Skip to content

fix(hosting): Ignore frame requests after FramePacer disposal - #25196

Open
MartinZikmund wants to merge 2 commits into
masterfrom
dev/mazi/framepacer-disposal
Open

MartinZikmund wants to merge 2 commits into
masterfrom
dev/mazi/framepacer-disposal

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

GitHub Issue: part of #25139

PR Type:

🐞 Bugfix

What changed? 🚀

An X11 Expose could call FramePacer.RequestFrame() on the event thread after the close path had disposed the timer, aborting the Linux Desktop WebGPU lane with exit 134.

Split out of #25140 (part of the WebGPU lane stabilization tracked in #25139). In the 8 days to 2026-10-09, 36 of 39 master builds had a failed WebGPU job.

Cluster Cause Change Kind
FramePacer disposed timer (X11 exit 134) An X11 Expose could call RequestFrame() on the event thread after the close path disposed the timer Requests and disposal serialized; a request or pending tick after disposal is a no-op. New Given_FramePacer unit tests failed with the CI exception before the fix root-cause fix

Results (CI build 238511, every WebGPU lane forced on, all fixes combined)

WebGPU lane Failed tests, all attempts Before (8-day window, builds with test failures)
Desktop Linux 0 4 / 141 (+ occasional exit-134 abort)

PR Checklist ✅

🤖 Generated with Claude Code

https://claude.ai/code/session_01TP1JtY64etkfxxGCms44aN

Copilot AI balanced review requested due to automatic review settings October 10, 2026 21:30

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the area/automation Categorizes an issue or PR as relevant to project automation label Oct 10, 2026
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 21s —— View job


Review summary

Verdict: ship (2 nits, 0 blocking)

  • Read the diff and FramePacer.cs
  • Posted inline findings

Assessment: This is a root-cause fix, not just a guard. RequestFrame() and Dispose() are now serialized under _gate, and _disposed makes later requests a no-op. That closes the ObjectDisposedException race from the X11 Expose path. The unit tests cover both the sequential case and the concurrent case. I did not build or run them; this was a code review only. Code style, braces and tabs are consistent with the repo, and no event Action was introduced.

Cross-cutting notes

  • The new InternalsVisibleTo("Uno.UI.UnitTests") and the ProjectReference to Uno.UI.Runtime in the unit test project are reasonable. Please confirm on CI that the added reference doesn't change the unit test build or TFM resolution.
  • Dispose() does not wait for an in-flight Elapsed callback. This is noted inline.

_targetIntervalTicks = FpsToTicks(fps);
_timer = new Timer { AutoReset = false, Interval = TargetIntervalMs };
_timer.Elapsed += (_, _) => onTimerElapsed();
_timer.Elapsed += (_, _) =>

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.

Nit (defensive, not a regression): the _disposed check here is check-then-act and is not under _gate, so a tick already dequeued from the thread pool can still invoke onTimerElapsed() just after Dispose() returns. That's fine if the callback tolerates a closing host, but the PR description says a "pending tick after disposal is a no-op", which is only best-effort. Consider softening the wording or the comment, and confirm the callbacks in the hosts (X11 etc.) handle a late invocation.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 238845 found UI Test snapshots differences: skia-linux-screenshots: 118, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 118 changed over 2458

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ClipboardTests.png-dark
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • DisplayInformation.png-dark
    • DropDownButtonPage.png-dark
    • CalendarView_Theming.png-dark
    • Buttons.png-dark
    • CalendarView_Theming.png
    • Buttons.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • DynamicFont.png-dark
    • DynamicFont.png
    • Focus_FocusVisual_Properties.png-dark
  • skia-windows-screenshots: 2458 changed over 2486

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png
    • Accessibility_ScreenReader.png-dark
    • AndroidWindowInsets.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AppBarButtonWithIconTest.png
    • AppBar_KeyBoard.png
    • AnimatedVisualsTestbedPage.png
    • AppBarButtonWithIconTest.png-dark
    • ApplicationViewMode.png
    • Application_DispatcherShutdownMode.png
    • ApplicationViewSizing.png-dark
    • AppBar_KeyBoard.png-dark
    • AppWindowClosing.png
    • AppXamlDefinedResources.png-dark
    • AppWindowFeatures.png-dark
    • ApplicationViewSpanningRectsPage.png-dark
    • AppWindowPresenters.png
    • Arrange_Performance01.png
    • AppWindowTitleBar Properties.png-dark
    • AppWindowFeatures.png

@unodevops

Copy link
Copy Markdown
Contributor

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

@morning4coffe-dev morning4coffe-dev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified: the diff, the full FramePacer.cs at head, the new _gate/_disposed serialization, the X11 close path (X11XamlRootHost.cs:147-148), and the three FramePacer call sites (X11, macOS, Win32). Code review only; I did not build or run the unit tests.

Findings:

  1. X11 can still hit the crash class this PR fixes, in the window it leaves open. The Elapsed handler checks _disposed (FramePacer.cs:36-41) and then calls onTimerElapsed() outside _gate. If the timer thread passes the check, and the close path then runs Dispose() and _renderRequested.Dispose() (X11XamlRootHost.cs:147-148), the callback _renderRequested.Set() (X11XamlRootHost.Rendering.cs:19) throws ObjectDisposedException on a threadpool thread. System.Timers.Timer does not catch that, so the process goes down. The macOS SignalFrameDue already guards exactly this with a catch of ObjectDisposedException (MacOSWindowHost.cs, around line 1038), and its remarks describe the same hazard. Suggested fix: invoke the callback under _gate in the handler (lock (_gate) { if (!_disposed) onTimerElapsed(); }), so Dispose() waits for an in-flight callback. All three callbacks are non-blocking Set() calls, so this does not deadlock; add a remark that onTimerElapsed must not block.

  2. The stress test (Given_FramePacer.cs:104-125) only asserts that the requester thread throws nothing. It never has an Elapsed callback in flight, so it will not catch finding 1. A test that holds the callback open (or a callback that calls Set() on a disposed event) would.

  3. The new ProjectReference from Uno.UI.UnitTests to Uno.UI.Runtime, together with InternalsVisibleTo, pulls the full Skia runtime into the unit test build. Please confirm on CI that the unit test TFM resolution and build time are unchanged, as the description asks.

Validation: the "fails before, passes after" claim for the first test is plausible (Timer.Enabled = true throws on a disposed timer), but I have not run it.

@MartinZikmund MartinZikmund added the 7.0 PRs only. For issues, use the Release field. label Nov 4, 2026
@MartinZikmund

Copy link
Copy Markdown
Member Author

@Mergifyio backport release/stable/7.0

@mergify

mergify Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

backport release/stable/7.0

🟠 Waiting for conditions to match

Details
  • merged [📌 backport requirement]

@mergify

mergify Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

7.0 PRs only. For issues, use the Release field. area/automation Categorizes an issue or PR as relevant to project automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants