amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

A4A doubleclick fails to destroy FIE when inside amp-sticky-ad

Open jridgewell opened this issue 8 years ago • 6 comments

Steps:

  1. https://www-newsweek-com.cdn.ampproject.org/c/s/www.newsweek.com/donald-trump-jr-and-girlfriend-kimberly-guilfoyle-denied-service-montana-1127418
  2. Scroll down to reveal sticky-ad
  3. 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
  4. Put a break point at AmpAdNetworkDoubleclickImpl.p.unlayoutCallback
    • Careful, there are 2 unlayoutCallback definitions in amp-ad-network-doubleclick-impl-0.1.js. You're looking for the one with this.useSra (AmpAdNetworkDoubleclickImpl's definition, not AmpA4A's definition)
  5. Close the amp-sticky-ad
  6. Observe that the unlayoutCallback early returns, and does not call AmpA4A.p.unlayoutCallback
    • AmpA4A's does the FIE destroying

This is causing a memory leak, with everything inside the FIE persisting in Resources and Layers

jridgewell avatar Sep 22 '18 02:09 jridgewell

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.

keithwrightbos avatar Sep 22 '18 14:09 keithwrightbos

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.

jridgewell avatar Sep 22 '18 21:09 jridgewell

Ah that does make a difference! Is there a way we can differentiate unlayoutCallback being called for sticky close vs user swipe between pages?

keithwrightbos avatar Sep 24 '18 15:09 keithwrightbos

No, unfortunately not.

jridgewell avatar Sep 24 '18 18:09 jridgewell

This issue doesn't have a category which makes it harder for us to keep track of it. @bradfrizzell Please add an appropriate category.

ampprojectbot avatar Sep 25 '18 08:09 ampprojectbot

Fixed by https://github.com/ampproject/amphtml/pull/18344.

jridgewell avatar Sep 25 '18 14:09 jridgewell