Repository navigation
[Android] Shell: Defer inactive content until first selection - #39315
Conversation
Keep offscreen fragments and per-tab navigation state while lazily creating root pages and navigation hosts. Initialize selected content before pager scrolling with an OnResume fallback, and cover startup, navigation, cancellation, overflow, and lifecycle paths. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39315Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 39315" |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🔵 Needs a closer look
The startup-sensitive Android Shell lifecycle changes appear well tested, but required CI remains in progress.
0 open findings
What changed in this PR
Defers Android Shell page and navigation-host creation until content is first selected, reducing multi-tab startup work while retaining fragment caching.
Changes:
- Lazily initializes Shell content during selection or lifecycle resume.
- Initializes destinations before pager animation.
- Adds comprehensive Android device-test coverage.
| File | Description |
|---|---|
ShellLazyStartupTests.Android.cs |
Covers startup, selection, navigation, recreation, and reconnection. |
PublicAPI.Unshipped.txt |
Records the OnResume override. |
ShellSectionHandler.Android.cs |
Initializes selected top-tab content before scrolling. |
ShellItemHandler.Android.cs |
Initializes selected bottom-tab content before scrolling. |
ShellContentNavigationFragment.Android.cs |
Defers inactive page and host materialization. |
🧠 Review effort: Balanced
This comment has been minimized.
This comment has been minimized.
Performance Review Summary
Performance ResultsVerdict: 🟢 No performance blocker found; coverage incomplete The pinned diff defers Android Shell page and navigation-host initialization until content is selected, while retaining initialization guards for already visited content. No managed suites were selected, and the supplied bundle contains no run manifest, comparison summary, or measurement table; neither startup savings nor first-selection cost is empirically established. Device measurement required: the supplied evidence does not cover the changed native handler path, so the whole PR cannot receive a clean performance verdict. CoverageProduct files: 3; directly managed-measured: 0; device-required: 0; static-reviewed: 3. Sampled subsets: managed 0, device 0. Findings & Follow-upStatic hot-path reviewIn ShellContentNavigationFragment.Android.cs, the changed OnCreateView/OnResume/InitializeNavigation path (new lines 60–207) gates page creation and navigation-manager setup, and the existing-manager guard prevents repeated setup through the added entry points. ShellSectionHandler.Android.cs, InitializeCurrentContent (new lines 533–555), adds an item-index lookup, fragment-tag formatting, and native fragment lookup during selection; ShellItemHandler.Android.cs invokes it before switching sections. These are selection/lifecycle operations, not demonstrated per-frame callbacks, so the diff does not establish a high-frequency allocation or redundant-layout regression. Offscreen fragment containers are still created; lazy page/host creation must not be described as eliminating all offscreen native setup. The selector classifies all changed product paths as static-only/unmapped, with no directly measured, sampled, or catalog-selected device scenario evidence. The added device tests express intended startup, navigation-stack, cancellation, and lifecycle behavior, but no execution results are supplied. Recommended next action
The deterministic baseline's limited no-performance-action recommendation is consistent with no selected managed comparisons and no concrete static hot-path regression identified in this diff; it is not an empirical clearance of the Android changes. The selector's prNumber 0 and baseRef origin/main are not the resolved PR number and net11.0 base, and the selector provides no revision identities to corroborate those metadata fields; do not use them as alternative revision pins. This review uses only the supplied merge-base/head diff. Android startup, first selection, revisits, and fragment recreation remain unmeasured, and the empty device-scenario selection supplies no supported native driver. Human assessment of that gap is still required; retrying managed benchmarks would not exercise these native paths.
|
This comment has been minimized.
This comment has been minimized.
|
Note 🔍
|
|
/azp run maui-pr-uitests, maui-pr-devicetests |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
MauiBot
left a comment
There was a problem hiding this comment.
AI Review Summary
@simonrozsival — new AI review results are available based on commit
9686fd1.
🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix
Gate Result: ✅ PASSED
Platform: ANDROID · Base: net11.0 · Merge base: feffbb38
| Test | Without Fix (expect FAIL) | With Fix (expect PASS) |
|---|---|---|
📱 ShellLazyStartupTests (StartupCreatesOnlyTheSelectedContent, FirstSelectionCreatesOnceAndRevisitsRetainTabStacks, TopTabSelectionIsLazyAndCancelledSelectionDoesNotCreateContent, FirstSelectionInitializesContentBeforePagerAnimationSettles, ChangingContentInAnInactiveSectionDoesNotInitializeItsPages, NavigationBeforeFirstSelectionIsReconciledWithoutDuplicatePushes, InactiveTabChangesAndOverflowDoNotCreatePages, InactiveViewRecreationAndActiveResumePreserveLazyInitialization, RecreatingVisitedContentRetainsItsRootAndNavigationStack, ReconnectingShellPreservesStackWithoutCreatingInactiveContent) Category=Shell |
✅ FAIL — 348s | ✅ PASS — 339s |
🔴 Without fix — 📱 ShellLazyStartupTests (StartupCreatesOnlyTheSelectedContent, FirstSelectionCreatesOnceAndRevisitsRetainTabStacks, TopTabSelectionIsLazyAndCancelledSelectionDoesNotCreateContent, FirstSelectionInitializesContentBeforePagerAnimationSettles, ChangingContentInAnInactiveSectionDoesNotInitializeItsPages, NavigationBeforeFirstSelectionIsReconciledWithoutDuplicatePushes, InactiveTabChangesAndOverflowDoNotCreatePages, InactiveViewRecreationAndActiveResumePreserveLazyInitialization, RecreatingVisitedContentRetainsItsRootAndNavigationStack, ReconnectingShellPreservesStackWithoutCreatingInactiveContent): FAIL ✅ · 348s
(no coded error found; showing last 1200 chars)
ryBytes": 8322998272
},
"target": {
"kind": "emulator",
"name": "sdk_gphone_x86_64",
"identifier": "emulator-5554",
"operatingSystem": "Android",
"operatingSystemVersion": "11",
"apiLevel": 30,
"architecture": "x86_64",
"supportedArchitectures": [
"x86_64",
"x86",
"arm64-v8a",
"armeabi-v7a",
"armeabi"
],
"manufacturer": "Google",
"model": "sdk_gphone_x86_64",
"productName": "sdk_gphone_x86_64",
"buildFingerprint": "google/sdk_gphone_x86_64/generic_x86_64_arm64:11/RSR1.201211.001/7027799:user/release-keys",
"cpuModel": "0",
"cpuMaxFrequencyHertz": 2000,
"totalMemoryBytes": 2077544448
}
}
}
<<XHARNESS_RESULT_END>>
info: Attempting to remove apk 'com.microsoft.maui.controls.devicetests'..
info: Successfully uninstalled com.microsoft.maui.controls.devicetests
XHarness exit code: 1 (TESTS_FAILED)
Passed: 0
Failed: 13
Skipped: 0
Total: 13
Tests completed with exit code: 1
🟢 With fix — 📱 ShellLazyStartupTests (StartupCreatesOnlyTheSelectedContent, FirstSelectionCreatesOnceAndRevisitsRetainTabStacks, TopTabSelectionIsLazyAndCancelledSelectionDoesNotCreateContent, FirstSelectionInitializesContentBeforePagerAnimationSettles, ChangingContentInAnInactiveSectionDoesNotInitializeItsPages, NavigationBeforeFirstSelectionIsReconciledWithoutDuplicatePushes, InactiveTabChangesAndOverflowDoNotCreatePages, InactiveViewRecreationAndActiveResumePreserveLazyInitialization, RecreatingVisitedContentRetainsItsRootAndNavigationStack, ReconnectingShellPreservesStackWithoutCreatingInactiveContent): PASS ✅ · 339s
(no coded error found; showing last 1200 chars)
"totalMemoryBytes": 8322998272
},
"target": {
"kind": "emulator",
"name": "sdk_gphone_x86_64",
"identifier": "emulator-5554",
"operatingSystem": "Android",
"operatingSystemVersion": "11",
"apiLevel": 30,
"architecture": "x86_64",
"supportedArchitectures": [
"x86_64",
"x86",
"arm64-v8a",
"armeabi-v7a",
"armeabi"
],
"manufacturer": "Google",
"model": "sdk_gphone_x86_64",
"productName": "sdk_gphone_x86_64",
"buildFingerprint": "google/sdk_gphone_x86_64/generic_x86_64_arm64:11/RSR1.201211.001/7027799:user/release-keys",
"cpuModel": "0",
"cpuMaxFrequencyHertz": 2000,
"totalMemoryBytes": 2077544448
}
}
}
<<XHARNESS_RESULT_END>>
info: Attempting to remove apk 'com.microsoft.maui.controls.devicetests'..
info: Successfully uninstalled com.microsoft.maui.controls.devicetests
XHarness exit code: 0
Passed: 13
Failed: 0
Skipped: 0
Total: 13
Tests completed successfully
📁 Fix files reverted (4 files)
src/Controls/src/Core/Handlers/Shell/ShellContentNavigationFragment.Android.cssrc/Controls/src/Core/Handlers/Shell/ShellItemHandler.Android.cssrc/Controls/src/Core/Handlers/Shell/ShellSectionHandler.Android.cssrc/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt
📋 Pre-Flight — Context & Validation
Pre-Flight Context
PR snapshot: #39315 is an open, non-draft PR targeting net11.0. The immutable comparison is base feffbb381c09049a8ac4d19b9d74a435428c64c4 to head 9686fd158cbb5eaee278a120535c793e38e61c2a. GitHub reports one commit, 5 changed files, 614 additions, and 25 deletions.
Reported problem
The PR reports that the new .NET 11 Android Shell handler creates every cached offscreen ShellContent page during startup. ViewPager2 intentionally creates and retains offscreen fragments, but each fragment’s OnCreateView also called IShellContentController.GetOrCreateContent(), causing never-selected ContentTemplate/DI pages, handlers, navigation managers, and navigation hosts to be created before first draw.
The author reports this constructor path:
ContentTemplate / DI factory
-> ElementTemplate.CreateContent
-> IShellContentController.GetOrCreateContent
-> ShellContentNavigationFragment.OnCreateView
In an author-reported five-tab Samsung A16 benchmark, the matched source-built comparison measured:
| Variant | Median first frame | p90 |
|---|---|---|
Unpatched net11.0 |
1631.5 ms | 1716.4 ms |
Compatibility ShellRenderer |
1197.5 ms | 1249.2 ms |
| PR implementation | 1251.0 ms | 1307.4 ms |
The claimed improvement is 380.5 ms/23.3% relative to the unpatched handler. Raw measurements, APKs, traces, logs, and screenshots were retained locally and are unavailable here, so these performance figures are author-reported rather than independently verifiable from the PR.
There is no dedicated issue for the exact multi-tab inactive-content case. The PR links #37282 as historical context: that issue concerned single-page Shell startup overhead and was closed after #37321 added a single-page optimization. #39315 describes a distinct remaining multi-tab behavior.
Changed files and mechanism
| File | Submitted change |
|---|---|
ShellContentNavigationFragment.Android.cs |
Separates lightweight fragment-container creation from page/navigation-host initialization. |
ShellItemHandler.Android.cs |
Initializes the destination section’s current content before switching the bottom ViewPager2. |
ShellSectionHandler.Android.cs |
Initializes selected top-tab content before pager movement, subject to active-section and fragment-state checks. |
PublicAPI/net-android/PublicAPI.Unshipped.txt |
Records the inherited public OnResume() override. |
ShellLazyStartupTests.Android.cs |
Adds 10 Android device-test methods comprising 13 test cases. |
The central mechanism is ShellContentNavigationFragment.InitializeNavigation():
- It returns if initialization already produced a navigation manager or if the container, Shell content, or MAUI context is unavailable.
- It materializes the root page with
GetOrCreateContent(). - It subscribes to
NavigationRequested. - It creates the scoped
StackNavigationManagerandMauiNavHostFragment. - It connects immediately when attached, otherwise registering the existing attach callback.
OnCreateView() now always creates the cached FragmentContainerView, but calls InitializeNavigation() only when the fragment represents the current visible content or when _rootPage proves that the content was initialized previously. Existing-container reuse also initializes current content and only restores the navigation-event subscription when a navigation manager already exists.
OnResume() is a lifecycle fallback: if the fragment has become current, it attempts initialization again. Currentness requires the parent ShellSection to be visible and its CurrentItem to equal this ShellContent.
Selection paths attempt initialization before pager animation:
- Bottom-section switching calls
ShellSectionHandler.InitializeCurrentContent()beforeShellItemHandlerchanges its pager position. ShellSectionHandler.MapCurrentItem()does the same before changing the top-content pager position.- The helper requires an added parent fragment, an adapter and current item, the full Shell hierarchy to identify this as the active section, and an unsaved
FragmentManagerstate. It locates the existing content fragment by theFragmentStateAdapterstable-item tag and callsInitializeNavigation().
The existing destruction model remains significant: OnDestroyView() clears the native container and navigation manager, unsubscribes events, and preserves the cached root page while the content remains in the Shell hierarchy. A recreated visited fragment therefore builds a fresh host/manager around the existing page and reconciles the section stack.
Platform-sensitive paths
This is Android-only code involving AndroidX.Fragment, nested ViewPager2/FragmentStateAdapter layers, FragmentContainerView, synchronous fragment transactions, lifecycle callbacks, stable fragment tags, and window-attachment callbacks.
Important boundaries evident from the source:
- Offscreen fragment views and lightweight containers are still created and cached. The change defers page, handler, navigation-manager, and navigation-host creation; it does not eliminate all offscreen native setup.
FragmentManager.IsStateSavedprevents selection-time initialization, leavingOnResume()as the fallback.- Initialization depends on stable tags of the form
f{adapter.GetItemId(index)}. - Full active-section checks prevent changing
CurrentIteminside an inactive bottom section from creating its pages. - Existing active-section appearance setup may still call
GetOrCreateContent()for the active section’s current page. - Navigation queued before the host exists must be reconciled from
ShellSection.Stack, rather than replayed as duplicate pushes. - Fragment view recreation must create a fresh native manager while retaining an already-created root page and navigation stack.
- Fragment and pager operations are lifecycle/thread-sensitive; the inspected code does not add an explicit dispatcher or thread assertion.
Validation context and requirements
The supplied Gate result is authoritative for this context: Gate passed—tests fail without the fix and pass with it. It was not re-run.
The submitted Android device tests require the following behavior:
- At startup, only the selected bottom section/top content is materialized, including non-zero initial selections.
- First activation creates a page exactly once.
- Bottom and top destinations have a navigation host before pager animation settles.
- Repeated visits preserve independent navigation managers, page handlers, and stacks.
- A cancelled top-tab selection does not create the proposed destination.
- Changing content inside an inactive section does not initialize that section.
- Navigation queued before first selection is reconciled without duplicate pushes.
- Visibility, insertion/removal, title, badge, enabled-state, and overflow/“More” routing changes do not create unrelated pages.
- Pause/resume preserves an active manager while unvisited recreated fragments remain lazy.
- Recreating visited content retains its root page and logical navigation stack while creating a fresh manager.
- Full Shell disconnect/reconnect preserves the active stack without creating inactive content.
The PR description additionally reports:
- New focused class: 13/13 passed.
- Combined new and existing Android Shell device coverage: 86/89 passed.
- The same three
FlyoutCustomContentMargindensity-rounding failures occurred on the pristine baseline. - Android Release build and public API validation passed.
- A filtered managed Shell unit-test invocation was blocked before execution by pre-existing RS0030 analyzer diagnostics.
- Separate UI/device pipelines were started according to PR comments, but their final results were not available in the gathered context.
Performance validation should distinguish page-construction savings from the remaining wrapper, pager, fragment, toolbar, and selected-host costs. Startup, first selection, revisit, and recreation costs are native-device scenarios; managed benchmarks alone would not exercise them.
Remaining uncertainties
- There is no dedicated issue containing an independently maintained reproduction for the exact regression.
- The attached diff was explicitly partial. GitHub reports five changed files, and the affected head/base handler source plus the complete added test file were inspected, but this is not an exhaustive review of all interacting Shell code.
- Raw benchmark artifacts and visual-equivalence evidence are unavailable.
- Behavior across other Android versions, OEM fragment implementations, device speeds, configuration changes, process restoration, and rapid lifecycle/selection interleavings is unknown.
- The reliability of the
IsStateSavedearly return plusOnResume()fallback under every navigation/restoration ordering remains for expert validation. - Stable fragment-tag lookup depends on adapter identity behavior during collection mutation; submitted tests cover several mutations but cannot establish every ordering.
- Whether all mapper and navigation entry points are guaranteed to execute on the Android UI thread was not established from this limited source read.
- Final CI status, merge-block reason, and results from the separately running expert review are unknown. No recommendation or winner is asserted here.
🔬 Code Review — Deep Analysis
Expert PR Evaluation
Independent Assessment
What this changes: The submitted Android Shell fix separates lightweight offscreen fragment-container creation from page and navigation-host materialization. It initializes the selected destination before pager movement and uses fragment lifecycle fallback paths for restoration and state-saved transitions, while preserving already-created root pages across native view recreation.
Inferred motivation: ViewPager2 caches offscreen fragments, and the previous OnCreateView() path materialized every cached ShellContent page before first draw. The change defers inactive ContentTemplate/DI pages, handlers, navigation managers, and navigation hosts until first selection.
Evidence
- Reviewed immutable submitted diff
feffbb381c09049a8ac4d19b9d74a435428c64c4..9686fd158cbb5eaee278a120535c793e38e61c2a. - The single MAUI expert dimension review completed and produced
inline-findings.jsoncontaining[]; no validated actionable defect was found. - Trusted Gate passed: all 13 focused Android device cases failed without the fix and passed with the submitted fix.
- Regression cross-reference result is
CLEAN; no recent labeled bug-fix overlap or revert risk was detected.
Blast Radius and Failure-Mode Probing
- Runs for all instances: The Android Shell handler path is shared, but inactive content now stops at lightweight fragment/container setup. Page and host materialization remains limited to current or previously initialized content.
- Startup impact: Yes, intentionally. The selected content still initializes; never-selected cached content remains lazy.
- Static/shared state: No new static or cross-window state is introduced.
- Selection and cancellation: Destination initialization occurs on committed selection paths; the focused Gate covers bottom/top selection, non-zero initial selection, and cancelled top-tab selection.
- Lifecycle and state restoration:
IsStateSavedcan defer selection-time initialization toOnResume(). The Gate covers pause/resume, inactive view recreation, visited-content recreation, and full Shell reconnect. - Subscriptions and navigation reconciliation: Destruction removes navigation subscriptions and native manager/container state while retaining the logical root and stack. The Gate covers first/repeat visits, independent stacks, queued navigation, and reconnect/recreation.
- Collection mutation and inactive sections: Stable fragment lookup and active-section guards are exercised by visibility, insertion/removal, title, badge, enabled-state, overflow routing, and inactive-section changes.
CI Status
- The trusted focused Android Gate is green.
- Required-check status could not be queried because
ghis unauthenticated and branch-protection requirements require authentication. - Public check-run evidence at review time showed 62 successes, 1 skipped check, 1 MacCatalyst Label UI-test failure, 110 checks still in progress, and 2 queued checks. The failure is outside the Android-only submitted diff, but its attribution was not independently established and the overall run was not complete.
Findings
No validated inline code findings. The evidence threshold for a pr-plus-reviewer refinement is not met.
External Output Contract
Not applicable.
Verdict: NEEDS_DISCUSSION
Confidence: low
Summary: The submitted mechanism is coherent, the focused regression Gate is strong, and the expert review found no actionable code defect. The code-review verdict remains NEEDS_DISCUSSION only because required CI could not be identified and the public check set was still incomplete; this is missing completion evidence, not a demonstrated defect in the submitted Android fix.
🛠️ Try-Fix — Analysis & Comparison
Alternative generation: not requested
Evidence-first mode intentionally omits routine Try-Fix attempts. This is not a failed
attempt, a completed alternative search, or evidence that alternatives have no value.
The expert review may still produce one evidence-backed PR refinement.
🏁 Report — Final Recommendation
⚠️ Final Recommendation: REQUEST CHANGES
Phase Status
| Phase | Status | Notes |
|---|---|---|
| Pre-Flight | ✅ COMPLETE | Trusted evidence-first context consumed for immutable base feffbb38 and head 9686fd1 |
| Code Review | NEEDS_DISCUSSION (low) | 0 errors, 0 warnings; required CI identity unavailable and the public check set was incomplete |
| Gate | ✅ PASSED | Android; 13/13 focused cases failed without the fix and passed with it |
| Try-Fix | Not requested | Evidence-first mode intentionally omitted routine alternative generation |
| Refinement | Not generated | No concrete expert finding met the evidence threshold |
| Report | ✅ COMPLETE | Raw pr is the sole candidate and winner |
Code Review and Candidate Comparison
| Candidate | Expert findings addressed | Validation | Result |
|---|---|---|---|
pr |
No validated actionable findings were produced | Trusted Android Gate passed; regression cross-reference was CLEAN |
Best and only real candidate |
The single expert review produced an empty inline-findings array. A pr-plus-reviewer candidate was therefore not implemented, and no try-fix-N candidates exist. The submitted PR wins the code-and-focused-validation comparison, but the review cannot recommend approval while required-check identity is unavailable and the public check set remains incomplete.
Summary
The submitted fix is coherent and directly validated against the reported lazy-materialization regression. The recommendation is REQUEST CHANGES only because CI completion evidence is missing at review time: public evidence showed one unclassified MacCatalyst Label UI-test failure, 110 checks still running, and 2 queued checks, while authentication was unavailable to identify required checks. This is not a demonstrated defect in the Android fix.
Root Cause
Android ViewPager2 creates cached offscreen Shell fragments, and the prior ShellContentNavigationFragment.OnCreateView() path called GetOrCreateContent() for each cached fragment. That eagerly constructed never-selected ContentTemplate/DI pages, handlers, navigation managers, and navigation hosts before first draw.
Fix Quality
The fix separates lightweight fragment-container creation from page/navigation-host initialization, initializes committed destinations before pager movement, and retains lifecycle fallbacks for state-saved and restoration paths. The focused Gate covers startup selection, first activation, revisit and independent stacks, cancelled top-tab selection, inactive-section changes, queued navigation, collection mutations, pause/resume, recreation, and Shell reconnect. Expert review found no actionable defect, and the regression cross-reference found no recent fix overlap; broader CI completion remains the only unresolved evidence gap.
📱 UI Tests — Shell
Detected UI test categories: Shell
[!WARNING]
No UI test results were produced for the detected categories. The PR build itself was
fine — the deep UI stage was skipped or interrupted on infrastructure (the
merge-for-testing step, emulator/simulator boot, or an Appium hang), not by this PR's code.
This is usually transient; the review re-runs on new commits (a maintainer can also re-run it).
🧭 Next Steps — review latest findings
No alternative fix was selected for this run. Review the session findings and CI results before merging.
[!NOTE]
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
Restore lazy page materialization in the new Android Shell: cached offscreen content fragments must not instantiate never-selected
ContentTemplatepages, their handlers, or navigation hosts.This PR targets
net11.0, where the new Android implementation exists.mainstill uses the compatibility implementation and does not contain these handlers.Why this needs investigation
A five-tab conference app using DI-created
ContentTemplatepages showed a large startup difference when switching only the Shell implementation within the same pinned MAUI 11 configuration:ShellRendererThe legacy implementation was 442 ms / 30.1% faster. There were 15 process-cold launches per configuration across three blocks; block improvements were 460 / 426 / 431 ms. Warmups were excluded, every launch had a new process, the device was exclusively reserved, and thermal status was 0. Both displayed the actual populated Home screen, not an empty timing shortcut.
This was a Samsung A16 SM-A165F, Android 16, ARM64, using
11.0.0-rc.1.26451.6(source484132f9e51f4d1eae72dba038575d6102639730). App content, registrations, Material 3, and Release compiler/runtime settings were matched. Each Shell variant had a separately collected startup profile, so the builds were not byte-identical. The metric is Androidam start -Wfirst displayed frame, not reboot-cold startup or completion of agenda initialization.Separately instrumented constructor traces, with no lost events, showed all four inactive pages (Sessions, Speakers, Schedule, Community) being constructed before the first draw. The constructor path was:
Current
net11.0retained that eager path. The instrumented trace timestamps are not the uninstrumented benchmark numbers or additive CPU time.The historical comparison is not a benchmark of this PR. The matched source-built comparison below separately measures the correction; the whole historical 442 ms should not be attributed to one line. The remaining Shell wrapper/pager/tab infrastructure overhead still warrants investigation.
Matched source-built three-way benchmark (October 12)
The PR implementation was also benchmarked against the unpatched
net11.0handler and the compatibilityShellRendererfrom that same framework graph. This is a new controlled comparison, separate from the historical RC1 measurements above; literalmainis not the baseline because it does not contain the new Android Shell.net11.0ShellRendererThe correction reduced the median by 380.5 ms / 23.3% and closed 87.7% of the unpatched-to-legacy gap. It remained 53.5 ms / 4.5% slower than compatibility Shell; that remaining infrastructure overhead still merits investigation. The improvement held in all three blocks: 393.0 / 398.5 / 362.5 ms.
Protocol: Samsung A16 SM-A165F, Android 16, ARM64; 30 measured process-cold launches per implementation in three counterbalanced blocks of ten. Two warmups per implementation per block were excluded. Every launch reported
COLD, had a new PID, and had thermal status 0 before and after. App data was not cleared between configurations.am start -WTotalTimeis time to the first displayed frame with warm filesystem caches, not reboot-cold startup or completion of agenda initialization. p90 uses linear interpolation at(n-1)*0.9.All variants used public app source
jfversluis/dotnetconf-appcommit4b2077609680eaec04429ea76efc04833d7aacb6, a separate benchmark package, target SDK 37, and the repository-pinned SDK11.0.100-rtm.26480.113. The graph was pinned tofeffbb381c09049a8ac4d19b9d74a435428c64c4; the fixed variant applied9686fd158cbb5eaee278a120535c793e38e61c2a. Material 3, SourceGen XAML, app content/DI/control registrations, Release compiler/runtime settings, and trimming policy were common. There were no independently trained profile inputs per variant. Normalized executable-assembly comparisons confirmed identical app code for unpatched/fixed and changes confined to the PR's three Shell types; compilation identities and native images were not byte-identical.Visual/content equivalence was checked independently from timings. The original saved first-frame and settled screenshots contain byte-identical, fully opaque Home hero regions across all three implementations, including the title and “Explore sessions” button. Separate constructor/native-tree probes confirmed five root pages created at startup in the unpatched handler, versus only Home in compatibility Shell and this PR, with matching visible Home content. Diagnostic runs were not included in the timing data. Raw measurements, APKs, logs, and screenshots remain local rather than being uploaded automatically.
Remaining compatibility-renderer gap (hypothesis)
Our hypothesis is that the remaining 53.5 ms reflects infrastructure the corrected handler still initializes: nested wrapper fragments, item/section
ViewPager2and adapter layers (including single-content sections), cached inactive-content containers, and the selected content's shared navigation-host machinery. Compared with the compatibility renderer's on-demand section-fragment path, these can add native-object creation, lifecycle callbacks, layout work, and JNI crossings even though inactive pages are now lazy.The rewrite retained this structure for shared-component reuse, a persistent toolbar, independent navigation stacks, and protection against fragment-state restoration failures. These are design/correctness motivations, not proof that the measured residual cost is unavoidable or belongs to a particular bug fix. We have not profiled the individual costs within that 53.5 ms. This PR deliberately stops at the validated inactive-content correction; single-content fast paths and further deferred wrapper/pager initialization remain possible follow-up investigations, provided they preserve navigation and restoration behavior.
Design history and retained invariants
#34758 introduced shared drawer/tab/navigation building blocks, a persistent toolbar, and independent content navigation stacks. Its all-items
OffscreenPageLimitpolicy was intentional: it avoids fragment save/restore paths that lose MAUI state and cause crashes.#37282 previously reported single-page startup overhead and called out the nested pager/fragments and all-items caching policy. #37321 then deferred unnecessary single-page tab-manager infrastructure and preserved dynamic growth, appearance replay, badges, and native manager reuse. It did not defer inactive page/navigation-host creation in a multi-tab Shell.
This PR keeps the existing offscreen limits, stable fragment IDs, cached fragments, toolbar/tab/badge infrastructure, and the single-page optimization. It does not replace the default handler with the legacy renderer.
Two important constraints from the rewrite remain intact:
ShellSection.Stack, not replayed, avoiding duplicate pushes and incorrect task completion.Correction
ShellContentNavigationFragment.OnCreateViewcreates the lightweight cached container without materializing never-selected content. The currently selected content still initializes normally.On first selection, the existing bottom/top selection mapper paths initialize the selected destination before pager scrolling. This prevents waiting until smooth-scroll completion and showing an empty destination during the first tab animation.
OnResumeremains the fallback for fragments whose views were not ready when selection changed. Activation checks the full active Shell section, and saved-state selection defers to the lifecycle fallback.Initialization remains once-per-live-navigation-host. Existing root-page caching, background setup, navigation subscriptions, stack reconciliation, and destruction/recreation behavior are retained. The API ledger records the inherited
OnResumeoverride; no new navigation API or configuration switch is introduced.Validation
Built from the repository-pinned SDK
11.0.100-rtm.26480.113, with an Android-only local build override and the repository build tasks. Both framework variants used the same in-tree graph and Release settings; pristine source/API files fromfeffbb381c09049a8ac4d19b9d74a435428c64c4were selected through a local compile override without reverting the working tree. Public API analyzers stayed enabled. Logs/APKs remain local and are not uploaded.OnResume-only candidate: destination host was emptyCurrentItemchangeThe combined final run was 86/89 passed, not a completely green suite. All three failures are
FlyoutCustomContentMargin(header/content/footer); the pristine baseline produces the same device-density rounding values (20.266666...for an expected 20 DIP margin).Coverage includes non-first initial bottom/top selections, only one initial page materialized, once-only first activation, repeated tab visits and independent stacks, cancelled top selection, navigation queued before host creation, overflow/More routing, item/content visibility and collection changes, badges on inactive tabs, pause/resume, adapter-driven recreation before/after a visit, and full Shell disconnect/reconnect.
Build/test commands and results (local APK/output paths abbreviated):
The prescribed runner's build/class-filter machinery was used. Physical-device execution used explicit XHarness instrumentation because the emulator-start helper rejects physical serials; no emulator or shared adb server was restarted.
Issues Fixed
No new issue filed at the author's request. Related historical single-page report: #37282; this PR addresses the distinct multi-tab inactive-content case.