Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefetch the advertising info #696

Open
YuriyVelichkoPI opened this issue Sep 27, 2023 · 1 comment · May be fixed by #753
Open

Prefetch the advertising info #696

YuriyVelichkoPI opened this issue Sep 27, 2023 · 1 comment · May be fixed by #753
Assignees

Comments

@YuriyVelichkoPI
Copy link
Contributor

YuriyVelichkoPI commented Sep 27, 2023

Background

In the current implementation, the SDK requests the advertising info on each bid request. To avoid blocking, it is performed async in the background thread. However, the Prebid SDK in any case, is waiting until the OS returns the current advertising info. See the class AdIdManager of the SDK for the details.

This implementation has two major disadvantages:

To avoid runtime issues and get rid of delays in creating the bid request, the SDK should prefetch the advertising info so it's always available. The prefetching should take into consideration the Android policy to request the updated info each time it's needed and not cache it.

Proposal

Even though Android docs advise not to cache the ID, it's clear that this property won't be changed too often, especially during the single app session. So, if the SDK will fetch it on the initialization and refresh on each following bid request, it shouldn't violate privacy settings and other policies.

The general approach is displayed in the following diagram:

Prebid - Github Proposals

Step 1: The SDK on the initialization step runs the background task to fetch the advertising info and save it in memory. No saving to the persistent memory.
Step 2: Once the SDK is initialized, publishers can run bid requests
Step 3: Publisher calls the fetchDemand method, or any other, that leads to creating and sending the Bid Request.
Step 4: Prebid SDK uses the prefetched advertising info to build the Bid Request
Step 5: Prebid SDK updates the advertising info, starting the background task. The SDK doesn't wait for the result.
Step 6: SDK makes the bid request with prefetched advertising info

Once the updating task is finished, the advertising info will be actualized and used in the subsequent bid request.

Note: the diagram and description don't contain, but assume that fetching the advertising info is performed according to the user consent and permission as it is happening now.

Objectives

Once the proposal is reviewed, finalized, and approved, the implementation will assume the following steps:

  • Add the advertising ID fetching task to the SDK initialization
  • Update the flow of the building the Bid Request:
    • Use the prefetched advertising info
    • Run the async task to update the advertising info
  • Make sure that updating the advertising info is not performed too often. If the publisher runs bid requests for several ad units at the same time, there is no need to run an updating task for each request. We can introduce policies like "run no more than one advertising update task per minute". Hence, the method AdIdManager.updateAdvertizingId() should check the last update time before starting a new background task.
  • Cover new behavior with unit tests
  • Prepare run and study benchmarks for the initilizeSDK method to understand the impact of the new task.
@YuriyVelichkoPI
Copy link
Contributor Author

History note. The motivation for the proposed changes was raised in the discussion of this PR. This is not the first time we have experienced problems with the sequential retrieval of the advertising info while preparing the bid request.

@alexsavelyev alexsavelyev moved this from Triage to Needs Requirements in Prebid Mobile Prioritization Feb 22, 2024
@alexsavelyev alexsavelyev moved this from Needs Requirements to Ready for Dev in Prebid Mobile Prioritization Feb 22, 2024
@jsligh jsligh moved this from Ready for Dev to In Progress in Prebid Mobile Prioritization Apr 4, 2024
@jsligh jsligh self-assigned this Apr 4, 2024
@jsligh jsligh moved this from In Progress to Ready for Dev in Prebid Mobile Prioritization May 22, 2024
@jsligh jsligh moved this from Ready for Dev to In Progress in Prebid Mobile Prioritization May 22, 2024
@jsligh jsligh linked a pull request May 23, 2024 that will close this issue
@jsligh jsligh linked a pull request May 23, 2024 that will close this issue
@jsligh jsligh moved this from In Progress to Under Review in Prebid Mobile Prioritization Jul 30, 2024
@jsligh jsligh removed the in review label Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Under Review
Development

Successfully merging a pull request may close this issue.

2 participants