amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Do not collapse an ad when in current viewport

Open jasti opened this issue 9 years ago • 10 comments

Report from @jpettitt https://drive.google.com/file/d/0B7Ua3lXLZAIKMkt0YksyYmNVZGM/view happens on v 1486673261599

jasti avatar Feb 10 '17 19:02 jasti

Can be reproduced in canary on https://cdn.ampproject.org/c/dailydot.relaymedia.com/amp/upstream/only-in-hella-webseries-interview/

lannka avatar Feb 10 '17 20:02 lannka

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.

jpettitt avatar Feb 10 '17 21:02 jpettitt

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/

lannka avatar Feb 10 '17 21:02 lannka

@keithwrightbos any thoughts?

lannka avatar Feb 10 '17 21:02 lannka

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.

keithwrightbos avatar Feb 10 '17 22:02 keithwrightbos

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.

lannka avatar Feb 10 '17 22:02 lannka

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.

lannka avatar Feb 10 '17 23:02 lannka

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.

lannka avatar Feb 10 '17 23:02 lannka

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 avatar Feb 10 '17 23:02 keithwrightbos

@keithwrightbos FYI we're using amp-experiment to select between the 2 ad tags. It's 80/20 which one will fire.

jpettitt avatar Feb 11 '17 00:02 jpettitt