amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

iOS 10.3 amp-image-lightbox image does not resize on orientation change

Open mikeduarte opened this issue 9 years ago • 8 comments

On iOS 10.2 when I would open an image in an amp-image-lightbox in portrait then rotated the phone to landscape, the image would resize and fill the available space as well as get repositioned. On iOS 10.3 the image doesn't resize or move.

How do we reproduce the issue?

  1. Go here: https://ampbyexample.com/components/amp-image-lightbox/
  2. In portrait orientation, tap an image to open it in a lightbox
  3. Rotate your phone to landscape. Notice the image is stuck on the bottom left of screen.

What browsers are affected?

Mobile Safari 10.3

Which AMP version is affected?

  • ampbyexample link above is running: Version 1490652623650 of AMP.
  • Use to work fine in 10.2

mikeduarte avatar Mar 29 '17 13:03 mikeduarte

/cc @ericlindley-g

aghassemi avatar Mar 29 '17 15:03 aghassemi

/to @muxin

Take a look at this comments ( https://github.com/dimsemenov/PhotoSwipe/issues/1315#issuecomment-291897591 ) It explains what causes the bug in iOS 10.3. It also talks about a temp solution that we may need to do for 10.3 version and above.

aghassemi avatar Apr 06 '17 22:04 aghassemi

@dvoytenko The bug happens because the measurement of imageViewer (invoked by viewport resize event) happens before orientation change takes place (or wrong value when orientation change occurs). I wonder what should be an appropriate time for the measurement to happen? (Simply adding vsync around measurement doesn't work)

muxin avatar Apr 10 '17 21:04 muxin

OK, as the referenced issue suggested, adding a timeout could be a temp fix.

muxin avatar Apr 10 '17 21:04 muxin

Maybe we should listen for both? Resize events and orientation change events? That might be the most accurate and I hope that size is definitely updated for one of them.

dvoytenko avatar Apr 11 '17 01:04 dvoytenko

Webkit bug here: https://bugs.webkit.org/show_bug.cgi?id=170595

aghassemi avatar Apr 11 '17 16:04 aghassemi

@muxin Could you subscribe to https://bugs.webkit.org/show_bug.cgi?id=170595 so we can remove whatever hack we put in once it is fixed?

aghassemi avatar Apr 11 '17 16:04 aghassemi

From the webkit bug description, it seems that it also provide wrong values during orientationchange event. So the temp fix could be the timeout.

muxin avatar Apr 11 '17 18:04 muxin