Skip to content

CI reliability: dangling macOS native handle and unbounded test bodies #24111

Open

Description

@MartinZikmund

Current behavior

A teardown of every build for pipeline Uno.UI - CI between 2026-06-18 and 2026-08-18 (674 builds, 630 with full timeline + failure artifacts) turned up four defects that make CI unreliable in ways that are independent of any individual flaky test. Ranking failures by the number of distinct source branches affected — rather than by artifact file, which over-counts a single red branch that gets re-queued — isolates them clearly.

1. A dangling macOS native element handle crashes the whole test job.

A hard SIGSEGV in objc_retain inside libUnoNativeMac was recovered from crash reports on 11 different branches. It kills the Tests - Desktop Skia macOS job outright, so the results of every other test in the run are lost.

objc_retain                                    (libobjc.A.dylib)  <-- SIGSEGV
<unnamed>                                      (libUnoNativeMac.dylib)
Microsoft.UI.Xaml.Controls.ContentPresenter.AttachNativeElement()
Microsoft.UI.Xaml.Controls.ContentPresenter.EnterImpl(...)
Microsoft.UI.Xaml.UIElement.AddChild(...)

Reached from two triggers: WindowHelper.RestoreOriginalWindowContent() and MediaPlayerElement full-window toggling.

uno_native_dispose does not deallocate on its own — [element dispose] only calls removeFromSuperview, and the NSView dies when [transients removeObject:] drops the last strong reference. MacOSNativeElement raised that from the managed Unloaded event, which fires on any tree leave including a reparent, while leaving NativeHandle pointing at the freed view. Re-entering the tree then hands that pointer to uno_native_attach, and ARC retains freed memory.

2. Test bodies have no timeout, so one hang costs the entire shard.

Exactly 2 of 4675 [TestMethod]s carry [Timeout]. UnitTestsControl.GetTestTimeout returned null for the rest and the harness then awaited the body bare. A single hung test consumes the full 60-minute job budget and the run ends with no results file at all, so every other test in that shard reports nothing. DefaultUnitTestTimeout exists but is only applied to Initialize/Cleanup steps.

Split: two further defects originally filed here — the Hot Reload workspace scenario that can pass without running, and the RID cross-check on CoreCLR-on-Android — moved to #24124 (fixed by #24125), together with two more Hot Reload test defects found later. This issue now covers only the two non-Hot-Reload items above.

Expected behavior

  • A dead native peer can never be handed back to native code; a use-after-free is impossible by construction rather than by luck of ordering.
  • A hung test fails on its own and the shard still publishes results for everything else.
  • A hot-reload run that executed no tests fails instead of passing.

How to reproduce

Observed across the CI corpus rather than locally; per-test assertion text is retrievable anonymously from _apis/test/Runs/{runId}/results/{resultId}. Items 2 and 4 reproduce deterministically:

  • 2: add a test whose body awaits a never-completing TaskCompletionSource and run the suite — the job hangs to its limit and no results file is produced.
  • 4: run the workspace test with a filter containing the fully qualified outer test name; the HRApp executes nothing and the test passes.

Workaround

None for item 1 beyond re-applying [PlatformCondition(Exclude, SkiaMacOS)] to When_MediaPlayerElement_SetIsFullWindow_Check_Fullscreen, which was [Ignore]d on Skia until 2026-08-07.

Works on UWP/WinUI

N/A — CI infrastructure and Uno-specific hosting code.

Environment

Skia targets (macOS, Windows, Linux), Skia-on-Android CoreCLR head, feature/breakingchanges.

Related

Part of the flaky-test roundup #9080 and runtime-test reliability #23354. Adjacent, not addressed here: #24005, #24006 (macOS host freezes / stall diagnosability), #23967 (When_MsAppData hang), #23695 (ScrollViewer extent chase, which is the mechanism behind the flaky Given_ListViewBase.When_Incremental_Load_ShouldStop).

The dominant individual flaky tests found by the same teardown are a separate matter and are not fixed here: five WebAssembly tests share one root cause in the accessibility bridge, where _isAccessibilityEnabled is set once and never cleared, leaving FocusSynchronizer and FocusManager.SuppressNativeFocus armed for the rest of the shard. That needs its own issue and validation on the WASM leg.

Activity

  1. added
    kind/bug
    on Aug 19, 2026
  2. changed the title [-]CI reliability: dangling macOS native handle, unbounded test bodies, and two tests that cannot fail correctly[/-] [+]CI reliability: dangling macOS native handle and unbounded test bodies[/+] on Aug 19, 2026
  3. added theissue type on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/cikind/bug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions