Skip to content

fix(skia-win32): defer native element SetWindowPos to present time - #23126

Merged
agneszitte merged 4 commits into
unoplatform:masterfrom
ramezgerges:win32_webview_flicker
Apr 28, 2026
Merged

agneszitte merged 4 commits into
unoplatform:masterfrom
ramezgerges:win32_webview_flicker

Conversation

@ramezgerges

Copy link
Copy Markdown
Contributor

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:

Other information ℹ️

ramezgerges and others added 2 commits April 23, 2026 12:08
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]>
Copilot AI review requested due to automatic review settings April 23, 2026 16:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SetWindowPos from ArrangeNativeElement to the RenderingNegativePathReevaluated callback (right before CopyPixels).
  • Introduce “pending arrange” state to apply position/size updates at present time and force clip recomputation.
  • Add Win32 SupportsZIndex / SetZIndex implementation for native-host render-order updates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 208907 did not find any UI Test snapshots differences.

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 208907 has failed on Uno.UI - CI.

@ramezgerges

Copy link
Copy Markdown
Contributor Author

/azp run

@ramezgerges
ramezgerges enabled auto-merge April 27, 2026 16:16
@ramezgerges
ramezgerges disabled auto-merge April 27, 2026 16:16
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 209566 has failed on Uno.UI - CI.

@agneszitte
agneszitte merged commit 7175acb into unoplatform:master Apr 28, 2026
42 checks passed
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants