Repository navigation
fix(wasm): Redispatch resize once viewport settles after rotation (backport #24216) - #24265
Merged
kazo0 merged 12 commits intoAug 29, 2026
Merged
Conversation
(cherry picked from commit b447eb8)
(cherry picked from commit b3100ba)
(cherry picked from commit 54a8f93)
(cherry picked from commit c3a2d38)
(cherry picked from commit 3519548)
(cherry picked from commit ba93a8a)
(cherry picked from commit c6ecb4b)
(cherry picked from commit b009a27)
(cherry picked from commit 425d767)
(cherry picked from commit 35d56d4)
(cherry picked from commit 6d8daa5)
(cherry picked from commit dbdbdde)
ajpinedam
approved these changes
Aug 28, 2026
2 of 4 tasks
kazo0
enabled auto-merge
August 28, 2026 15:47
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24265/wasm-skia-net9/index.html |
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24265/wasm-skia-net9/index.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitHub Issue: n/a — customer-reported, tracked internally.
PR Type:
🐞 Bugfix
What changed? 🚀
Current behavior: in a WebAssembly app using the Skia renderer, rotating the device between portrait and landscape can leave the app rendered at the wrong dimensions (controls squished / at the wrong scale). Some mobile browsers — observed with Chrome on iPad, while Safari is fine — fire
resize/orientationchangebefore the layout viewport (document.documentElement) has actually reflowed to the new size, and never fire a correctiveresizeafterward. SinceWebAssemblyWindowWrappersizes the window (and thus the Skia surface) fromdocumentElement.getBoundingClientRect()inside that earlyresizehandler, it keeps the stale pre-rotation dimensions until some other event forces a re-measure. Because rendering and input mapping both use the stale size, taps also land offset from the visuals.This PR installs a
ResizeObserverondocument.documentElement— the exact elementresize()measures from — in the Skia WASM host.ResizeObserverfires after layout, i.e. precisely when the element has actually settled to its post-rotation size. When the observed size differs from the last size the host measured, it re-dispatches a syntheticwindow.resize, restoring the corrective event the browser should have fired; the existing resize path then re-measures against the settled dimensions. The host records the last measured size on everyresize(), so when a native resize already handled the change the observer callback no-ops — no redundant dispatches, no loops (the observer only fires on actual size changes). Browsers withoutResizeObserverkeep the previous behavior.The fix is host-level and benefits app code too: application-level
window.resizelisteners were equally stale, and now receive the corrective event. Dispatching the global event (rather than re-measuring internally) is deliberate —BrowserRenderersizes the canvas from its ownwindow.resizelistener, so an internal-only re-measure would fix the window bounds but leave the canvas stale.Design notes / scope:
window.resizelistener stays the primary size source; the observer is only the corrective for the mis-ordered case. The native listener uniquely covers DPR-only resizes (browser zoom firesresizewithout changingdocumentElement's CSS size, which aResizeObservercannot see).uno.csspinshtml/bodyand the canvas toposition: fixed; width/height: 100%; overflow: hidden, so the viewport drivesdocumentElement— never the canvas — andresize()records the last measured size, making the observer a no-op whenever a native resize already handled the change.WindowManager.tsand may exhibit the same staleness, but per the Skia-first policy it is maintenance-only and intentionally out of scope here.RasterizationScaleon zoom/monitor moves) is a pre-existing, unrelated behavior and is unchanged.PR Checklist ✅
Wasm_ViewportOrientationTelemetry(Wasm category), which live-comparesXamlRoot.SizeagainstdocumentElement.getBoundingClientRect()with a STALE/OK banner and rawresize/orientationchangecounters, so the symptom and the fix are directly observable on a device.SamplesApp.Skia.WebAssembly.Browserserved over LAN, and as the equivalent logic A/B-toggled in a telemetry repro app) every rotation converges to the settled viewport size. Safari behavior is unchanged.Screenshots Compare Test Runresults.Credit: the root-cause analysis and the proposed
ResizeObserverapproach come from the reporting customer's investigation.This is an automatic backport of pull request #24216 done by [Mergify](https://mergify.com).