Skip to content

test: unit test assemblies are trimmer roots - #24215

Merged
jonpryor merged 4 commits into
feature/breakingchangesfrom
dev/jonpryor/jonp-do-not-trim-RuntimeTests
Sep 1, 2026
Merged

jonpryor merged 4 commits into
feature/breakingchangesfrom
dev/jonpryor/jonp-do-not-trim-RuntimeTests

Conversation

@jonpryor

Copy link
Copy Markdown
Contributor

Fixes: #24208

Issue #24208 notes that the
Tests - Android+NativeAOT Skia > Runtime Tests * jobs are all failing, with an apparent on-device crash:

--------- 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)

The crash appears to be a red herring; it happens, but it's not actually important.

There are two important bits:

  1. "Process 4678 exited cleanly (0)"
  2. The test results file exists but does not contain results.

Important background on (1) is App.HandleRuntimeTests(), which contains:

await SampleControl.Presentation.SampleChooserViewModel.Instance.RunRuntimeTests(
  CancellationToken.None,
  runtimeTestResultFilePath,
  () => System.Environment.Exit(0));

In particular, note the 4th line: when RunRuntimeTests() finishes, Environment.Exit(0) is invoked. This exits the process with exit code 0, which is the cause for Process 4678 exited cleanly (0).

If we look at a runner test execution log file, e.g. from Tests - Android+NativeAOT Skia > Runtime Tests 0 > Run Android+NativeAOT Skia Tests, what appears to be happening is:

  1. The tests are started:

    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-20260826120957.xml
    
  2. On-device, the test runner runs, and successfully creates TestResult-20260826120957.xml.

    When RunRuntimeTests() finishes, it exits.

  3. The test runner grabs the test results file:

    adb pull /storage/emulated/0/Android/data/uno.platform.samplesapp.skia.nativeaot/files/TestResult-20260826120957.xml TestResult-20260826120957.xml
    

    This is successful; the file exists.

  4. TestResult-20260826120957.xml is processed to determine if any tests failed:

    pushd src/Uno.NUnitTransformTool
    

    dotnet run fail-empty ../../TestResult-20260826120957.xml

  5. Uno.NUnitTransformTool is not happy, as no tests are present:

    The test results file /agent/_work/1/s/build/TestResult-20260826120957.xml does not contain any results
    

The TestResults*.xml file exists, which is why (3) succeeds. The process exited cleanly.
The FORTIFY: pthread_mutex_lock called on a destroyed mutex message looks important -- it would be an explanation for the overall failure of the job -- but isn't important, because the part we actually care about -- the creation of TestResult-20260826120957.xml -- was successful. The crash didn't hinder that.

The real question is this: why isn't Uno.NUnitTransformTool happy? Why doesn't TestResults*.xml contain any results?

The partial answer is Native AOT trimming: RunRuntimeTests() executes types that have a [TestClass] attribute, but the app contains no types with [TestClass]. (Verified via printf debugging; see comments on #24208).

As the test runner is driven by Reflection, looking for types with [TestClass] -- types which will not be statically referenced by anything else -- then in order for the types to remain after linking, they must be considered roots.

Fix this by adding a @(TrimmerRootAssembly) entry for Uno.UI.RuntimeTests. This causes Uno.UI.RuntimeTests.dll to be treated as a "root assembly," preserving all types and members within that assembly. This in turn allows [TestClass]-attribute types to be found at runtime, which in turn means TestResults*.xml is no longer empty; it contains unit test run information!

(Obvious followup question: why did this start mattering with .NET 11 Preview 7? @jonpryor doesn't have a theory for why this previously worked with .NET 11 Preview 6 and earlier…)

GitHub Issue: closes #24208

PR Type:

🏗️ Build or CI related changes

What changed? 🚀

PR Checklist ✅

@github-actions github-actions Bot added the area/automation Categorizes an issue or PR as relevant to project automation label Aug 26, 2026
@github-actions github-actions Bot added the area/build Categorizes an issue or PR as relevant to build infrastructure label Aug 26, 2026
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

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

@unodevops

Copy link
Copy Markdown
Contributor

@jonpryor
jonpryor force-pushed the dev/jonpryor/jonp-do-not-trim-RuntimeTests branch from a150533 to fa2c98f Compare August 27, 2026 10:51
@unodevops

Copy link
Copy Markdown
Contributor

@jonpryor

Copy link
Copy Markdown
Contributor Author

One of the unit test failures is in When_WebMessageReceived():

Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException: Timed out waiting for condition to be met. When_WebMessageReceived():476
at Private.Infrastructure.TestServices.WindowHelper.<WaitFor>d__41.MoveNext()
--- End of stack trace from previous location ---
at Uno.UI.RuntimeTests.Tests.Microsoft_UI_Xaml_Controls.Given_WebView2.<When_WebMessageReceived>d__10.MoveNext()
--- End of stack trace from previous location ---
at Uno.UI.Samples.Tests.UnitTestsControl.<>c__DisplayClass74_2.<<ExecuteTestsForInstance>g__InvokeTestMethod|5>d.MoveNext()

This is caused by a regression in dotnet/android; see: dotnet/android#12542

@jonpryor

Copy link
Copy Markdown
Contributor Author

On Discord, Peppers mentioned a possible workaround for dotnet/android#12542: setting $(_AndroidTypeMapImplementation)=llvm-ir.

Unfortunately, when I try that locally:

diff --git a/src/Uno.CrossTargetting.targets b/src/Uno.CrossTargetting.targets
index 925eabe92b..ec17ae78ff 100644
--- a/src/Uno.CrossTargetting.targets
+++ b/src/Uno.CrossTargetting.targets
@@ -104,6 +104,7 @@
 	  -->
 	<PropertyGroup Condition=" $(IsAndroid) And '$(BundledNETCoreAppPackageVersion)' == '11.0.0-preview.7.26381.103' ">
 		<MicrosoftNETCoreAppRefPackageVersion>11.0.0-preview.7.26381.103</MicrosoftNETCoreAppRefPackageVersion>
+		<_AndroidTypeMapImplementation>llvm-ir</_AndroidTypeMapImplementation>
 	</PropertyGroup>
 
 	<PropertyGroup Condition=" '$(TargetFramework)' != 'uap10.0.19041' and $(TargetFramework.EndsWith('-windows10.0.19041.0')) != 'true' and '$(TargetPlatformIdentifier)' != 'UAP'">

SamplesApp hangs during startup:

E JavaInteropRuntime: JavaInteropRuntime.init: error: System.NotSupportedException: Internal error: unknown runtime not supported
E JavaInteropRuntime:    at Android.Runtime.JNIEnv.TypemapManagedToJava(Type)
E JavaInteropRuntime:    at Android.Runtime.AndroidTypeManager.GetSimpleReference(Type)
E JavaInteropRuntime:    at Java.Interop.JniRuntime.ReflectionJniTypeManager.GetTypeSignatureCore(Type)
E JavaInteropRuntime:    at Java.Interop.JniRuntime.ReflectionJniValueManager.CreatePeer(JniObjectReference&, JniObjectReferenceOptions, Type)
E JavaInteropRuntime:    at Java.Interop.JniRuntime.JniValueManager.GetPeer(JniObjectReference, Type)
E JavaInteropRuntime:    at Java.Lang.Object.GetObject(IntPtr, JniHandleOwnership, Type)
E JavaInteropRuntime:    at Java.Lang.Object._GetObject[T](IntPtr, JniHandleOwnership)
E JavaInteropRuntime:    at Microsoft.Android.Runtime.JavaInteropRuntime.init(IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr)

At present, the suggested workaround doesn't appear to be viable.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 230688 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 225

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • CalendarView_Theming.png-dark
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • ContentControl_Inheritance.png
    • Focus_FocusVisual_Properties.png-dark
    • ContextRequested.png-dark
    • Examples.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ImageBrush_Stretch.png
    • Buttons.png
    • DropDownButtonPage.png-dark
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • Attributed_text_FontSize_Changing.png
  • skia-windows-screenshots: 225 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Contacts_Pick.png-dark
    • Contacts_Pick.png
    • ContentPresenter_Template.png-dark
    • ContentPresenter_Template.png
    • DataTransferManager.png-dark
    • DataTransferManager.png
    • FocusManagerTest.png-dark
    • FocusManagerTest.png
    • ImageSourceUrlMsAppDataScheme.png-dark
    • ImageSourceUrlMsAppDataScheme.png
    • ChatBox.png-dark
    • ChatBox.png
    • Focus_FocusVisual_Properties.png-dark
    • Hyperlink_Button.png-dark
    • Hyperlink_Button.png
    • Hyperlink_CanExecute_False.png-dark
    • Hyperlink_CanExecute_False.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • Gamepad_CurrentReading.png-dark

@unodevops

Copy link
Copy Markdown
Contributor

@jonpryor
jonpryor force-pushed the dev/jonpryor/jonp-do-not-trim-RuntimeTests branch from 7227c51 to 964da95 Compare August 28, 2026 21:32
@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 230899 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 237

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ContentControl_Inheritance.png
    • Attributed_text_FontSize_Changing.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png
    • CalendarView_Theming.png-dark
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • ContextRequested.png-dark
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • DropDownButtonPage.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • Image_Margin_Large.png
    • DynamicFont.png
  • skia-windows-screenshots: 237 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Basics Pivot Test.png
    • ClipboardTests.png-dark
    • DoubleImageBrushInList.png-dark
    • Focus_FocusState.png-dark
    • Focus_FocusState.png
    • Hyperlink_Button.png-dark
    • Hyperlink_Button.png
    • ImageSourceUrlMsAppDataScheme.png-dark
    • Hyperlink_CanExecute_False.png-dark
    • ImageSourceUrlMsAppDataScheme.png
    • Hyperlink_CanExecute_False.png
    • Hyperlink_Disabled.png-dark
    • Hyperlink_Disabled.png
    • Basics Pivot Test.png-dark
    • BitmapImage_vs_SvgImageSource.png-dark
    • BitmapImage_vs_SvgImageSource.png
    • Buttons.png-dark
    • Buttons.png
    • Grid_in_Canvas.png-dark
    • Grid_in_Canvas.png

Fixes: #24208

Issue #24208 notes that the
**Tests - Android+NativeAOT Skia > Runtime Tests \*** jobs are all
failing, with an apparent on-device *crash*:

	--------- 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)

The crash appears to be a red herring; it happens, but it's not
actually important.

There are two important bits:

 1. "Process 4678 exited cleanly (0)"
 2. The test results file *exists* but *does not contain results*.

Important background on (1) is [`App.HandleRuntimeTests()`][0],
which contains:

	await SampleControl.Presentation.SampleChooserViewModel.Instance.RunRuntimeTests(
	  CancellationToken.None,
	  runtimeTestResultFilePath,
	  () => System.Environment.Exit(0));

In particular, note the 4th line: when `RunRuntimeTests()` finishes,
`Environment.Exit(0)` is invoked.  This exits the process with exit
code 0, which is the cause for `Process 4678 exited cleanly (0)`.

If we look at a *runner* test execution log file, e.g. from
**Tests - Android+NativeAOT Skia > Runtime Tests 0 > Run Android+NativeAOT Skia Tests**,
what appears to be happening is:

 1. The tests are started:

        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-20260826120957.xml

 2. On-device, the test runner runs, and successfully creates
    `TestResult-20260826120957.xml`.

    When `RunRuntimeTests()` finishes, it exits.

 3. The test runner grabs the test results file:

        adb pull /storage/emulated/0/Android/data/uno.platform.samplesapp.skia.nativeaot/files/TestResult-20260826120957.xml TestResult-20260826120957.xml

    This is successful; the file exists.

 4. `TestResult-20260826120957.xml` is processed to determine if any
    tests failed:

        pushd src/Uno.NUnitTransformTool
	dotnet run fail-empty ../../TestResult-20260826120957.xml

 5. `Uno.NUnitTransformTool` is not happy, as no tests are present:

        The test results file /agent/_work/1/s/build/TestResult-20260826120957.xml does not contain any results

The `TestResults*.xml` file *exists*, which is why (3) succeeds.
The process exited cleanly.
The `FORTIFY: pthread_mutex_lock called on a destroyed mutex` message
*looks* important -- it would be *an* explanation for the overall
failure of the job -- but *isn't* important, because the part we
actually care about -- the creation of `TestResult-20260826120957.xml`
-- was successful.  The crash didn't hinder that.

The *real* question is this: why isn't `Uno.NUnitTransformTool` happy?
Why doesn't `TestResults*.xml` contain any results?

The partial answer is Native AOT trimming: `RunRuntimeTests()` executes
types that have a `[TestClass]` attribute, but the app contains *no*
types with `[TestClass]`.  (Verified via printf debugging; see comments
on #24208).

As the test runner is driven by Reflection, looking for types with
`[TestClass]` -- types which will *not* be statically referenced by
anything else -- then in order for the types to remain after linking,
they must be considered roots.

Fix this by adding a `@(TrimmerRootAssembly)` entry for
`Uno.UI.RuntimeTests`.  This causes `Uno.UI.RuntimeTests.dll` to be
treated as a "root assembly," preserving all types and members within
that assembly.  This in turn allows `[TestClass]`-attribute types to
be found at runtime, which in turn means `TestResults*.xml` is no
longer empty; it contains unit test run information!

(Obvious followup question: why did this start mattering with
.NET 11 Preview 7?  @jonpryor doesn't have a theory for why this
previously worked with .NET 11 Preview 6 and earlier…)

[0]: https://github.com/unoplatform/uno/blob/ea3418a53ca8a6bae5b8f8bed4075a775746abff/src/SamplesApp/SamplesApp.Shared/App.Tests.cs#L91-L94
@jonpryor
jonpryor force-pushed the dev/jonpryor/jonp-do-not-trim-RuntimeTests branch from 964da95 to 878906c Compare August 31, 2026 13:50
@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 231171 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 218

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • CalendarView_Theming.png-dark
    • DropDownButtonPage.png-dark
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • Focus_FocusVisual_Properties.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • ContextRequested.png-dark
    • DynamicFont.png
    • Examples.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • Buttons.png
    • ContentControl_Inheritance.png
    • Gamepad_CurrentReading.png-dark
    • Attributed_text_FontSize_Changing.png
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
  • skia-windows-screenshots: 218 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Basics Pivot Test.png
    • ChatBox.png-dark
    • ChatBox.png
    • Clipping652.png-dark
    • Clipping652.png
    • DisplayInformation.png-dark
    • Dopes.png-dark
    • EllipseAlignment2542_2547.png-dark
    • Examples.png
    • EllipseAlignment2542_2547.png
    • Focus_FocusState.png-dark
    • Focus_FocusState.png
    • Hyperlink_Disabled.png-dark
    • Hyperlink_Disabled.png
    • ImageAlignment2541.png-dark
    • ImageAlignment2541.png
    • BitmapImage_vs_SvgImageSource.png
    • DynamicFont.png
    • HyperlinkButton_IsEnabled_Automated.png-dark
    • HyperlinkButton_IsEnabled_Automated.png

Many tests on Android+NativeAOT were failing with:

	Microsoft.UI.Xaml.Markup.XamlParseException: Failed to parse member
	(Unable to find type {using:Uno.UI.Markup}FromJson. If the linker is enabled, more info at https://aka.platform.uno/linker-configuration)

Indeed, `Uno.UI.Markup.FromJsonExtension` was trimmed away from
`Uno.UI.Extras.dll`.

Add `Uno.UI.Extras` to `@(TrimmerRootAssembly)`, which will hopefully
fix the above error.
Context: dotnet/android#12542
Context: #24270
Context: #24271

Ignore the following test, which is a regression in dotnet/android;
see also dotnet/android#12542:

  * Given_WebView2.When_WebMessageReceived()

        Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException: Timed out waiting for condition to be met. When_WebMessageReceived():476
           at Private.Infrastructure.TestServices.WindowHelper.<WaitFor>d__41.MoveNext()
           --- End of stack trace from previous location ---
           at Uno.UI.RuntimeTests.Tests.Microsoft_UI_Xaml_Controls.Given_WebView2.<When_WebMessageReceived>d__10.MoveNext()
           --- End of stack trace from previous location ---
           at Uno.UI.Samples.Tests.UnitTestsControl.<>c__DisplayClass74_2.<<ExecuteTestsForInstance>g__InvokeTestMethod|5>d.MoveNext()

  * Given_WebView2.When_WebMessageReceived_After_RemoveAdd():
    Hangs on CI, as the test didn't have a `[Timeout]`.

Ignore the following test, which is probably some floating-point
related issue that needs more investigation; see also #24270:

  * Given_AnimatedVisualPlayer.When_Reverse_Negative_PlaybackRate_Animation_Completes_At_One():

        Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException: Assert.AreEqual failed. Expected a difference no greater than <0.02> between expected value <0.2223382443189621> and actual value <0.25255224108695984>. 'expected' expression: 'frozenProgress', 'actual' expression: 'GetPlayerProgress(player)'. A zero playback rate should freeze the current progress.
           at Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ThrowAssertAreEqualFailed[T](T expected, T actual, T delta, String userMessage) in //src/TestFramework/TestFramework/Assertions/Assert.AreEqual.cs:line 679
           at Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(Double expected, Double actual, Double delta, String message, String expectedExpression, String actualExpression) in //src/TestFramework/TestFramework/Assertions/Assert.AreEqual.cs:line 1149
           at Uno.UI.RuntimeTests.Tests.Microsoft_UI_Xaml_Controls.Given_AnimatedVisualPlayer.When_PlaybackRate_Zero_Keeps_Progress_Stable()
           at Uno.UI.Samples.Tests.UnitTestsControl.<>c__DisplayClass74_2.<<ExecuteTestsForInstance>g__InvokeTestMethod|5>d.MoveNext()

Ignore the following tests, which are failing for reasons @jonpryor
doesn't understand; see also #24271:

  * Given_BitmapSource.When_MsAppData()

        System.TimeoutException: The operation has timed out.
           at Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Media_Imaging.Given_BitmapSource.<When_MsAppData>d__3.MoveNext()
           --- End of stack trace from previous location ---
           at Uno.UI.Samples.Tests.UnitTestsControl.<>c__DisplayClass74_2.<<ExecuteTestsForInstance>g__InvokeTestMethod|5>d.MoveNext()

  * Given_WebView2.When_LocalFolder_File()

        Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException: Timed out waiting for condition to be met. When_LocalFolder_File():343
           at Private.Infrastructure.TestServices.WindowHelper.<WaitFor>d__41.MoveNext()
           --- End of stack trace from previous location ---
           at Uno.UI.RuntimeTests.Tests.Microsoft_UI_Xaml_Controls.Given_WebView2.<<When_LocalFolder_File>g__Do|7_0>d.MoveNext()
           --- End of stack trace from previous location ---
           at Uno.UI.RuntimeTests.Helpers.TestHelper.<RetryAssert>d__1.MoveNext()
           --- End of stack trace from previous location ---
           at Uno.UI.RuntimeTests.Helpers.TestHelper.<RetryAssert>d__1.MoveNext()
           --- End of stack trace from previous location ---
           at Uno.UI.RuntimeTests.Tests.Microsoft_UI_Xaml_Controls.Given_WebView2.<When_LocalFolder_File>d__7.MoveNext()
           --- End of stack trace from previous location ---
           at Uno.UI.Samples.Tests.UnitTestsControl.<>c__DisplayClass74_2.<<ExecuteTestsForInstance>g__InvokeTestMethod|5>d.MoveNext()
Context: https://dev.azure.com/uno-platform/1dd81cbd-cb35-41de-a570-b0df3571a196/_apis/build/builds/230688/logs/833

The **Tests - Android+NativeAOT Skia > Runtime Tests 1** job is
timing out.  While investigating this, I noticed a few oddities in
the log output.

For starters, the END_TIME value is stupidly high, and is never
reached:

	2026-08-28T01:20:09.4548273Z + UITEST_TEST_TIMEOUT_AS_MINUTES=2600
	2026-08-28T01:20:09.4548976Z + TIMEOUT=156000
	2026-08-28T01:20:09.4549296Z + END_TIME=156193
	…
	2026-08-28T02:01:06.8736188Z + [[ ! -n '' ]]
	2026-08-28T02:01:06.8736538Z + [[ 2650 -lt 156193 ]]
	2026-08-28T02:01:06.8736787Z + sleep 15
	2026-08-28T02:01:08.7396984Z ##[error]The Operation will be canceled. The next steps may not contain expected logs.
	2026-08-28T02:01:18.7490909Z ##[error]The operation was canceled.
	2026-08-28T02:01:18.7493689Z ##[section]Finishing: Run Android+NativeAOT Skia Tests

Notice that END_TIME=156193, but we only ever hit 2650!

The "problem" is a "semantic mismatch" between
`.azure-devops=tests-android-nativeaot-skia.yml`, which specifies a
"units" of seconds:

	UITEST_TEST_TIMEOUT: '2600s'

and `android-run-skia-runtime-tests.sh`, which trims off the unit
suffix, and assumes the resulting 2600 is in *minutes*, which it then
multiplies by 60 to get 156000 *seconds*.

Update `android-run-skia-runtime-tests.sh` to check the last character
of `$UI_TEST_TIMEOUT`, and when `s` ("seconds"), use the value as-is.

The next observed oddity was around the `while` loop:

	while [[ ! $($ANDROID_HOME/platform-tools/adb shell test -e "$UITEST_RUNTIME_AUTOSTART_RESULT_DEVICE_PATH" > /dev/null) && $SECONDS -lt $END_TIME ]]; do

The log file would contain:

	2026-08-28T01:20:09.4553055Z ++ /agent/_work/1/s/build/android-sdk/platform-tools/adb shell test -e /storage/emulated/0/Android/data/uno.platform.samplesapp.skia.nativeaot/files/TestResult-20260828012008.xml
	2026-08-28T01:20:09.4684328Z + [[ ! -n '' ]]
	2026-08-28T01:20:09.4684990Z + [[ 193 -lt 156193 ]]

What's up with `+ [[ ! -n '' ]]`?

Because of the `$($ANDROID_HOME/…/adb shell test -e …)`, the `while`
loop was implicitly capturing the output of `adb shell test -e`,
and comparing that to a non-empty string.  (`test -n` is true when the
value length is non-zero.)

The problem is, `adb shell test -e` *never* prints anything:

	% adb shell test -e /storage/emulated/0/Android/data/uno.platform.samplesapp.skia.nativeaot/files/TestResult-4.xml
	% echo $?
	0
	% adb shell ls -l /storage/emulated/0/Android/data/uno.platform.samplesapp.skia.nativeaot/files/TestResult-4.xml
	-rw-rw---- 1 u0_a197 ext_data_rw 1399428 2026-08-28 13:28 /storage/emulated/0/Android/data/uno.platform.samplesapp.skia.nativeaot/files/TestResult-4.xml

Thus, checking the *output* of `adb shell test -e` for "truthiness"
is doomed to fail.

Split this up so that the test can actually work:

	while [[ $SECONDS -lt $END_TIME ]]; do
	  if $ANDROID_HOME/platform-tools/adb shell test -e "$UITEST_RUNTIME_AUTOSTART_RESULT_DEVICE_PATH" ; then
	    break;
	  fi
	done

This still doesn't fix the apparent hang, but it does reduce the
headscratching involved when reading the log files…
@jonpryor
jonpryor force-pushed the dev/jonpryor/jonp-do-not-trim-RuntimeTests branch from 878906c to b39b85c Compare September 1, 2026 02:34
@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 231279 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 221

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ContextRequested.png-dark
    • Examples.png
    • Attributed_text_FontSize_Changing.png
    • ContentControl_Inheritance.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • CalendarView_Theming.png-dark
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • Focus_FocusVisual_Properties.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • DropDownButtonPage.png-dark
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • DynamicFont.png
    • Buttons.png
  • skia-windows-screenshots: 221 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Battery.png-dark
    • ButtonClippingTestsControl.png
    • BitmapImage_vs_SvgImageSource.png-dark
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • Clipping652.png-dark
    • Clipping652.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • Contacts_Pick.png-dark
    • Contacts_Pick.png
    • DisplayInformation.png-dark
    • Dopes.png-dark
    • Examples.png
    • EllipsemaskingEllipseGrid.png-dark
    • ExpanderColorValidationPage.png-dark
    • GeolocatorPositionChanged.png-dark
    • GeolocatorPositionChanged.png
    • Gamepad_CurrentReading.png-dark

@jonpryor
jonpryor marked this pull request as ready for review September 1, 2026 11:16
@jonpryor
jonpryor requested review from MartinZikmund and a lite review from Copilot September 1, 2026 11:16

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

This PR addresses Android+NativeAOT Skia runtime-test execution issues by ensuring the Uno.UI.RuntimeTests assembly is preserved during trimming (so [TestClass] discovery via reflection still works), and by adjusting a few known-problematic runtime tests / runner behavior for NativeAOT scenarios.

Changes:

  • Mark Uno.UI.RuntimeTests (and Uno.UI.Extras) as trimmer root assemblies when publishing NativeAOT SamplesApp.
  • Exclude specific runtime tests on SkiaAndroid under RUNTIME_NATIVE_AOT where they hang or behave differently.
  • Fix Android runtime-test runner timeout handling (supports ...s seconds values) and improve result-file wait loop behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media_Imaging/Given_BitmapSource.cs Excludes a hanging test on Android+NativeAOT by extending platform exclusion logic.
src/Uno.UI.RuntimeTests/Tests/Microsoft_UI_Xaml_Controls/Given_WebView2.cs Adds Android+NativeAOT exclusions for WebView2 tests that hang/fail under AOT trimming/runtime constraints.
src/Uno.UI.RuntimeTests/Tests/Microsoft_UI_Xaml_Controls/Given_AnimatedVisualPlayer.cs Skips a floating-point sensitive test on Android+NativeAOT.
src/SamplesApp/SamplesApp/SamplesApp.csproj Adds @(TrimmerRootAssembly) entries so runtime test assemblies aren’t trimmed away during NativeAOT publish.
build/test-scripts/android-run-skia-runtime-tests.sh Updates timeout parsing to correctly handle second-based timeouts and improves the poll loop for results.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@unodevops

Copy link
Copy Markdown
Contributor

@jonpryor
jonpryor enabled auto-merge September 1, 2026 13:29
@nventive-devops

Copy link
Copy Markdown
Contributor

The build 231326 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 229

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ContentControl_Inheritance.png
    • Buttons.png
    • DropDownButtonPage.png-dark
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • Examples.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • ContextRequested.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • Attributed_text_FontSize_Changing.png
    • DynamicFont.png
  • skia-windows-screenshots: 229 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Buttons.png-dark
    • Buttons.png
    • Examples.png
    • GeolocatorPositionChanged.png-dark
    • GeolocatorPositionChanged.png
    • ElementLevelTheme.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ClipboardTests.png-dark
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • Focus_FocusVisual_Properties.png-dark
    • BitmapImage_vs_SvgImageSource.png
    • EmailManagerTests.png-dark
    • EmailManagerTests.png
    • GetFocus.png-dark

@mergify

mergify Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@jonpryor
jonpryor merged commit f8a75d5 into feature/breakingchanges Sep 1, 2026
55 checks passed
@jonpryor
jonpryor deleted the dev/jonpryor/jonp-do-not-trim-RuntimeTests branch September 1, 2026 14:16
MartinZikmund added a commit that referenced this pull request Sep 1, 2026
The ms-appdata load intermittently never completes on the Android Skia
runtime-test host: the test starts, then 30 seconds of total silence
follow with no ImageOpened, no ImageFailed and no exception, until the
inner WaitAsync trips. That is the same signature already tracked for
the Linux hosts in #23967, which the existing exclusion covers.

#24215 already excluded SkiaAndroid for this test, but gated behind
RUNTIME_NATIVE_AOT while investigating #24271. The hang is not specific
to NativeAOT -- it reproduces on the plain Android Skia leg -- so the
exclusion is un-gated here rather than duplicated, and #24271 is kept
in the comment.

The test only began running on Android at all once #24003 aligned shard
0's UITEST_RUNTIME_TEST_GROUP_COUNT (4 -> 5, 005db43): selection is
a stable hash modulo that count, so before the fix When_MsAppData was
one of the 14.7% of methods no shard selected. It is not a new failure,
just a newly executed one.

Since that merge it has failed on three unrelated PR builds within
hours of each other -- 231145 (#24186), 231142 (#24194) and 231152
(#19083) -- where the isolated retry only sometimes recovers, so it
reddens whichever PR happens to be unlucky. master still carries the
old count of 4 and therefore never runs it.

Scoped to this test alone: When_MsAppData_StreamDisposed_FileNotLocked
and When_Exif_Rotated_MsAppData use the same ms-appdata path and run
green on Android in every post-fix build checked, so they keep running.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015Lk1RUZfAj6A7xGWzYaoBw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation area/build Categorizes an issue or PR as relevant to build infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants