Repository navigation
fix(skia-win32): defer native element SetWindowPos to present time - #23126
Conversation
Previously, ArrangeNativeElement called SetWindowPos synchronously on the child HWND while FrameRendered was firing, roughly a full frame before the Skia pixels reached the parent's framebuffer via CopyPixels. DWM's compose cycle could tick in that gap, sampling the child at its new position over the parent's previous frame — visible as airspace flicker when scrolling a native host. Stash the intended rect in ArrangeNativeElement and apply SetWindowPos from OnRenderingNegativePathReevaluated, which fires inside the render tick between Skia playback and CopyPixels. The child move and the Skia present now happen microseconds apart on the same dispatcher tick, shrinking the window where DWM can observe an inconsistent state. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ContentPresenter.OnNativeHostsRenderOrderChanged falls back to detach+reattach of the native element on every z-order change — and on the "element scrolled out of view" path. For hosts like WebView2 this tears down and rebuilds the browser surface each time, visibly flickering during scroll. Implement SupportsZIndex/SetZIndex on the Win32 extension so z-order is realised via Win32's built-in child z-order (SetWindowPos with HWND_TOP). Since SetZIndex is invoked for every host in ascending z-order, moving each to HWND_TOP in turn leaves the final ordering consistent with the Uno visual tree. Out-of-view hosts stay attached and are clipped by their offscreen arrange rect rather than being torn down. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Defers Win32 native child HWND positioning to the moment the Skia frame is being presented, aiming to reduce flicker when native elements move (e.g., during scrolling) by aligning SetWindowPos with the render/present cycle.
Changes:
- Defer
SetWindowPosfromArrangeNativeElementto theRenderingNegativePathReevaluatedcallback (right beforeCopyPixels). - Introduce “pending arrange” state to apply position/size updates at present time and force clip recomputation.
- Add Win32
SupportsZIndex/SetZIndeximplementation for native-host render-order updates.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23126/wasm-skia-net9/index.html |
|
The build 208907 did not find any UI Test snapshots differences. |
|
|
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23126/wasm-skia-net9/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23126/wasm-skia-net9/index.html |
|
|
GitHub Issue: closes https://github.com/unoplatform/kahua-private/issues/449
PR Type:
What is the current behavior? 🤔
What is the new behavior? 🚀
PR Checklist ✅
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Runresults.Other information ℹ️