-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Convert ad iframes to get initialIntersection async #31753
Conversation
Hey @alanorozco! These files were changed:
|
I found one surprising attribute about IntersectionObserver Most likely according to spec, but I'm having trouble figuring out why that makes sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! But one question. PTAL.
In order to merge the helper without blocking on the ads changes, I've split it into its own PR (#31858) |
@samouri could you further elaborate on the change? shouldn't width/height be absolute values? |
I believe that both the Current Current |
Thansk @samouri . That sounds like not a problem to me for those ads. Another thing: amphtml/src/utils/intersection.js Lines 86 to 94 in 090da63
We are normalizing the inob entry data object using |
Unless I'm missing something, that is the new code :). Previously we didn't need to do anything special since the entries were calculated inside of JS. Now are are using real InObEntry objects which are not serializable, and so we need to convert them here to be plain object (and therefore eligible for postMessage) |
oh, my bad. then it looks great |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh wait a second. just saw this PR also touches amp-a4a.
would this change introduce latency to the rendering of an ad?
if it does, to avoid debugging an ads metric regression while promoting RC to prod, we'd better to run an explicit experiment for this change.
I'd expect it to create an ~10ms async delay. Likely unnoticeable in most circumstances (e.g. the resources system already often forces ~2s deprioritization on ads, which would be the rate-limiting factor) |
For changes that might affect ads performance, we need to run experiment to measure the impact before launch it. @calebcordry could you give some guidance for setting up such an experiment? |
@lannka: do you only want the experiment for a4a, or also for name-frame-renderer + amp-ad? |
Agree with @lannka. I would recommend wrapping the a4a/nameframe/safeframe/iframeGet all in an |
done! PTAL |
Just performed a sanity check and gltf viewer still behaves as expected + ad context still contains intialIntersection. |
* getContextMetadata --> Promise * ad iframes gather initialIntersection async * use experiments * remove log / fix test * revert test change now that under expeirment. * fix test-amp-ad-custom * caleb updates * toggle intersection needs win
summary
Alternative to #31714
Partial for #31540
AFAIK, only ads are supposed to use
initialIntersection
. The gltf extension happened to be using it as well, but IMO it shouldn't have since the message fromviewportCallback
should be more than good enough.Changes:
measureIntersection(el) --> Promise<IntersectionObserverEntry
initialIntersection
for ad iframes.Breaking change:
rootBounds
andintersectionRatio
are now according to spec as opposed to the definition we had been using. That means width/height is relative to viewport instead of the document's viewport.TODO: figure out a less brittle solution for the tests. potentially just delete the assertions on
intersectionRect
etc. now that we are using the real InOb, so likely not worth testing.I recommend viewing the changes with whitespace removed