WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
310087
Composited layers flash blank when window.scrollTo() is called synchronously with a DOM layout change on iOS
https://bugs.webkit.org/show_bug.cgi?id=310087
Summary
Composited layers flash blank when window.scrollTo() is called synchronously ...
kuanglingxi
Reported
2026-03-17 01:57:47 PDT
Description: On iOS (Safari / WKWebView), elements promoted to their own GPU compositing layer briefly flash blank when window.scrollTo({ behavior: 'instant' }) is called in the same synchronous JS task as a DOM layout change (e.g. changing an element's height). Elements affected (anything that creates an independent compositing layer): - transform: translateZ(0) - will-change: transform - <canvas> (always composited) Elements NOT affected: - Regular document-flow elements (no compositing promotion) Scroll method matters: - window.scrollTo() → flashes ✗ - element.scrollTop = (overflow container) → no flash ✓ Minimal reproduction (open on iOS and tap the button): <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> #top { height: 200px; background: #f0f4ff; } .composited { transform: translateZ(0); font-size: 24px; padding: 20px; background: #e8f0fe; } .normal { font-size: 24px; padding: 20px; background: #e8f0fe; margin-top: 12px; } .spacer { height: 2000px; } </style> </head> <body> <button onclick="trigger()" style="position:fixed;top:8px;left:8px;z-index:9">Trigger</button> <div style="height:60px"></div> <div id="top"></div> <div class="composited">Composited layer text (flashes)</div> <div class="normal">Normal text (no flash)</div> <div class="spacer"></div> <script> const heights = [200, 2000]; let cur = 200, idx = 0; window.scrollTo({ top: 160, behavior: 'instant' }); function trigger() { idx = (idx + 1) % heights.length; const diff = heights[idx] - cur; cur = heights[idx]; document.getElementById('top').style.height = cur + 'px'; window.scrollTo({ top: window.scrollY + diff, behavior: 'instant' }); } </script> </body> </html> Use case: This pattern is a common technique to preserve the viewport position when content above the visible area changes height. When a DOM element above the viewport grows or shrinks by diff pixels, calling window.scrollTo({ top: window.scrollY + diff }) in the same task compensates for the layout shift, so the user sees no visible jump. The intent is that nothing in the viewport should change visually — yet composited layer elements flash blank, which is exactly the opposite of the desired behavior. Expected: Composited layer elements remain visible throughout — the scroll compensates for the layout change and no visual change should be observable. Actual: The composited layer element briefly flashes blank/white on each trigger. Normal (non-composited) elements are unaffected. Workarounds found: We have discovered some workarounds, but none feel like the right fix: 1. Replace window.scrollTo() with element.scrollTop = on an overflow scroll container — avoids the issue entirely but requires restructuring the page layout. 2. Before calling window.scrollTo(), temporarily replace composited elements with a non-composited snapshot (e.g. a plain <img> without any compositing CSS) and restore them afterward — this masks the flash but adds complexity and overhead. Question for the WebKit team: Is there a recommended or idiomatic way to perform viewport-preserving scroll compensation alongside DOM layout changes without causing composited layers to flash? We want to understand whether this is a known limitation, a bug that will be fixed, or if there is a proper API or approach we should be using instead. Tested on: iOS 26, Safari
Attachments
Screen recording
(346.94 KB, video/quicktime)
2026-03-17 02:40 PDT
,
kuanglingxi
no flags
Details
Test
(1.09 KB, text/html)
2026-04-06 16:12 PDT
,
Simon Fraser (smfr)
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
kuanglingxi
Comment 1
2026-03-17 02:40:36 PDT
Created
attachment 478705
[details]
Screen recording
Radar WebKit Bug Importer
Comment 2
2026-03-23 17:38:22 PDT
<
rdar://problem/173197381
>
Simon Fraser (smfr)
Comment 3
2026-04-06 16:12:23 PDT
Created
attachment 478938
[details]
Test
Simon Fraser (smfr)
Comment 4
2026-04-06 16:13:34 PDT
I can reproduce.
Simon Fraser (smfr)
Comment 5
2026-04-06 16:32:30 PDT
This is because `RenderLayerCompositor::visibleRectForLayerFlushing()` uses `frameView->exposedContentRect()` which uses `m_delegatedScrollingGeometry->exposedContentRect()` which doesn't get updated until we get a message back from the UI process.
Simon Fraser (smfr)
Comment 6
2026-04-06 21:55:07 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/62166
EWS
Comment 7
2026-04-09 14:55:25 PDT
Committed
310864@main
(46fb2414dbc9): <
https://commits.webkit.org/310864@main
> Reviewed commits have been landed. Closing PR #62166 and removing active labels.
kuanglingxi
Comment 8
2026-04-16 02:21:32 PDT
(In reply to Simon Fraser (smfr) from
comment #6
)
> Pull request:
https://github.com/WebKit/WebKit/pull/62166
Thank you so much! By the way, can you confirm which iOS version this fix will be released with?
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug