iOS 10.3 amp-image-lightbox image does not resize on orientation change
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?
- Go here: https://ampbyexample.com/components/amp-image-lightbox/
- In portrait orientation, tap an image to open it in a lightbox
- 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
/cc @ericlindley-g
/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.
@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)
OK, as the referenced issue suggested, adding a timeout could be a temp fix.
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.
Webkit bug here: https://bugs.webkit.org/show_bug.cgi?id=170595
@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?
From the webkit bug description, it seems that it also provide wrong values during orientationchange event. So the temp fix could be the timeout.