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

Cache bids locally for Bidding Only API #1103

Open
YuriyVelichkoPI opened this issue Feb 11, 2025 · 3 comments
Open

Cache bids locally for Bidding Only API #1103

YuriyVelichkoPI opened this issue Feb 11, 2025 · 3 comments
Assignees

Comments

@YuriyVelichkoPI
Copy link
Contributor

YuriyVelichkoPI commented Feb 11, 2025

Description

Reported by @bretg.

Turns out putting banners into Prebid Cache is expensive and not 100% reliable. It would be good to explore ways to cut out that middleware.

Bid data is being sent from PBS anyhow: price, adm, etc. I see this block in the PUC:

  // For MoPub, creative is stored in localStorage via SDK.
  let search = 'Prebid_';
  if (uuid.substr(0, search.length) === search) {
    loadFromLocalCache(uuid);
    //register creative right away to not miss initial geom-update
    updateIframe(size);

Is there a way to force this loadFromLocalCache() behavior in GAM? (edited)

Objectives

  • Investigate how Prebid Mobile can work without Prebid Cache for bidding Only API.
  • Propose the solution
@justadreamer
Copy link

Postindustria has prototyped the approach 5(!) years ago, but has never contributed it. I think it can be resurrected now from the top commits of our forks:

The approach comes down to supplying a localhost URL to PUC as a cache server. Then on iOS it has to be a local running HTTPS server (that's a security requirement for webviews that it can't fetch file:/// URLs in the top frame I believe on iOS). On Android I think local file:/// URL worked, but needs to be verified - please check the code mentioned above.

@bretg
Copy link
Contributor

bretg commented Feb 11, 2025

Thanks for exploring this @YuriyVelichkoPI and @justadreamer. What about the existing loadFromLocalCache() function? Could that work?

https://github.com/prebid/prebid-universal-creative/blob/5fbde2b59b11939b65ad7771373bddc676088ed4/src/mobileAndAmpRender.js#L40

function loadFromLocalCache(cacheId) {
  let bid = window.localStorage.getItem(cacheId);
  let displayFn = responseCallback(true);
  displayFn(bid);
}

@justadreamer
Copy link

justadreamer commented Feb 11, 2025

Hi @bretg that's a great direction of thought. Out of the box it won't work for mobile obviously, because on mobile, WebView is a fully isolated rendering context, instantiated and owned by Google Mobile Ads SDK. Unlike browser in the AMP case it is not the same context that was requesting the bid and could have stored it in the localStorage.
However Prebid SDK can traverse the view hierarchy and find the rendering WebView - it then can try to inject JS that would put the creative into the localStorage. However synchronization will be of essence here as PUC may render before that and will fail to find it in the cache, JS may then need to re-render.
The prototype mentioned above is a bit more involved, but also less intrusive as it does not require any injections or tinkering with the object owned by GMA SDK - it relies on a normal way to cross the border of an isolated WebView - i.e. providing PUC with an URL to download the creative from. So we have at least 2 approaches to explore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Triage
Development

No branches or pull requests

3 participants