amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

[amp-iframe] iframe height is being miscalculated

Open dmanek opened this issue 5 years ago • 5 comments

Description

On https://www.google.com/amp/s/www.nytimes.com/2021/04/20/us/black-history-continued-events.amp.html the iframe height is miscalculated, causing content to be chopped off.

Additional context: https://amphtml.slack.com/archives/C9HPA6HGB/p1622575649072900

Reproduction Steps

  1. Go to https://www.google.com/amp/s/www.nytimes.com/2021/04/20/us/black-history-continued-events.amp.html
  2. Notice content is chopped off at the bottom of the iframe. See screenshot" Screen Shot 2021-06-02 at 9 36 40 PM
  3. Another issue is following console error: Uncaught DOMException: Failed to set the 'domain' property on 'Document': Assignment is forbidden for sandboxed iframes.

Relevant Logs

No response

Browser(s) Affected

Chrome, Firefox

OS(s) Affected

No response

Device(s) Affected

No response

AMP Version Affected

No response

dmanek avatar Jun 03 '21 04:06 dmanek

The console error only occurs on the AMP viewer due to the page trying to set document.domain, which is only allowed for same or parent domain. It does not occur when accessing the page directly.

dmanek avatar Jun 03 '21 04:06 dmanek

After debugging the amp-iframe code, the updateSize_ callback receives height argument that is smaller than what is required for the iframe. I believe this is coming from the runtime. Any ideas @jridgewell?

dmanek avatar Jun 03 '21 16:06 dmanek

The iframe is responsible for requesting a size, and we're just granting it. It's not our responsibility to guess the correct size of the iframe.

jridgewell avatar Jun 03 '21 19:06 jridgewell

Thanks @jridgewell. Looks like the postMessage to resize the iframe is sending the wrong height. @callihiggins check out https://amp.dev/documentation/components/amp-iframe/#iframe-resizing and retry with a larger height?

dmanek avatar Jun 07 '21 16:06 dmanek

Closing this issue since it's not on AMP.

dmanek avatar Jun 28 '21 21:06 dmanek