Skip to content

Android + NativeAOT SamplesApp aborts with FORTIFY pthread_mutex_lock on a destroyed mutex since the .NET 11 Preview 7 bump #24208

Closed

Description

@MartinZikmund

Current behavior 🐛

On feature/breakingchanges (Uno Platform 7.0, net11.0), the Android + NativeAOT SamplesApp aborts with a native libc fortify failure roughly 0.3–0.5 s after the runtime-test engine starts enumerating tests. The process dies before writing a single test result, so all five Tests - Android+NativeAOT Skia CI jobs fail with "The test results file … does not contain any results".

The abort, verbatim from logcat (test group 3, build 7.0-dev.569):

--------- beginning of crash
08-26 12:10:03.662  4678  4878 F libc            : FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x7c447e440768)
08-26 12:10:03.748   525  2499 I ActivityManager : Process uno.platform.samplesapp.skia.nativeaot (pid 4678) has died: fg  TOP
08-26 12:10:03.751   356   356 I Zygote          : Process 4678 exited cleanly (0)

There is no managed exception, no ART FATAL EXCEPTION, and no Java stack trace — it is a pure native abort. Nothing is written to /data/tombstones before the CI harness tears the emulator down, so no backtrace has been captured yet.

Characteristics, consistent across all five parallel test groups and every branch build since 2026-08-22:

  • The crashing thread is always the guest Vulkan thread — its first appearance in logcat is D goldfish_vulkan: ensureSyncDeviceFd: created sync device for current Vulkan process: N.
  • The crash always lands 0.3–0.5 s after the last managed log line, I NativeAotFromAndroid: Filtering with group #N — i.e. exactly when the runtime-test engine finishes filtering and starts driving the UI.
  • The app is fully alive before that: JavaInteropRuntime loads, NativeAotRuntimeProvider.onCreate() runs, Skia/Vulkan initialises, the app renders frames (EGL_emulation: app_time_stats), and it writes its canary file. It is not a startup/trimming failure.
Test group pid / crashing tid last managed line abort
0 4511 / 4707 Filtering with group #0 @ 12:10:09.725 12:10:10.186
1 4702 / 4806 Filtering with group #1 @ 12:10:35.976 12:10:36.303
2 4631 / 4825 Filtering with group #2 @ 12:10:25.759 12:10:26.255
3 4678 / 4878 Filtering with group #3 @ 12:10:02.971 12:10:03.662
4 4688 / — Filtering with group #4 @ 12:10:10.507 12:10:10.966 (F line not captured)

Expected behavior 🎯

The Android + NativeAOT SamplesApp should run the Uno Platform runtime-test suite to completion, as it did before the .NET 11 Preview 7 bump and as the non-AOT Android Skia flavour still does today on the same commit, same emulator image and same SkiaSharp version.

How to reproduce it (as minimally and precisely as possible) 🔬

Reproduces 5/5 jobs, every CI run, on the unoplatform/uno feature/breakingchanges branch. No separate repro project needed — it is the SamplesApp head built exactly as CI does it:

# .NET SDK 11.0.100-preview.7.26381.103 (pinned in build/ci/net11/_global.json)
# Android workload packs 37.0.0-preview.7.2131

dotnet publish src/SamplesApp/SamplesApp/SamplesApp.csproj \
  -c Release \
  -r android-x64 \
  -f net11.0-android \
  -p:UnoTargetFrameworkOverride=net11.0-android \
  -p:ApplicationId=uno.platform.samplesapp.skia.nativeaot \
  -p:SkiaPublishAot=true \
  -p:SkiaSharpVersion=4.151.1

Then install on an API 34 x86_64 emulator (-gpu swiftshader_indirect -no-window -memory 4096) and launch with the runtime-test autostart extras:

adb install .../uno.platform.samplesapp.skia.nativeaot-Signed.apk
ACT=$(adb shell cmd package resolve-activity --brief uno.platform.samplesapp.skia.nativeaot | tail -n 1 | tr -d '\r')
adb shell am start -n "$ACT" \
  -e UITEST_RUNTIME_TEST_GROUP 0 \
  -e UITEST_RUNTIME_TEST_GROUP_COUNT 5 \
  -e UITEST_RUNTIME_AUTOSTART_RESULT_FILE /storage/emulated/0/Android/data/uno.platform.samplesapp.skia.nativeaot/files/TestResult.xml \
  -e UITEST_RUNTIME_TESTS_FILTER fA==
adb logcat

The app dies shortly after NativeAotFromAndroid: Filtering with group #0 appears in logcat.

The full CI recipe lives in build/ci/tests/.azure-devops-tests-android-nativeaot-skia-build.yml (publish) and build/test-scripts/android-run-skia-runtime-tests.sh (install + launch + result polling).

Regression window 🔎

The Tests - Android+NativeAOT Skia stage on feature/breakingchanges went from fully green to fully red in a single commit range:

CI build Commit NativeAOT stage
7.0-dev.391 (227595) 40c4a89814452996e2fa78bc30d68c7fcc3a1e9f ✅ 5/5 green
7.0-dev.392 (227658) 9582c40fd26a70bf18f3166d764a1767c4dc6357 ❌ 5/5 red

40c4a8981..9582c40 contains exactly three commits — the merge of #24054 plus its two commits:

  • f42da0432d8 — chore: Update to .NET 11 Preview 7
  • c8242ccecda — chore: use Mono.Cecil 0.11.6

It has been red on every branch build since (2026-08-14 → today).

Note that the failure presented in two distinct phases, which is why this went unnoticed for a while:

  1. 2026-08-14 → 2026-08-22 — Error: Activity class {…/crc6448f3b0362cbf4bc9.MainActivity} does not exist. Preview 7 changed the generated JCW type name prefix from crc64… to scrc64…, and the CI script hard-coded the old name. Fixed in fix(ci): Resolve the Android launcher activity dynamically #24120 (0589bca5b87, resolve the launcher activity via cmd package resolve-activity).
  2. Since f06611905 (merge of fix(ci): Resolve the Android launcher activity dynamically #24120) → today — the activity resolves and the app launches correctly, revealing the pthread_mutex_lock abort described above. This is the currently unresolved failure.

What has been ruled out ✅

  • Not the emulator or the Vulkan/Skia path in general. On the same branch build (7.0-dev.569, ADO build 230320), the non-AOT Tests - Android Skia stage runs the identical test suite on the identical emulator image and passes 5/5. The only build-flag delta between the two heads is -p:SkiaPublishAot=true -r android-x64.
  • Not SkiaSharp. Both Android heads resolve SkiaSharp 4.151.1 (src/Directory.Build.targets:77 is the default; the NativeAOT job's -p:SkiaSharpVersion=4.151.1 is redundant). The 4.151.1 bump (738de3da678, 2026-08-09) was already in the last green NativeAOT run.
  • Not an Uno Platform-side regression in that window. The regression range contains only the .NET 11 Preview 7 + Mono.Cecil commits; no Uno source changed.
  • Not a general branch health problem. On build 230320 every other stage is green (21 of 23); the only other red stage is Tests - iOS Skia, which failed for an unrelated 90-minute agent timeout.
  • Not visible on master. master is still on .NET 10 and its Tests - Android+NativeAOT Skia stage passes (e.g. ADO builds 229621, 229680).

Workaround 🛠️

None known. The stage cannot currently gate anything, because build/ci/tests/.azure-devops-tests-android-nativeaot-skia.yml skips these jobs on PR builds (condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))), so only the branch's own CI build exercises them.

Renderer 🎨

Skia

Affected platforms 📱💻🖥️

Android (NativeAOT only — Mono/CoreCLR flavour unaffected)

Uno.Sdk version (and other relevant versions) 📦

Branch feature/breakingchanges (Uno Platform 7.0 development branch), built from source.

Component Version
.NET SDK 11.0.100-preview.7.26381.103 (build/ci/net11/_global.json, rollForward: disable)
Target framework net11.0-android, RID android-x64
Microsoft.Android.Sdk.Linux 37.0.0-preview.7.2131
Microsoft.Android.Runtime.NativeAOT.37.android-x64 37.0.0-preview.7.2131
SkiaSharp 4.151.1
Emulator API 34, x86_64, -gpu swiftshader_indirect -no-window -memory 4096
CI agent Ubuntu (self-hosted Linux pool), KVM enabled

The build emits warning XA1040: The NativeAOT runtime on Android is an experimental feature and not yet suitable for production use, so this may ultimately belong in dotnet/android — happy to move it there.

Anything else we need to know? 💬

@jonpryor — flagging you since this falls out of #24054 (the Preview 7 bump) and is squarely in NativeAOT-on-Android territory.

Two things that would help pin it down and that we can wire up on our side if useful:

  • Tombstones. build/test-scripts/android-run-skia-runtime-tests.sh currently pulls only the test-result XML and a logcat -d dump. Adding an adb pull /data/tombstones (or adb shell cmd stats/bugreport) on failure would give a symbolicated native backtrace for the aborting thread instead of just the fortify line.
  • A narrower repro. The crash needs the runtime-test engine to actually start driving the UI, so a plain "launch the app" smoke test does not reproduce it — the app renders happily for several seconds first. If a smaller NativeAOT + Skia + Vulkan repro would help, tell us what shape you want and we will build it.

Public CI evidence (anonymous access):

Activity

  1. added
    kind/bug
    platform/android 🤖
    triage/untriaged
    area/skia ✏️
    on Aug 26, 2026
  2. jonpryor commented on Aug 26, 2026

    @jonpryor
    Contributor

    I am confused. 😅

    I think (suspect?) that the FORTIFY: message is a red herring.

    For "local repro and investigation" purposes, when I:

    1. Run emulator-uno,

    2. Begin logging:

      adb logcat > log.txt
    3. Install uno.platform.samplesapp.skia.nativeaot-Signed.apk from CI

      adb install ~/Downloads/uno.platform.samplesapp.skia.nativeaot-Signed.apk
    4. Run the tests "like" CI does:

      adb shell pm grant uno.platform.samplesapp.skia.nativeaot android.permission.WRITE_EXTERNAL_STORAGE
      adb shell pm grant uno.platform.samplesapp.skia.nativeaot android.permission.READ_EXTERNAL_STORAGE
      adb shell am start -n "uno.platform.samplesapp.skia.nativeaot/scrc6415f86cac20992436.MainActivity" \
        -e UITEST_RUNTIME_TEST_GROUP 0 \
        -e UITEST_RUNTIME_TEST_GROUP_COUNT 5 \
        -e UITEST_RUNTIME_TESTS_FILTER fA== \
        -e UITEST_RUNTIME_AUTOSTART_RESULT_FILE /storage/emulated/0/Android/data/uno.platform.samplesapp.skia.nativeaot/files/TestResult.xml

    I see the app launch, and then ~immediately exit. log.txt (from 2) contains:

    08-26 12:29:42.488   341   341 D Zygote  : Forked child process 14057
    …
    08-26 12:29:42.534 14057 14057 I .skia.nativeaot: Using CollectorTypeCC GC.
    08-26 12:29:42.543 14057 14057 E .skia.nativeaot: Not starting debugger since process cannot load the jdwp agent.
    …
    08-26 12:29:42.551 14057 14057 D CompatibilityChangeReporter: Compat change id reported: 171979766; UID 10190; state: ENABLED
    08-26 12:29:42.551 14057 14057 D CompatibilityChangeReporter: Compat change id reported: 242716250; UID 10190; state: ENABLED
    …
    08-26 12:29:51.001 14057 14119 I NativeAotFromAndroid: Filtering with group #0
    08-26 12:29:51.120 14057 14088 D EGL_emulation: app_time_stats: avg=327.96ms min=16.79ms max=1472.60ms count=7
    08-26 12:29:51.285   510  3574 I ActivityManager: Process uno.platform.samplesapp.skia.nativeaot (pid 14057) has died: fg  TOP 
    …
    08-26 12:29:51.286   510   538 I libprocessgroup: Successfully killed process cgroup uid 10190 pid 14057 in 0ms
    …
    08-26 12:29:51.287   341   341 I Zygote  : Process 14057 exited cleanly (0)
    

    In this run, I don't have the FORTIFY: pthread_mutex_lock called on a destroyed mutex message.

    I do have this message:

    Zygote  : Process 14057 exited cleanly (0)
    

    Similar-but-different, if I:

    1. Go to CI for: https://dev.azure.com/uno-platform/Uno%20Platform/_build/results?buildId=230320&view=results
    2. Download 28 published > runtime-tests-android-skia-nativeaot-results > android-skia-34-net10 > android-device-log-RuntimeTests-0-RuntimeTests.interim.txt

    We see content resembling the original report -- FORTIFY message, etc. -- along with the "Process exited cleanly" message:

    08-26 12:10:09.725  4511  4653 I NativeAotFromAndroid: Filtering with group #0
    …
    08-26 12:10:10.024  4511  4566 D EGL_emulation: app_time_stats: avg=614.65ms min=11.81ms max=4015.62ms count=8
    …
    --------- beginning of crash
    08-26 12:10:10.186  4511  4707 F libc    : FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x7ab6bd70ddc8)
    08-26 12:10:10.186  4511  4707 F libc    : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 4707 (Thread-8), pid 4511 (.skia.nativeaot)
    …
    08-26 12:10:10.284   521   551 I libprocessgroup: Successfully killed process cgroup uid 10190 pid 4511 in 0ms
    …
    08-26 12:10:10.290   354   354 I Zygote  : Process 4511 exited cleanly (0)
    …
    08-26 12:10:10.310   521  2290 I ActivityManager: Process uno.platform.samplesapp.skia.nativeaot (pid 4511) has died: fg  TOP 
    

    What I suspect is happening is the following:

    1. App is started with UITEST_RUNTIME_TEST_GROUP=0, UITEST_RUNTIME_TEST_GROUP_COUNT=5, UITEST_RUNTIME_TESTS_FILTER=fA==, and UITEST_RUNTIME_AUTOSTART_RESULT_FILE=…/TestResult*.xml
    2. App reads those values, and runs no tests. …/TestResult*.xml is saved.
    3. App exits, as per:
      await SampleControl.Presentation.SampleChooserViewModel.Instance.RunRuntimeTests(
      CancellationToken.None,
      runtimeTestResultFilePath,
      () => System.Environment.Exit(0));

      Note line 94, which calls Environment.Exit(0).

    It is after (during?) the Environment.Exit(0) invocation that CI gets the "beginning of crash" message, and it's because we're in the "middle" of exiting the process that no stack trace/etc. can be provided: the process is gone, there's nothing to log!

    Meanwhile, (2) happens; from the Run Android+NativeAOT Skia Tests log:

    + /agent/_work/1/s/build/android-sdk/platform-tools/adb pull /storage/emulated/0/Android/data/uno.platform.samplesapp.skia.nativeaot/files/TestResult-20260826120957.xml TestResult-20260826120957.xml
    The app is not running anymore
    /storage/emulated/0/Android/data/uno.platform.samplesapp.skia.nativeaot/files/TestResult-20260826120957.xml: 1 file pulled, 0 skipped. 0.0 MB/s (1344 bytes in 0.049s)
    …
    + pushd /agent/_work/1/s/src/Uno.NUnitTransformTool
    + echo 'Running NUnitTransformTool'
    + dotnet run fail-empty /agent/_work/1/s/build/TestResult-20260826120957.xml
    /agent/_work/1/s/src/Uno.NUnitTransformTool /agent/_work/1/s/build
    Running NUnitTransformTool
    Using launch settings from /agent/_work/1/s/src/Uno.NUnitTransformTool/Properties/launchSettings.json...
    The test results file /agent/_work/1/s/build/TestResult-20260826120957.xml does not contain any results
    

    TestResult-20260826120957.xml was created. We could adb pull it. We did not crash before it could be written.

    The problem is that TestResult-20260826120957.xml is empty; when I run it locally, it has the contents:

    <?xml version="1.0" encoding="utf-16"?>
    <test-run id="a03920aa-c901-4909-b52b-1168f7a45a3a" name="Runtime Tests" testcasecount="0" result="Passed" time="0" total="0" errors="0" passed="0" failed="0" inconclusive="0" skipped="0" asserts="0" run-date="2026-08-26" start-time="15:23:14" end-time="11:23:15">
      <test-suite type="Assembly" name="SamplesApp.Skia">
        <environment machine-name="localhost" platform="n/a" />
        <test-suite type="TestFixture" name="a03920aa-c901-4909-b52b-1168f7a45a3a" executed="true" testcasecount="0" result="Passed" time="0" total="0" errors="0" passed="0" failed="0" inconclusive="0" skipped="0" asserts="0" />
      </test-suite>
    </test-run>

    Note testcasecount="0" and total="0".


    My assertion is that if any tests were executed, the Runtime Tests * stages would be green, even if adb logcat mentions the FORTIFY message, because the FORTIFY message is written too late to be relevant.

    The problem is that we're not finding tests to run.

  3. jonpryor commented on Aug 26, 2026

    @jonpryor
    Contributor

    Possibly related/variation on the analysis: dotnet/maui#32166 in which a MAUI app calls Application.Current.Quit(), and crashes with a SIGSEGV (signal 11) -- which we don't observe here -- but does contain the FORTIFY messages:

    [libc] FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x7b0c631cb8)
    [libc] FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x7b0c631cb8)
    
  4. jonpryor commented on Aug 26, 2026

    @jonpryor
    Contributor

    "Obvious followup is obvious": so why aren't any tests found?

    This is Native AOT, so "debuggers" don't exist, so time to printf-debug this:

    diff --git a/src/SamplesApp/SamplesApp.Shared/App.xaml.cs b/src/SamplesApp/SamplesApp.Shared/App.xaml.cs
    index 782dd0521b..0e55a96ee8 100644
    --- a/src/SamplesApp/SamplesApp.Shared/App.xaml.cs
    +++ b/src/SamplesApp/SamplesApp.Shared/App.xaml.cs
    @@ -509,7 +509,7 @@ namespace SamplesApp
     
     #if !DEBUG
     				// Exclude logs below this level
    -				builder.SetMinimumLevel(LogLevel.Information);
    +				builder.SetMinimumLevel(LogLevel.Debug);
     #else
     				// Exclude logs below this level
     				builder.SetMinimumLevel(LogLevel.Debug);
    diff --git a/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewModel.cs b/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewModel.cs
    index 59efcea3a6..8f88986bfe 100644
    --- a/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewModel.cs
    +++ b/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewModel.cs
    @@ -137,6 +137,7 @@ namespace SampleControl.Presentation
     			{
     				_log.Info($"Found {_categories.SelectMany(c => c.SamplesContent).Distinct().Count()} sample(s) in {_categories.Count} categories.");
     			}
    +			Console.WriteLine($"# jonp: Found {_categories.SelectMany(c => c.SamplesContent).Distinct().Count()} sample(s) in {_categories.Count} categories.");
     
     			_ = _dispatcher.RunAsync(
     					async () =>
    @@ -811,6 +812,7 @@ namespace SampleControl.Presentation
     				from sample in _allSamples
     				let sampleAttribute = FindSampleAttribute(sample.Type)
     				select (sample, sampleAttribute);
    +			Console.WriteLine($"# jonp: SampleChooserViewModel.InitializeCategories: samples ({samples.Count()}):\n\t{string.Join("\n\t", samples.Select(s => s.GetType().FullName))}");
     
     			// Group samples into categories.
     			var categories =
    @@ -820,6 +822,7 @@ namespace SampleControl.Presentation
     				group content by category into contentByCategory
     				orderby contentByCategory.Key.ToLower(CultureInfo.CurrentUICulture)
     				select new SampleChooserCategory(contentByCategory);
    +			Console.WriteLine($"# jonp: SampleChooserViewModel.InitializeCategories: categories ({categories.Count()}):\n\t{string.Join("\n\t", categories.Select(c => c.Category))}");
     
     			_allCategories = categories.ToList();
     			_visibleCategories = _allCategories.Where(c => !c.Category.StartsWith('_')).ToList();
    diff --git a/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UnitTest/UnitTestsControl.cs b/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UnitTest/UnitTestsControl.cs
    index 03528614b2..3183712f49 100644
    --- a/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UnitTest/UnitTestsControl.cs
    +++ b/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UnitTest/UnitTestsControl.cs
    @@ -1351,13 +1351,16 @@ namespace Uno.UI.Samples.Tests
     		[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "Appears to work on CI!")]
     		private IEnumerable<UnitTestClassInfo> InitializeTests()
     		{
    +			Console.WriteLine($"# jonp: UnitTestsControl.InitializeTests: AppDomain.Assemblies ({AppDomain.CurrentDomain.GetAssemblies().Count()}):\n\t{string.Join("\n\t", AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetName().Name))}");
     			var testAssembliesTypes =
     				from asm in AppDomain.CurrentDomain.GetAssemblies()
     				where asm.GetName().Name.EndsWith("tests", StringComparison.OrdinalIgnoreCase)
     				from type in asm.GetTypes()
     				select type;
    +			Console.WriteLine($"# jonp: UnitTestsControl.InitializeTests: testAssembliesTypes ({testAssembliesTypes.Count()}):\n\t{string.Join("\n\t", testAssembliesTypes.Select(t => t.FullName))}");
     
     			var types = GetType().GetTypeInfo().Assembly.GetTypes().Concat(testAssembliesTypes);
    +			Console.WriteLine($"# jonp: UnitTestsControl.InitializeTests: types ({types.Count()}):\n\t{string.Join("\n\t", types.Select(t => t.FullName))}");
     
     			if (_ciTestsGroupCountCache != -1)
     			{
    @@ -1377,6 +1380,7 @@ namespace Uno.UI.Samples.Tests
     					filteredGroups.Add(i, [.. tests]);
     
     					this.Log().Info($"Filtered group {i}: {testCount} tests");
    +					Console.WriteLine($"# jonp: UnitTestsControl.InitializeTests: Filtered group {i}: {testCount} tests");
     				}
     
     				// Ensure that tests are not present in multiple groups
    @@ -1403,6 +1407,7 @@ namespace Uno.UI.Samples.Tests
     			}
     
     			var groupedList = GetFilteredTests(types, _ciTestsGroupCountCache, _ciTestGroupCache);
    +			Console.WriteLine($"# jonp: UnitTestsControl.InitializeTests: groupedList ({groupedList.Count()}):\n\t{string.Join("\n\t", groupedList)}");
     
     			return groupedList.ToArray();
     		}
    @@ -1416,6 +1421,7 @@ namespace Uno.UI.Samples.Tests
     				where type.GetTypeInfo().GetCustomAttribute(typeof(TestClassAttribute)) != null
     				orderby type.Name
     				select type;
    +			Console.WriteLine($"# jonp: UnitTestsControl.GetFilteredTests(groups={groupCount}, active={activeGroup}): testClasses ({testClasses.Count()}):\n\t{string.Join("\n\t", testClasses.Select(t => t.FullName))}");
     #pragma warning disable IL2072
     			var groupedList =
     				from type in testClasses
    @@ -1425,6 +1431,7 @@ namespace Uno.UI.Samples.Tests
     				where g.Count() != 0
     				select BuildTestClassInfo(g.Key, g.ToArray());
     #pragma warning restore IL2072
    +			Console.WriteLine($"# jonp: UnitTestsControl.GetFilteredTests(groups={groupCount}, active={activeGroup}): groupedList ({groupedList.Count()}):\n\t{string.Join("\n\t", groupedList)}");
     			return groupedList;
     		}
     
    @@ -1436,7 +1443,9 @@ namespace Uno.UI.Samples.Tests
     			var buffer = Encoding.UTF8.GetBytes(method.DeclaringType.FullName + "." + method.Name);
     			var hash = _sha1.ComputeHash(buffer);
     
    -			return BitConverter.ToUInt64(hash, 0);
    +			var group = BitConverter.ToUInt64(hash, 0);
    +			Console.WriteLine($"# jonp: UnitTestsControl.GetTypeTestGroup: method `{method.DeclaringType.FullName}.{method.Name}` is in group: {group}");
    +			return group;
     		}
     
     		private static UnitTestClassInfo BuildTestClassInfo([DynamicallyAccessedMembers(RunTestsForInstanceRequirements)] Type type, MethodInfo[] tests)

    The above could use some improvements, but rebuilds are slow, so… relevant output:

    08-26 13:38:15.857 11523 11523 I NativeAotFromAndroid: # jonp: Found 1412 sample(s) in 133 categories.
    

    That sounds good.

    08-26 13:38:21.667 11523 11578 I NativeAotFromAndroid: # jonp: UnitTestsControl.InitializeTests: types=
    08-26 13:38:21.667 11523 11578 I NativeAotFromAndroid: 	<>f__AnonymousType0`1
    …34 *thousand* lines later…
    08-26 13:38:22.158 11523 11578 I NativeAotFromAndroid: # jonp: UnitTestsControl.InitializeTests: Filtered group 0: 0 tests
    08-26 13:38:22.389 11523 11578 I NativeAotFromAndroid: # jonp: UnitTestsControl.InitializeTests: Filtered group 1: 0 tests
    08-26 13:38:22.619 11523 11578 I NativeAotFromAndroid: # jonp: UnitTestsControl.InitializeTests: Filtered group 2: 0 tests
    08-26 13:38:22.850 11523 11578 I NativeAotFromAndroid: # jonp: UnitTestsControl.InitializeTests: Filtered group 3: 0 tests
    08-26 13:38:23.079 11523 11578 I NativeAotFromAndroid: # jonp: UnitTestsControl.InitializeTests: Filtered group 4: 0 tests
    08-26 13:38:23.193 11523 11578 I NativeAotFromAndroid: Filtering with group #0
    08-26 13:38:23.308 11523 11551 I .skia.nativeaot: Explicit concurrent copying GC freed 273(85KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 4149KB/8298KB, paused 6us,4us total 3.736ms
    08-26 13:38:23.333 11523 11578 I NativeAotFromAndroid: # jonp: UnitTestsControl.InitializeTests: groupedList=
    

    That's not good. At least this further confirms that no tests are being executed…

    Circle back with MOAR printfs, now with counts!

    08-26 14:01:46.047 21914 22052 I NativeAotFromAndroid: # jonp: UnitTestsControl.InitializeTests: AppDomain.Assemblies (250):
    …
    08-26 14:01:46.087 21914 22052 I NativeAotFromAndroid: # jonp: UnitTestsControl.InitializeTests: testAssembliesTypes (2470):
    …
    08-26 14:01:46.821 21914 22052 I NativeAotFromAndroid: # jonp: UnitTestsControl.InitializeTests: types (33289):
    …
    08-26 14:01:47.108 21914 22052 I NativeAotFromAndroid: # jonp: UnitTestsControl.GetFilteredTests(groups=5, active=0): testClasses (0):
    

    …and that right there might be the problem? This is from:

    		private IEnumerable<UnitTestClassInfo> GetFilteredTests(IEnumerable<Type> types, int groupCount, int activeGroup)
    		{
    			var testClasses =
    				from type in types
    				where type.GetTypeInfo().GetCustomAttribute(typeof(TestClassAttribute)) != null
    				orderby type.Name
    				select type;
    			Console.WriteLine($"# jonp: UnitTestsControl.GetFilteredTests(groups={groupCount}, active={activeGroup}): testClasses ({testClasses.Count()}):\n\t{string.Join("\n\t", testClasses.Select(t => t.FullName))}");

    meaning that despite having 33289 types, none have [TestClass].

    It's thus time to cross-reference things. Do we have types with [TestClass]? Yes:

    % git grep -1 '\[.*TestClass.*\]' src
    …
    src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyPropertyGeneratorTests/Given_DependencyPropertyGenerator.cs-
    src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyPropertyGeneratorTests/Given_DependencyPropertyGenerator.cs:[TestClass]
    src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyPropertyGeneratorTests/Given_DependencyPropertyGenerator.cs-public class Given_DependencyPropertyGenerator
    …

    Though not all matches are relevant. Consider the above: src/SourceGenerators is not included in SamplesApp, so the above match doesn't matter. Nor does src/Uno.Analyzers.Tests, or src/Uno.HotReload.Tests, or src/Uno.UI.DevServer.Cli.E2E.Tests, or…

    What could matter? src/Uno.UI.RuntimeTests seems plausible:

    src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/appbar/AppBarIntegrationTests.cs-{
    src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/appbar/AppBarIntegrationTests.cs:       [TestClass]
    src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/appbar/AppBarIntegrationTests.cs-       public class AppBarIntegrationTests : BaseDxamlTestClass
    --
    src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/calendardatepicker/CalendarDatePickerIntegrationTests.cs-{
    src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/calendardatepicker/CalendarDatePickerIntegrationTests.cs:       [TestClass]
    src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/calendardatepicker/CalendarDatePickerIntegrationTests.cs-       public partial class CalendarDatePickerIntegrationTests : BaseDxamlTestClass
    …
    

    CalendarDatePickerIntegrationTests does not appear in adb logcat output. Maybe …/dxaml/… isn't relevant either?

    --
    src/Uno.UI.RuntimeTests/MUX/Input/Focus/FocusTests.cs-{
    src/Uno.UI.RuntimeTests/MUX/Input/Focus/FocusTests.cs:  [TestClass]
    src/Uno.UI.RuntimeTests/MUX/Input/Focus/FocusTests.cs-  [RequiresFullWindow]
    

    The above is for Uno.UI.RuntimeTests.MUX.Input.Focus.FocusTests, which does not appear in adb logcat.

    adb logcat does contain Uno.UI.Samples.Content.UITests.FocusTests.FocusManagerTest, but that's a [Sample] type, not a [TestClass] type.

    Spot checking git grep … output, nothing in src/Uno.UI.RuntimeTests/ appears in adb logcat either. For example, Given_Uri isn't mentioned.

    Those tests are in Uno.UI.RuntimeTests.dll, and Uno.UI.RuntimeTests is mentioned in adb logcat:

    08-26 14:01:46.047 21914 22052 I NativeAotFromAndroid: # jonp: UnitTestsControl.InitializeTests: AppDomain.Assemblies (250):
    …
    08-26 14:01:46.047 21914 22052 I NativeAotFromAndroid:  Uno.UI.RuntimeTests
    

    However, what's odd is that Given_Uri isn't found:

    08-26 14:01:46.087 21914 22052 I NativeAotFromAndroid: # jonp: UnitTestsControl.InitializeTests: testAssembliesTypes (2470):
    …
    08-26 14:01:46.087 21914 22052 I NativeAotFromAndroid:  Uno.UI.RuntimeTests.When_MenuFlyout_DataContext_Changes_In_Opening
    …
    08-26 14:01:46.110 21914 22052 I NativeAotFromAndroid:  Uno.UI.RuntimeTests.Tests.Windows_Storage.Given_StorageFolder_Native_Base
    …
    

    My theory is that Given_Uri -- and all other [TestClass]-attributed types -- are removed by the trimmer during Native AOT generation. What's preserved is all code referenced by [Sample]-attributed types.

    With that theory in mind, what if we told the linker to not trim that assembly?

    diff --git a/src/SamplesApp/SamplesApp/SamplesApp.csproj b/src/SamplesApp/SamplesApp/SamplesApp.csproj
    index 724aa096ee..15cfa7ee98 100644
    --- a/src/SamplesApp/SamplesApp/SamplesApp.csproj
    +++ b/src/SamplesApp/SamplesApp/SamplesApp.csproj
    @@ -104,6 +104,8 @@
     		<ProjectReference Include="..\..\AddIns\Uno.WinUI.SpellChecking\Uno.WinUI.SpellChecking.csproj" />
     		<ProjectReference Include="..\..\AddIns\Uno.WinUI.Graphics3DGL\Uno.WinUI.Graphics3DGL.csproj" />
     		<ProjectReference Include="..\..\AddIns\Uno.WinUI.Graphics2DSK\Uno.WinUI.Graphics2DSK.Crossruntime.csproj" />
    +
    +		<TrimmerRootAssembly Include="Uno.UI.RuntimeTests" RootMode="All" />
     	</ItemGroup>
     
     	<!-- Desktop framework variants + runtimes + AddIns (Win32/X11/FrameBuffer/macOS) -->

    With that change, tests actually run (yay), and adb logcat contains:

    08-26 15:00:07.008 31487 31487 I NativeAotFromAndroid: # jonp: SampleChooserViewModel.InitializeCategories: samples (1419):
    …
    08-26 15:00:07.136 31487 31487 I NativeAotFromAndroid: # jonp: SampleChooserViewModel.InitializeCategories: categories (134):
    …
    08-26 15:00:07.198 31487 31487 I NativeAotFromAndroid: # jonp: Found 1412 sample(s) in 133 categories.
    …
    08-26 15:00:12.251 31487 31623 I NativeAotFromAndroid: # jonp: UnitTestsControl.InitializeTests: AppDomain.Assemblies (253):
    # 3 more assemblies than last time?!
    …
    08-26 15:00:12.389 31487 31623 I NativeAotFromAndroid: # jonp: UnitTestsControl.InitializeTests: testAssembliesTypes (9701):
    # up from 2470!
    …
    08-26 15:00:13.223 31487 31623 I NativeAotFromAndroid: # jonp: UnitTestsControl.InitializeTests: types (40520):
    # up from 33289!
    …
    08-26 15:00:13.737 31487 31623 I NativeAotFromAndroid: # jonp: UnitTestsControl.GetFilteredTests(groups=5, active=0): testClasses (436):
    # up from 0!
    …
    08-26 15:00:13.893 31487 31623 I NativeAotFromAndroid: # jonp: UnitTestsControl.GetTypeTestGroup: method `Microsoft.UI.Xaml.Tests.MUXControls.ApiTests.RepeaterTests.AccessibilityTests.ValidateChildrenPeers` is in group: 4114059220024542768
    # this message wasn't previously present
    …
    08-26 15:00:20.815 31487 31623 I NativeAotFromAndroid: Filtering with group #0
    08-26 15:00:21.122 31487 31623 I NativeAotFromAndroid: # jonp: UnitTestsControl.GetFilteredTests(groups=5, active=0): testClasses (436):
    …
    

    It also takes considerably longer to run (shock!).

    TestsResult.xml contains (abbreviated):

    <?xml version="1.0" encoding="utf-16"?>
    <test-run id="bb505580-1a85-486a-aff5-c0c550de4438" name="Runtime Tests" testcasecount="1335" result="Failed" time="0" total="1335" errors="0" passed="1321" failed="4" inconclusive="10" skipped="127" asserts="0" run-date="2026-08-26" start-time="19:00:12" end-time="15:06:38">
      <test-suite type="Assembly" name="SamplesApp.Skia">
        <environment machine-name="localhost" platform="n/a" />
        <test-suite type="TestFixture" name="bb505580-1a85-486a-aff5-c0c550de4438" executed="true" testcasecount="1335" result="Failed" time="0" total="1335" errors="0" passed="1321" failed="4" inconclusive="10" skipped="127" asserts="0">
          <test-case name="CanClickAButtonInAnAppBar" fullname="Windows.UI.Tests.Enterprise.AppBarIntegrationTests.CanClickAButtonInAnAppBar" classname="Windows.UI.Tests.Enterprise.AppBarIntegrationTests" methodname="CanClickAButtonInAnAppBar" duration="0" time="0" result="Skipped" />
          …
          <test-case name="ValidateDayMonthYearFormatProperties()" fullname="Microsoft.UI.Tests.Controls.DatePickerTests.DatePickerIntegrationTests.ValidateDayMonthYearFormatProperties()" classname="Microsoft.UI.Tests.Controls.DatePickerTests.DatePickerIntegrationTests" methodname="ValidateDayMonthYearFormatProperties" duration="0.0372176" time="0" result="Failed">
            <failure>
              <message>Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException: Assert.Fail failed. Exception thrown by action on the UI thread: Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException: Assert.AreEqual failed. Expected string length 21 but was 23. 'expected' expression: 'expectedDayString', 'actual' expression: 'dayTextBlock.Text'.
    Expected: "Friday, June 15, 1990"
    But was:  "Thursday, June 14, 1990"
    -----------^
       at Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowAssertAreEqualFailed(Object, Object, String)
       at Microsoft.UI.Tests.Controls.DatePickerTests.DatePickerIntegrationTests.&lt;&gt;c__DisplayClass13_0.&lt;ValidateDayMonthYearFormatProperties&gt;b__3()
       at MUXControlsTestApp.Utilities.RunOnUIThread.&lt;&gt;c__DisplayClass4_0.&lt;ExecuteAsync&gt;b__0()
       at MUXControlsTestApp.Utilities.RunOnUIThread.&lt;&gt;c__DisplayClass7_0.&lt;&lt;ExecuteAsync&gt;b__0&gt;d.MoveNext()
       at Microsoft.VisualStudio.TestTools.UnitTesting.Assert.Fail(String)
       at MUXControlsTestApp.Utilities.RunOnUIThread.&lt;ExecuteAsync&gt;d__7.MoveNext()
    --- End of stack trace from previous location ---
       at MUXControlsTestApp.Utilities.RunOnUIThread.&lt;ExecuteAsync&gt;d__5.MoveNext()
    --- End of stack trace from previous location ---
       at MUXControlsTestApp.Utilities.RunOnUIThread.&lt;ExecuteAsync&gt;d__4.MoveNext()
    --- End of stack trace from previous location ---
       at Microsoft.UI.Tests.Controls.DatePickerTests.DatePickerIntegrationTests.&lt;ValidateDayMonthYearFormatProperties&gt;d__13.MoveNext()
    --- End of stack trace from previous location ---
       at Uno.UI.Samples.Tests.UnitTestsControl.&lt;&gt;c__DisplayClass74_2.&lt;&lt;ExecuteTestsForInstance&gt;g__InvokeTestMethod|5&gt;d.MoveNext()</message>
            </failure>
          </test-case>
          …
          <test-case name="When_StrokeLineJoin_Round_Renders()" fullname="Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Shapes.When_Shape.When_StrokeLineJoin_Round_Renders()" classname="Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Shapes.When_Shape" methodname="When_StrokeLineJoin_Round_Renders" duration="0.0004935" time="0" result="Passed" />
        </test-suite>
      </test-suite>
    </test-run>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/skia ✏️kind/bugplatform/android 🤖triage/untriaged

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions