A4A doubleclick fails to destroy FIE when inside amp-sticky-ad
Steps:
- https://www-newsweek-com.cdn.ampproject.org/c/s/www.newsweek.com/donald-trump-jr-and-girlfriend-kimberly-guilfoyle-denied-service-montana-1127418
- Scroll down to reveal sticky-ad
- Refresh and start over until you get a A4A doubleclick using FIE ad
$$('amp-sticky-ad iframe').filter(i => i.__AMP_EMBED__)to test if you have an FIE
- Put a break point at
AmpAdNetworkDoubleclickImpl.p.unlayoutCallback- Careful, there are 2
unlayoutCallbackdefinitions inamp-ad-network-doubleclick-impl-0.1.js. You're looking for the one withthis.useSra(AmpAdNetworkDoubleclickImpl's definition, notAmpA4A's definition)
- Careful, there are 2
- Close the amp-sticky-ad
- Observe that the
unlayoutCallbackearly returns, and does not callAmpA4A.p.unlayoutCallbackAmpA4A's does the FIE destroying
This is causing a memory leak, with everything inside the FIE persisting in Resources and Layers
This is intentional to allow for AMP creatives to survive when users swipe between tabs in the viewer and the result is an increase in CTR as the creative still exists if/when the user swipes back. FWIW - I've been meaning to remove the SRA carve-out as it no longer relevant now that we launched maintaining creative pageview state in the client.
Ha, forgot to put the "close the sticky-ad" step. This unlayoutCallback is happening because the <amp-sticky-ad> is being removed from the DOM tree. In this case, you must destroy the FIE because the iframe's context window itself is going to be destroyed when the it's removed from the tree.
Ah that does make a difference! Is there a way we can differentiate unlayoutCallback being called for sticky close vs user swipe between pages?
No, unfortunately not.
This issue doesn't have a category which makes it harder for us to keep track of it. @bradfrizzell Please add an appropriate category.
Fixed by https://github.com/ampproject/amphtml/pull/18344.