Skip to content

fix(samplesapp): Root the head assembly for android trimming - #24353

Merged
agneszitte merged 1 commit into
feature/breakingchangesfrom
dev/mazi/nativeaotadjust
Sep 2, 2026
Merged

agneszitte merged 1 commit into
feature/breakingchangesfrom
dev/mazi/nativeaotadjust

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: closes #24352

PR Type:

🐞 Bugfix

What changed? 🚀

Every Android + NativeAOT runtime-test group has been aborting since the SamplesApp head consolidation (#24046) — two NUnit results per group instead of ~1500, the second being the harness' synthetic Runtime exception:

System.ArgumentNullException: Value cannot be null. (Parameter 'xamlRoot')
   at Microsoft.UI.Xaml.Media.VisualTreeHelper.GetOpenPopupsForXamlRoot(XamlRoot xamlRoot)
   at Uno.UI.Samples.Tests.UnitTestsControl.CloseRemainingPopups()

UnitTestsControl.OnLoaded is what publishes TestServices.WindowHelper.XamlRoot, and it never runs — the control never reaches the live visual tree — so the first test's general cleanup throws and the run is abandoned.

Root cause. The removed SamplesApp.Skia.netcoremobile head rooted the samples assembly with TrimmerRootAssembly RootMode="All" on every one of its targets. The consolidated head restored that only for iOS/tvOS (0cf84f8). Android + NativeAOT publishes with PublishTrimmed=true / TrimMode=full and has no managed entry point to root the app assembly from, so the samples and the runtime-test harness — both reached only by reflection — get trimmed out of the head. Tests - Android Skia (Mono, same head, same commit) passes with 1242–1475 results in the same CI run, which is what isolates it to the trimmed publish.

Confirmed by diffing the TrimmerRootAssembly items in the two CI build binlogs:

before (0950717) after (6dfcb8f)
Uno.UI.RuntimeTests RootMode=All RootMode=All
Uno.UI.Extras ✔ ✔
samples assembly SamplesApp.Skia RootMode=All missing

The generated Uno.UI.Tasks descriptors are not a substitute: they only preserve properties on [Bindable] types and attached-property accessors.

Fix. Root SamplesApp with RootMode="All" on every Skia TFM, as the old samples-library root was — desktop and wasm don't trim here, so it costs them nothing.

Validated on CI. The Tests - Android+NativeAOT Skia stage is gated on ne(variables['Build.Reason'], 'PullRequest'), which is why no PR ever exercised it and the regression could only appear post-merge. That guard was temporarily dropped on this branch to run the stage against the fix — build 231546, group 0: 1472 results, 0 failed, matching the pre-regression baseline exactly (2 results, 1 failed before the fix). The guard has since been restored, so the stage will not appear on this PR's checks.

PR Checklist ✅

  • 🧪 Added Runtime tests, UI tests, or a manual test sample (for bug fixes / features, if applicable) — the existing Android+NativeAOT runtime-test stage is the test; see the CI validation above.
  • 📚 Docs have been added/updated following the documentation template (for bug fixes / features) — n/a, build configuration only.
  • 🖼️ Validated PR Screenshots Compare Test Run results.
  • ❗ Contains NO breaking changes
  • 👀 Reviewed 2 other open pull requests (optional but appreciated!)

🤖 Generated with Claude Code

https://claude.ai/code/session_01FMa5PnRraRxZNYL61Grv9z

The netcoremobile head rooted the samples assembly with RootMode=All on
every one of its targets, and the consolidated head kept that only for
iOS/tvOS. Android+NativeAOT publishes with PublishTrimmed and
TrimMode=full and has no managed entry point to root the app assembly
from, so the samples and the runtime-test harness — reached only by
reflection — are trimmed out of the head.

The whole Android+NativeAOT runtime-test run then aborts on the first
test's cleanup with `ArgumentNullException (Parameter 'xamlRoot')`:
UnitTestsControl never reaches the live visual tree, so its Loaded
handler never publishes the XamlRoot the harness cleans popups with.

The generated Uno.UI.Tasks descriptors are not a substitute — they only
preserve properties on [Bindable] types and attached-property accessors.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FMa5PnRraRxZNYL61Grv9z
Copilot AI lite review requested due to automatic review settings September 2, 2026 13:17
@github-actions github-actions Bot added area/build Categorizes an issue or PR as relevant to build infrastructure area/automation Categorizes an issue or PR as relevant to project automation labels Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 2m 20s —— View job


Claude's Review

  • Gather context (diff, changed files, AGENTS.md rules)
  • Review SamplesApp.csproj trimmer root change
  • Review CI pipeline guard change (flagged in PR body as temporary/to-revert)
  • Post inline findings
  • Post summary

Verdict: Ship (after the self-flagged temporary CI change is reverted)

Issues found: 1 (informational / merge-blocking checklist item, not a code defect) — see inline comment on .azure-devops-tests-android-nativeaot-skia.yml:14.

What I verified

SamplesApp.csproj — the fix is root-cause, not a guard:

  • _IsUIKit → _IsSkiaTfm correctly widens the TrimmerRootAssembly Include="SamplesApp" RootMode="All" item to every non-Windows TFM (desktop/wasm/android/ios/tvos), which is a strict superset of the old condition — no regression for iOS/tvOS.
  • Confirmed Android already carries the necessary trim-warning suppressions (NoWarn at csproj:302 already includes $(_UnoTrimmingNoWarn) plus AOT-specific IL30xx codes), so rooting the samples assembly there doesn't introduce new release-build warnings.
  • Confirmed desktop (PublishTrimmed=false) and wasm don't actually trim, so the added TrimmerRootAssembly item is inert there as the PR description claims — no build-time cost.
  • Traced the existing Uno.UI.RuntimeTests/Uno.UI.Extras roots (csproj:121-125, scoped to PublishAot == true, unchanged by this diff) and confirmed they're out of scope for this PR — consistent, pre-existing pattern.

CI condition change — traced the pipeline wiring (.azure-devops-tests-skia-stages.yml → -build.yml / -skia.yml) and confirmed the dependent build job has no Build.Reason guard, so flipping only the test job's condition is sufficient to validate the fix on this PR; nothing else needs a matching temporary change. It's correctly self-labeled as temporary in both the code comment and PR description — flagged inline as a reminder since it must be reverted before merge (a forgotten revert here would silently re-enable this expensive stage on every future PR).

No other correctness, style, or test-coverage issues found. Conventional Commit format is correct for both the PR title and the two commits.
· Branch

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.

🟡 Changes recommended

It currently removes the PR guard for an expensive CI stage in a way that would permanently run Android+NativeAOT tests on every PR if merged.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR fixes Android + NativeAOT Skia runtime-test runs aborting after SamplesApp head consolidation by ensuring the SamplesApp head assembly is rooted for trimming, preventing reflection-reached samples/test harness code from being removed during trimmed publish.

Changes:

  • Root SamplesApp with TrimmerRootAssembly RootMode="All" for all Skia TFMs (including Android) to keep reflection-reached test infrastructure intact under full trimming.
  • Temporarily removes the PR-skip condition for the Android+NativeAOT Skia test job to validate this fix in CI (intended to be reverted before merge).
File summaries
File Description
src/SamplesApp/SamplesApp/SamplesApp.csproj Expands the trimmer rooting condition to all Skia TFMs so Android trimmed publishes keep SamplesApp/test harness code.
build/ci/tests/.azure-devops-tests-android-nativeaot-skia.yml Temporarily enables Android+NativeAOT Skia tests on PR builds by removing the PullRequest guard.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

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

@unodevops

Copy link
Copy Markdown
Contributor

@MartinZikmund
MartinZikmund force-pushed the dev/mazi/nativeaotadjust branch from a6720a5 to d207da6 Compare September 2, 2026 13:52
@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 1m 48s —— View job


Claude's Review (updated after synchronize)

  • Diff the current PR state against origin/feature/breakingchanges
  • Re-verify the SamplesApp.csproj trimmer-root change
  • Confirm the temporary CI guard removal was reverted
  • Post summary

Verdict: Ship ✅

Issues found: 0. The merge-blocking item from the prior review round is resolved.

What changed since the last review pass

The PR now contains only the src/SamplesApp/SamplesApp/SamplesApp.csproj change (1 file, +11/-5, single commit d207da6). The temporary removal of the ne(variables['Build.Reason'], 'PullRequest') guard on Android_NativeAOT_Tests in .azure-devops-tests-android-nativeaot-skia.yml — flagged as merge-blocking by the previous review and by both bots — is no longer present in the diff; the file is now byte-identical to base. So the temporary-CI-validation step served its purpose and was cleanly removed, no follow-up revert needed.

Re-confirmed on the csproj change

  • _IsUIKit → _IsSkiaTfm (line 372) is still a strict superset of the old condition (_IsSkiaTfm = everything except windows, defined at line 64), so iOS/tvOS behavior is unchanged and android/desktop/browserwasm now also get TrimmerRootAssembly Include="SamplesApp" RootMode="All".
  • Verified browserwasm explicitly sets PublishTrimmed=false (line 230) and desktop doesn't trim either, so the added root is inert there — no build-time or size cost on those heads, matching the PR's claim.
  • Android's NoWarn (line 302) already carries $(_UnoTrimmingNoWarn) plus the AOT-specific IL30xx codes unconditionally (not gated on PublishAot), so rooting the assembly there doesn't introduce new warnings for either the Mono or NativeAOT Android publish.
  • The updated doc comment (lines 350–365) accurately describes the root cause (no managed entry point under TrimMode=full NativeAOT) and correctly scopes the fix — this reads as a root-cause fix, not a guard.
  • Conventional Commit format is correct for the PR title and the single remaining commit.

No further action needed from a code-review standpoint.
· Branch

@agneszitte
agneszitte merged commit 3ab2933 into feature/breakingchanges Sep 2, 2026
13 of 16 checks passed
@agneszitte
agneszitte deleted the dev/mazi/nativeaotadjust branch September 2, 2026 13:54
@github-actions github-actions Bot mentioned this pull request Sep 2, 2026
4 of 5 tasks
@unodevops

Copy link
Copy Markdown
Contributor

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.

4 participants