Repository navigation
refactor(android): Make Skia-Android multi-window-ready - #24042
Conversation
|
Claude finished @MartinZikmund's task in 9m 24s —— View job Review complete
Overall verdict:
|
|
Claude finished @MartinZikmund's task in 8m 3s —— View job Re-review: 4 new commits since first pass
What the 4 new commits addressed
The The new Remaining issues (2 inline comments posted)HIGH — Vulkan LOW — Note on
|
9dc62c3 to
d12374d
Compare
|
Claude finished @MartinZikmund's task in 3m 8s —— View job Re-review pass 3 (commits
|
| Commit | Topic | Status |
|---|---|---|
2542a0c9 |
Re-arm skipped frames, TeardownRenderer, unsubscribe singletons, IsChangingConfigurations gate |
✅ Sound — no new issues |
080f5262 |
Type ContextHelper.Current as Android.Content.Context?; 13 call sites updated with explicit ! |
✅ Fixed (MEDIUM from prior passes) |
d12374d1 |
Docs: migration guide additions, PackageDiffIgnore.xml, Given_AndroidSkiaXamlRootHost runtime test, spec corrections |
✅ Sound |
The new Given_AndroidSkiaXamlRootHost runtime test is well-formed: [PlatformCondition(ConditionMode.Include, RuntimeTestPlatforms.SkiaAndroid)] correctly gates it to the Android Skia CI lane; the three synchronous void methods don't await anything so the void return type is correct; reflection-based access avoids a compile-time dependency on the Android assembly.
Verdict: fix-first — 2 inline findings still open
The same two issues from the first two review passes remain unaddressed:
HIGH — UnoSKVulkanView.cs:225 — _activity.NativeLayerHost!.Path = nativeClipPath still uses the null-forgiving !. The canvas view received this fix in commit a2e944b2; the Vulkan view did not. See inline comment.
LOW — NativeWindowWrapper.Android.cs:233 — windowMetrics.Bounds is called unconditionally when windowMetrics can be null. See inline comment.
Neither the re-arm commit (2542a0c9) nor either of the two subsequent commits (080f5262, d12374d1) touched these lines. Both carry a one-line suggestion in their inline comments.
|
Claude finished @MartinZikmund's task in 1m 34s —— View job Re-review pass 4 — final
What the 2 new commits addressed
Verdict:
|
1592597 to
0c0e514
Compare
|
Claude finished @MartinZikmund's task in 3m 15s —— View job Re-review pass 5 — post-rebase check
What triggered this passThe branch was rebased after the pass 4 Verification of pass-4 fixesBoth pass-4 blockers are confirmed present in the rebased commits:
The Verdict:
|
0c0e514 to
10cb8c2
Compare
|
Claude finished @MartinZikmund's task in 3m 16s —— View job Re-review pass 6 — post-rebase check
What triggered this passThe branch was rebased again (second rebase since the pass 4 Verification of pass-4/pass-5 fixesAll prior blockers confirmed present in the rebased commits:
The pre-existing Verdict:
|
10cb8c2 to
b366505
Compare
|
Claude finished @MartinZikmund's task in 3m 46s —— View job Re-review pass 7 — post-synchronize check
What triggered this passThe branch was rebased again (third rebase since the pass 4 Verification of prior fixesAll prior blockers confirmed present in the rebased commits:
Full diff sweep findingsA fresh pass over all 32 changed files turned up no new issues:
Verdict:
|
b366505 to
4d0334d
Compare
4d0334d to
e8677bb
Compare
|
Claude finished @MartinZikmund's task in 1m 2s —— View job Re-review pass 8 — post-rebase check
What triggered this passThe branch was rebased again since the pass 7 Verification of prior fixesBoth blockers from the earliest review passes remain fixed in the current commits:
The MEDIUM findings from earlier passes ( Full sweep for new issuesSince the diff is unchanged from pass 7's fully-reviewed content, no new inline comments were posted. Nothing new surfaced:
Verdict:
|
e8677bb to
639118d
Compare
The recreation tests reflected on ApplicationActivity.Instance, which the de-singletoning removed, so trimming the Android heads failed (IL2037). Resolve the activity driving the test window through its XamlRoot host instead, and compare the first-frame gate with its int value. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DtsKbXbA642EduoduiNtt4
- ContextHelper.Current's setter is now internal: the value is owned by the activity lifecycle, and an app-assigned value was overwritten anyway. With several activities an outside write would point lookups at the wrong one, and internalizing it after 7.0 would be a binary break. - Remove ApplicationViewHelper.GetBaseActivityEvents() and IBaseActivityEvents: no Skia activity implements the interface, so it always returned null. The docs now point to Application.RegisterActivityLifecycleCallbacks. - Stop pointing ContextHelper.Current users at a XamlRoot lookup that has no public API. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DtsKbXbA642EduoduiNtt4
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GUsTVQvbj18pADVocyZaSj
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GUsTVQvbj18pADVocyZaSj
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GUsTVQvbj18pADVocyZaSj
The r8 pin works around an NPE that R8 9.1.31 hits in release mode while desugaring androidx.core without shrinking. Debug never needed it: the SDK already dexes through R8 with shrinking off. Pinning it there turned shrinking on with no JNI keep rules (AndroidLinkMode=None generates none), which stripped AndroidX and crashed the Debug head on launch. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GUsTVQvbj18pADVocyZaSj
SurfaceDestroyed disposed the renderer, context and native window even when the render thread outlived the join, racing its in-flight frame. Leave them to the process teardown instead, as TeardownRenderer does. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ed8fDt9yDQpZwoTfCyNUhU
The wrapper kept observing the destroyed activity and carried its attach state over, so the pre-draw gate could open before the new activity's content view attached. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ed8fDt9yDQpZwoTfCyNUhU
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ed8fDt9yDQpZwoTfCyNUhU
Both read internal host members through reflection, which NativeAOT trims, so they fail there without a product fault. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ed8fDt9yDQpZwoTfCyNUhU
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018oQnN1QdFYuiZcZUu9BNwA
A render thread that outlived the SurfaceDestroyed join kept reading the view's shared swapchain, renderer and native window fields while the abandon path nulled them and the next surface's thread overwrote them. Each render thread now creates, uses and releases its own resources, so a straggler never sees a successor's objects and frees its own once its frame ends. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014MKMBCoDVcXf5j7uLvSTtL
The registry gains an activity at construction, so a destroyed activity could hand the ambient context to a replacement that had not reached OnCreate yet. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014MKMBCoDVcXf5j7uLvSTtL
ContextHelper.Current is now null once the last activity is destroyed, while the process (and background handlers such as NetworkStatusChanged) can stay alive. System services, package info and the content resolver don't need an activity, so they now come from ApplicationContext. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0169CMCUD6YcRAtuZYm4qJpX
BaseActivity.Current is cleared on OnPause/OnStop, so creating the window after OnLaunched awaited something that paused the activity (e.g. a permission prompt) threw. Fall back to the most recently active live activity, which ContextHelper keeps until it is destroyed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0169CMCUD6YcRAtuZYm4qJpX
The public Activity*Handler delegates only typed IBaseActivityEvents' events. With the interface gone they have no consumer, and removing them later would be its own binary break. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0169CMCUD6YcRAtuZYm4qJpX
ContextHelper.Current is now null by design once the last activity is destroyed, so warning on every read there spammed advice about the MainActivity base class that doesn't apply. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0169CMCUD6YcRAtuZYm4qJpX
A throwing render teardown skipped base.OnDestroy() (SuperNotCalled) and the static unsubscriptions, leaking the activity; on the GL thread it crossed JNI and killed the process with no managed log. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0169CMCUD6YcRAtuZYm4qJpX
OnCreate runs before OnStart builds the per-activity render view, so the "recreated activity reuses the render view" branch can no longer run. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0169CMCUD6YcRAtuZYm4qJpX
The paused case resolves the host activity with BaseActivity.Current cleared, as OnPause leaves it. The input-source test now checks the host hands out its window wrapper's sources; the old same-instance check passed against a process-wide singleton too. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0169CMCUD6YcRAtuZYm4qJpX
Asserts the re-created activity takes the window, reopens the first-frame gate (the black-app regression only happened on this path) and becomes ContextHelper.Current. Also keeps XamlRootMap.GetHostForRoot for the reflective lookups under trimming. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0169CMCUD6YcRAtuZYm4qJpX
Repoints the TODO to #8341, aligns Current's contract with the migration guide and records the emulator validation and the current SamplesApp head. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0169CMCUD6YcRAtuZYm4qJpX
|
Claude finished @MartinZikmund's task in 17s —— View job Re-review: post-synchronize check
Verdict: The earlier passes covered the branch up to
I did not read the other new commits in detail: Still open (tracked in their own threads):
|
|
The build 238155 found UI Test snapshots differences: Details
|
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-24042/docs/index.html |
GitHub Issue: #8341, closes #24943
PR Type:
What changed? 🚀
Skia-on-Android baked "one window" into three process-wide static anchors. This PR
de-singletons them so Android converges onto the same per-window ownership pattern the
Skia desktop runtimes (Win32/X11/macOS) and the Apple UIKit runtime already use — making
the architecture multi-window-ready.
SupportsMultipleWindowsdeliberately staysfalse. The definition of done here isper-window instances everywhere, and zero single-window regressions — not a live second window.
The three anchors that went away
NativeWindowWrapper.Instance— was a process-wideLazy<>singleton returned byAndroidSkiaWindowFactory.CreateWindowfor every window. It is now an instance bound toits window, tracking the activity currently driving it (
CurrentActivity), since the managedWindowoutlives individual activities across re-creation.ApplicationActivity.Instance+ thestaticrender stack (render view, native-layer host,root layout) — now per-activity instance state. A new activity rebuilds its surface and
re-attaches on re-creation.
ContextHelper.Current— split into an explicit app-globalApplicationContextand anactivity-scoped
Currentthat tracks the foreground activity via the existingBaseActivityregistry, instead of today's sticky "last-ever-set" behaviour.
Supporting changes
AndroidSkiaXamlRootHostis per-window: it resolves its ownRootElementand drivingactivity, and registers in
XamlRootMapso consumers (native element hosting, TextBoxnotifications, IME) resolve the owning activity from a
XamlRootrather than a global.registered via
ApiExtensibility.Register<IXamlRootHost>(…), matching the Win32 runtime. Eachwindow's
InputManagerresolves its own sources through its host.Closingis raised only when the activity isactually finishing, so a configuration-change re-creation no longer spuriously closes the
surviving window.
UnoSKCanvasViewnow skips a frame when the window'sroot/composition target isn't ready (e.g. mid-teardown during activity re-creation), matching
the Vulkan backend, instead of dereferencing with
!.API surface
Not additive — this PR contains five deliberate public-surface breaks, all recorded in
doc/articles/migrating-to-uno-7.mdandbuild/PackageDiffIgnore.xml:Uno.UI.ContextHelper.Currentis re-typedAndroid.Content.Context?. It could always benullbefore any activity exists, but was annotated non-null and returned_current!, so thecompiler never surfaced it. Typing it honestly changed no runtime behaviour and immediately
exposed 13 unguarded dereferences in
Uno.WinRT. Its semantics also change: it now tracks themost recently active activity that is still alive, rather than the last one ever assigned.
ContextHelper.Current's setter is narrowed tointernal. The value is owned by theactivity lifecycle, which overwrote anything app code assigned; with several activities an
outside write would point lookups at the wrong one.
ApplicationViewHelper.GetBaseActivityEvents()andIBaseActivityEventsare removed. NoSkia activity implements the interface, so it always returned
null(the documented usage threw).doc/articles/android-activities.mdnow points toApplication.RegisterActivityLifecycleCallbacks.Uno.UI.ViewManagement.Activity*Handlerdelegates are removed. They only typedIBaseActivityEvents' events and have no other consumer.Uno.UI.OnSystemUiVisibilityChangeListeneris narrowed tointernal. It is constructed bythe host with the activity owning the window; app code had no way to supply one.
ContextHelper.ApplicationContextis new and additive. Everything else in this PR isinternal.Why now: 7.0 ships Android multi-window ready; live multi-window (#24397) targets 7.1+ and
must not need a binary break. A contract audit of the Android public surface found the two items
above as the only ones that would otherwise need a break later. Everything else multi-window needs
is additive:
InitializeWithWindowfor pickers/share/web auth, a per-window context accessor (keyedon
WindowId), per-window overloads forPermissionsHelper, MSAL and the add-ins. NewIAndroidSkiaHostBuildermembers must use default interface implementations to stay non-breaking.Design notes
specs/053-android-multiwindow-ready/plan.mddocuments the architecture, the phase breakdown,and the deliberate follow-ups — chiefly flipping
SupportsMultipleWindowstotrue(needsActivity↔Window lifecycle orchestration and on-device validation, mirroring how iOS staged its
own multi-window behind scene adoption) and threading an explicit owning-window
Contextthroughthe remaining ambient
ContextHelper.Currentconsumers.Validation
Uno.UI.Runtime.Android(withUno.WinRTfornet10.0-android) andUno.UI.RuntimeTests.Skiabuild clean on the rebased head.Given_AndroidSkiaXamlRootHostandGiven_ApplicationActivityrun on theAndroid Skia CI lane. They cover host registration, wrapper-owned input sources, host resolution
while the activity is paused, and the re-creation handover: the successor takes the window,
reopens the first-frame gate and becomes
ContextHelper.Current.caught and fixed a black-window regression in the pre-draw gate. It has not been re-run since the
rebase; to smoke-test:
dotnet run --project src/SamplesApp/SamplesApp -f net10.0-android.PR Checklist ✅
Given_AndroidSkiaXamlRootHostruns on the Android Skia CI lane and asserts host registration, activity resolution and per-window input-source identity. The foreground-repoint logic itself lives onBaseActivity : AppCompatActivity, which the net-basedUno.UI.UnitTestscannot instantiate.migrating-to-uno-7.md; the in-repo spec covers the architecture.Screenshots Compare Test Runresults — pending CI.Known follow-ups
Carried from the review panels, deliberately not in this PR:
Window. The activity still adopts it throughthe ambient current window, and the factory resolves its activity the same way. An explicit
activity⇄window binding needs the lifecycle orchestration that lands with the live second activity.
Marked
TODO #8341.ContextHelper.WindowContextResolveris an internal staticFunc; before 7.1 it should become atyped
ApiExtensibilityregistration with a public per-window accessor (additive).AndroidSkiaNativeElementHostingExtension._attachedViewsis process-wide; move it onto eachwindow's host.
ContextHelper.Currentconsumers that need an activity (dialogs,StartActivity, haptics,status bar) still use the ambient value. App-scoped ones now use
ApplicationContext.with no log. A pending web authentication only ends through the caller's token if its
activity dies.
NativeWindowWrapper's process-wideTitleBar/DpiChangedsubscriptions are never removed;harmless with one wrapper, a leak with several.
TextInputPlugin.NotifyValueChangedlogs full text at Debug, andPasswordBox : TextBox, so passwords can reach logcat.🤖 Generated with Claude Code
https://claude.ai/code/session_01DtsKbXbA642EduoduiNtt4