Lightbox flickers on Android only when Google Maps is rendered underneath #418
|
Hi, I’m seeing an Android-specific flickering issue with yet-another-react-lightbox, but only when a Google Maps map is rendered underneath the lightbox. On Android phones, if I open the lightbox over a Google Maps map and swipe between the images enough times, the whole lightbox/page occasionally flickers. It does not happen on every swipe, but after moving between images for a while it happens. When the flicker happens, it affects the image and also the buttons in the top-right corner, so it looks like the whole lightbox layer briefly redraws or flashes. I only see this when Google Maps is open/rendered underneath the lightbox. If the lightbox is tested without the map underneath, I do not see the same flickering.
Minimal sandbox: Thanks a lot in advance! |
Replies: 1 comment 1 reply
|
Hi, Thank you for the detailed report and the repro. I haven't reproduced the flicker myself since I don't have a test Android device on hand, but your description pinpoints the cause pretty clearly. I looked into both problems, and they share the same root cause. Neither is a lightbox bug, and unfortunately there is no CSS setting that can isolate the lightbox from the map, because it's not a stacking or paint-order problem. Here is what's going on. Android flickeringThe images in your repro are full-size camera originals — 4000×3000 (12 MP), up to 9.6 MB each. A decoded 12 MP image takes roughly 48 MB of GPU memory, and since the carousel keeps the adjacent slides mounted for smooth swiping, moving between slides churns through 100–150 MB of GPU texture uploads. Google Maps is the second half of the equation. It renders through a WebGL canvas that holds its own large GPU allocation and keeps repainting on every frame — even underneath the lightbox. Two things in your setup make that worse:
GPU memory on Android phones is limited. After enough swipes, Chrome hits memory pressure and drops and rebuilds its compositor layer tree, which re-rasterizes the entire overlay at once — that's exactly the symptom you're describing, where the image and the toolbar buttons flash together. Without the map there is enough GPU headroom, so it never triggers. What I recommend, in order of impact:
Slow image loading on iOSThis one is mostly caused by the same two factors. The cache-busting parameter means iOS Safari can never serve the images from HTTP cache, so every open re-downloads ~13 MB over the network. On top of that, iOS Safari is noticeably slower than Android Chrome at decoding very large JPEGs — it decodes lazily and applies downsampling heuristics to huge images — so a 12 MP photo shows a visible delay before it appears. There is no lightbox setting that makes a 4000×3000 JPEG decode faster on an iPhone; the fix is the same: drop the cache-buster and serve multiple image resolutions via One honest caveat: the flicker itself is a browser compositor behavior (Chrome on Android under GPU memory pressure), so no library can prevent it outright — but with reasonably sized images you should never come close to triggering it. Hope this helps! |
Hi,
Thank you for the detailed report and the repro. I haven't reproduced the flicker myself since I don't have a test Android device on hand, but your description pinpoints the cause pretty clearly. I looked into both problems, and they share the same root cause. Neither is a lightbox bug, and unfortunately there is no CSS setting that can isolate the lightbox from the map, because it's not a stacking or paint-order problem. Here is what's going on.
Android flickering
The images in your repro are full-size camera originals — 4000×3000 (12 MP), up to 9.6 MB each. A decoded 12 MP image takes roughly 48 MB of GPU memory, and since the carousel keeps the adjacent slides mounted for smooth sw…