Do not collapse an ad when in current viewport
Report from @jpettitt https://drive.google.com/file/d/0B7Ua3lXLZAIKMkt0YksyYmNVZGM/view happens on v 1486673261599
Can be reproduced in canary on https://cdn.ampproject.org/c/dailydot.relaymedia.com/amp/upstream/only-in-hella-webseries-interview/
Try https://cdn.ampproject.org/c/dailydot.relaymedia.com/amp/upstream/only-in-hella-webseries-interview/?_rmversion=test the top 320x50 doesn't fill most of the time (that may change when the tag gets fixed but for now it's a solid repro case.
Looks like a known issue. Might be related to the domain migration, the new domain does not have the problem: https://dailydot-relaymedia-com.cdn.ampproject.org/c/dailydot.relaymedia.com/amp/upstream/only-in-hella-webseries-interview/
@keithwrightbos any thoughts?
Is this a new issue? I believe what is going on is that ad request includes sz=0x0 for doubleclick blocks indicating they have no size. This causes our ad server to return a 400 response without a CORS header leading to an incorrect flow (essentially collapse behavior). I actually started investigating this today unrelated to this issue.
I found they're actually two separate issues. @keithwrightbos please take a look the Fetch API failure.
I'm looking into this collapse issue, and I believe it has been there from the beginning, meaning element at the top can collapse.
Tracked down the error to here. We actually never handle UI jump caused by element collapse above viewport (we only handled for element expand).
This is something we should do.
To make it clear, in this particular issue reported, the element to be collapsed is at the very top of the page, we have no way to prevent UI jump after collapsing it, so we should not collapse.
Looking into the fetch API issue, it appears the publisher has two amp-ad elements at the top of the page. The second has class rmAdRelay which sets display:none on the element. Delayed fetch understands not to send a request in this case as it appears that layoutCallback is never executed since display is set to none. However, fast fetch has already sent the request with a size set at 0x0 which causes an error response code and no access control response headers.
It would seem to me that the fix is within onLayoutMeasure do not initiate the adPromise chain if the height/width is 0 (an indicator of display none). I will open a separate issue to track.
@keithwrightbos FYI we're using amp-experiment to select between the 2 ad tags. It's 80/20 which one will fire.