Repository navigation
fix(x11): Stable pointer ids under a WM + DisplayInformation init race - #23844
ramezgerges merged 3 commits into
Conversation
WM-generated crossing events (map-under-pointer, grab activation) carry sourceid = master while regular events carry sourceid = slave, so keying PointerId on sourceid splits one cursor into two pointer ids. Controls tracking a single pointer id (e.g. NavigationViewItem) then ignore all real pointer events for the poisoned element, which broke NavigationView expand/collapse on Linux under a window manager. Co-Authored-By: Claude Fable 5 <[email protected]>
SetWindowIcon ran in Task.Run and resolved the scaled icon path via BitmapImage.GetScaledPath, which reads DisplayInformation. On cold starts this created the window's DisplayInformation concurrently with window init; its extension registered on the host, then UpdateDetails hit a NullReferenceException in UpdateRenderTimerFps (frame pacer not created yet), the exception was swallowed by Task.Run, and the next DisplayInformation creation crashed the app with "X11DisplayInformationExtension is set twice". Resolve the icon path on the UI thread and offload only the decode and X11 property calls, logging their failures. Create the frame pacer before UpdateWindowPropertiesFromPackage since reading the DPI reports the refresh rate through UpdateRenderTimerFps. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR fixes two X11/Skia Linux regressions in Uno.UI.Runtime.Skia.X11: (1) inconsistent pointer IDs under some window managers that broke NavigationViewItem pointer tracking, and (2) a startup race where DisplayInformation could be initialized from a thread-pool task during window icon setup, leading to crashes and “extension set twice” failures.
Changes:
- Create mouse
PointerIdfrom the XI2deviceid(while keeping touch IDs based ondetail) to avoid WM-induced master/slave ID mismatches. - Reorder X11 host initialization so the frame pacer exists before
DisplayInformationcan report refresh rate viaUpdateRenderTimerFps. - Keep icon path resolution on the UI thread and offload only decoding/X11 property setting, with error logging for failures during the offloaded work.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Uno.UI.Runtime.Skia.X11/Hosting/X11XamlRootHost.cs | Reorders frame pacer creation and adjusts window icon initialization to avoid DisplayInformation thread-pool races. |
| src/Uno.UI.Runtime.Skia.X11/Devices/Input/X11PointerInputSource.XInput.cs | Uses a stable XI2 identifier for mouse pointer IDs to prevent per-cursor pointer ID splitting under WMs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Clarify why deviceid is the master pointer id given the deviceid == sourceid filtering, and honor the pointerType parameter in CreatePointerEventArgsFromEnterLeaveEvent instead of hard-coding Mouse. Co-Authored-By: Claude Fable 5 <[email protected]>
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23844/wasm-skia-net9/index.html |
|
|
|
Tick the box to add this pull request to the merge queue (same as
|
…#23736, unoplatform#23844 Restores unoplatform#23736 (WSLg's XWM re-detaches subwindows without override-redirect set via XSetWindowAttributes, plus a best-effort post-reparent ownership check) and unoplatform#23844 (frame pacer created before the DPI read that spins up DisplayInformation; icon decoding offloaded per-icon instead of racing DisplayInformation creation off the UI thread). unoplatform#23895's Compositor.IsSoftwareRenderer line was already covered by the branch's own GraphicsContextKind-based assignment - the duplicate line from the merge was dropped. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XsQppKuZgijApgJxaTZt81
GitHub Issue: #23159 (fixes the "can't click anything in the left-hand tree" regression; the WebView rendering problems tracked in that issue are separate and remain open)
PR Type:
🐞 Bugfix
What changed? 🚀
1. NavigationView items didn't expand/navigate on click on Linux under a window manager (
fix(x11): Use master device id for mouse pointer id)The X11 host derived
PointerIdfrom the XI2sourceid. Under a WM (reproduced with mutter; does not reproduce on bare Xvfb), crossing events generated by the WM — map-under-pointerXI_Enter, grab activation/deactivationXI_Leave/XI_Enter— arrive withsourceid= the master pointer, while button/motion events carrysourceid= the slave device. One physical cursor therefore produced two different pointer ids.NavigationViewItemtracks a single pointer id (m_trackedPointerId, ported WinUI logic) and early-returns on id mismatch in every handler — includingPointerExited, the only place the tracked id is reset. Once an item saw a master-sourced crossing, it ignored every subsequent real pointer event, permanently. Controls without per-pointer-id tracking (ButtonBase: chevron,CheckBox,ToggleSwitch) kept working, as did keyboard invoke, which is why this presented as "NavigationView expansion is broken" (Uno.Gallery left nav, SamplesAppNavigationView_Pane_Automated).Fix: derive the mouse pointer id from
deviceid(the master device — the X11 "one cursor" concept, matching the master-delivered event copies the handler already keeps). Touch ids are unchanged (detail).Instrumented capture of a poisoned click (Uno.Gallery
6.7.0-dev.815artifact under Xvfb + mutter), before the fix:After the fix, the same scenario invokes and expands correctly (validated at runtime by swapping the rebuilt assemblies into the same Gallery artifact under the same Xvfb + mutter setup).
2. Startup crash
X11DisplayInformationExtension is set twice(fix(x11): Keep DisplayInformation init off the thread pool)SetWindowIconran insideTask.Runand resolved the scaled icon path viaBitmapImage.GetScaledPath, which readsDisplayInformation. On cold starts the task could win the race against the rest of theX11XamlRootHostconstructor:GetForCurrentView()created the window'sDisplayInformation; itsX11DisplayInformationExtensionregistered itself on the host, thenUpdateDetails()reported the XRandR refresh rate viaUpdateRenderTimerFps, which dereferenced the not-yet-assigned_framePacer→NullReferenceException.DisplayInformationconstructor, soGetOrCreateForWindowIdnever cached the instance — but the host kept the half-initialized extension.Task.Runswallowed the exception, so nothing was logged.DisplayInformationcreation fromX11WindowWrapper..ctorthen hitInvalidOperationException: X11DisplayInformationExtension is set twice→ unhandled → app aborts at startup.Fix: resolve the icon path on the UI thread (only the PNG decode and the
_NET_WM_ICONX11 calls — which takeXLock— are offloaded, and their failures are now logged instead of swallowed), and create the frame pacer beforeUpdateWindowPropertiesFromPackage()so reporting the refresh rate during DPI initialization can't NRE.Validation: making the call synchronous surfaced the previously-swallowed NRE deterministically at the exact call site; with the frame-pacer reorder the app starts cleanly, the extension is created once on the UI thread, and window-icon behavior is unchanged.
PR Checklist ✅
Xvfb+mutter --x11); bare Xvfb (as used by CI) does not reproduce. Manual repro steps documented above.Screenshots Compare Test Runresults.🤖 Generated with Claude Code