Repository navigation
Revert - [Android] Fix control size properties not available during Loaded event - #38769
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 38769Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 38769" |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
This comment has been minimized.
This comment has been minimized.
|
Note 🔍
|
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Add a lifecycle test verifying Loaded fires before the first visible frame.
Review effort: Lite
Findings: None
What changed in this PR
Reverts Android’s deferred Loaded callback behavior to restore its historical pre-display timing and address issue #38360.
Changes:
- Invokes
Loadedimmediately when the view is attached. - Removes the obsolete Issue14364 regression test and host page.
| File | Description |
|---|---|
src/Core/src/Platform/Android/ViewExtensions.cs |
Restores immediate Loaded invocation. |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue14364.cs |
Removes the obsolete regression test. |
src/Controls/tests/TestCases.HostApp/Issues/Issue14364.cs |
Removes the corresponding test page. |
MauiBot
left a comment
There was a problem hiding this comment.
Expert Review — 1 findings
See inline comments for details.
| disposable = localDisposable; | ||
| } | ||
| }); | ||
| action(); |
There was a problem hiding this comment.
🔍 AI-Generated Review (multi-model)
[major] Logic and Correctness Verification — Calling action() synchronously on ViewAttachedToWindow reintroduces pre-layout Loaded timing, so size-dependent logic can observe invalid dimensions. Concrete scenario: a control reads Width/Height in Loaded before the first Android layout pass and receives unset/-1 values (the Issue14364 reproduction that this PR also deletes).
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Tests Failure Analysis
🧪 CI Analysis — click to expand📊 maui-prNo failures found. 🧪 maui-pr-devicetestsNo results available. 🧪 maui-pr-uitestsNo results available. 🧭 Follow-up — actions and refreshNext action: Comment
|
This comment has been minimized.
This comment has been minimized.
|
Note 🔍
|
…38784) <!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Backports #38769 from `inflight/current` to `inflight/candidate`. - Restores immediate Android `Loaded` callbacks when a view attaches, reverting the `view.Post()` deferral introduced by #31590. - Removes the deferral-specific detach/re-attach workaround from #34734, which is no longer needed. - Removes the `Issue14364` test page and UI test, as in the source PR. The landed commit `c47caea729ac2e9b14e34407f426e6c5c88290e7` was applied without conflicts. The backport is patch-identical to the source commit. ### Issues Fixed Addresses #38360 on `inflight/candidate`, matching #38769. ### Validation - Android Core build succeeded: `dotnet build src/Core/src/Core.csproj -f net10.0-android36.0 -p:TargetFrameworks=net10.0-android36.0` (three Gradle Java 8 obsolescence warnings). - Repository formatting completed, scoped to `src/Core/src/Platform/Android/ViewExtensions.cs`. - Verified matching stable patch IDs and a clean worktree. - Device/UI tests were not run. Co-authored-by: BagavathiPerumal <93652794+BagavathiPerumal@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
MauiBot
left a comment
There was a problem hiding this comment.
AI Review Summary
@BagavathiPerumal — new AI review results are available based on commit
577a9af.
🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix
Gate Result: ⚠️ SKIPPED
No tests were detected in this PR.
Recommendation: Add tests to verify the fix using the write-tests-agent.
📋 Pre-Flight — Context & Validation
PR #38769 Pre-Flight
Context
- Title: Revert - [Android] Fix control size properties not available during Loaded event
- Base / head:
main(3d7ff41c8e9ee0e23c48df72b346218cb0071dd7) /Revert-31590(577a9af4508381c31b2d32f0ecc10f90abb13ad3) - Local review branch:
pr-review-38769, clean squashed commit06eb354a07c9df6155587ee00526cb913feb6aa9 - Platform: Android
- Issue: #38360 reports a regression beginning in 10.0.60:
Loadednow runs after the view is visible, breaking setup that must complete before first paint. - Gate: Skipped because the PR adds no tests. Do not rerun the gate and do not create or overwrite
gate/content.md.
Direct Diff Assessment
The PR changes three files:
src/Core/src/Platform/Android/ViewExtensions.cssrc/Controls/tests/TestCases.HostApp/Issues/Issue14364.cs- Deletes the Android fixture that reads
WidthandHeightinLoaded.
- Deletes the Android fixture that reads
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue14364.cs- Deletes
SizePropertiesAvailableDuringLoadedEvent.
- Deletes
Behavioral Conflict
- Before #31590, synchronous attach-time dispatch preserved the historical pre-paint timing but could expose unset dimensions (
-1) inLoaded. - #31590 deferred dispatch with
view.Post, making dimensions valid after layout but allowing the first frame to become visible beforeLoaded. - #34734 retained that deferral and restored the pending subscription when a
ViewPager2detached before the posted callback, preventingLoadedfrom being lost on re-attach. - The PR restores pre-paint timing by fully reverting to synchronous dispatch, but thereby knowingly reintroduces #14364/#14160. The existing automated review flagged this as a major compatibility regression.
An acceptable alternative should seek a lifecycle point after dimensions are available but before first draw, while preserving exactly-once invocation, cancellation, disposal, and detach/re-attach behavior. It must be mechanistically different from both the PR's unconditional synchronous callback and the existing unconditional queued view.Post callback.
Bounded Validation
The supplied gate found no newly added test, and no mandatory regression-test list was included in the STEP 5a request. Do not run a full category, project, or repository suite.
The only permitted targeted validation command for each candidate is:
pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -TestFilter "FullyQualifiedName~Issue14364"The PR head deletes the Issue14364 fixture and test. A candidate may refine them only if the baseline explicitly includes them in .github/.baseline-state.json under RevertedFiles; otherwise they remain outside the edit boundary. If the filter discovers zero tests, the result must be Blocked even if the wrapper prints a success summary. LifeCycleEventsFireWhenNavigatingTopTabs is relevant historical evidence from #34734, but it is not run in STEP 5a because no mandatory regression tests were supplied and running the broader device-test scope would violate the bounded test contract.
Each try-fix invocation gets one implementation/test pass and at most one focused correction/retest. It must use EstablishBrokenBaseline.ps1 and the exact restore procedure required by the try-fix skill.
Applicable Repository Guidance
.github/instructions/android.instructions.md.github/instructions/threading-async.instructions.md.github/instructions/uitests.instructions.md.github/instructions/public-api.instructions.mdapplies only if a candidate changes public API; the current surface is internal.
🔬 Code Review — Deep Analysis
Expert Evaluation — Raw PR Fix
Verdict: NEEDS_CHANGES
Confidence: low
Independent assessment
The submitted Android change removes the posted callback from ViewExtensions.OnLoaded and invokes the Loaded action synchronously from ViewAttachedToWindow. This restores the pre-#31590 event ordering, but it also restores the condition where layout-dependent values can still be unset when Loaded runs. The PR additionally deletes the Issue14364 HostApp page and UI test that asserted usable size values during Loaded.
Findings
- ❌ Error — The behavioral tradeoff is unprotected. The immediate callback at
src/Core/src/Platform/Android/ViewExtensions.cs:654deliberately favors firing before first paint over waiting for layout. That can reintroduce the size-observation failure previously covered byIssue14364; the current patch neither preserves a compatible size guarantee nor adds a test that defines the newly restored timing contract. - ❌ Error — Regression coverage is removed without replacement. Both
Issue14364files are deleted, leaving no focused test for either side of the conflict:Loadedmust occur before the first visible frame, while consumers may observe incomplete layout state at that point.
The earlier MauiBot error-level concern about synchronous action() remains applicable to the submitted code. The required inline artifact was written as []: the behavioral concern was already raised inline, and the coverage finding concerns deleted lines that cannot receive a RIGHT-side review comment.
Blast radius and failure modes
OnLoadedis shared Android platform infrastructure used by allVisualElementinstances, not a control-specific path.- Attach/detach and handler reconnects can execute this callback during transient layout state.
- Size-dependent
Loadedhandlers can observe unset dimensions; deferring all callbacks instead causes first-paint ordering regressions such as #38360. - No new static state or startup-only path is introduced.
Reviewer refinement
Keep the immediate callback needed for #38360, but add focused Android regression coverage that codifies the intended contract rather than deleting all coverage: verify Loaded runs before first rendering/visibility while documenting or testing the expected layout-state behavior. The supplied Gate was skipped because the submitted PR contains no detected tests, and current CI evidence was pending/undetermined, so safety confidence remains low.
External Output Contract
Not applicable.
Trim/AOT Evidence Chain
Not applicable.
🛠️ Try-Fix — Analysis & Comparison
PR #38769 Alternative Fix Candidates
| Candidate | Result | Validation |
|---|---|---|
| 1. Attach-scoped layout readiness | Blocked | Compiled; targeted filter discovered 0 tests |
| 2. One-shot pre-draw barrier | Blocked | Compiled; targeted filter discovered 0 tests |
Candidate 1 — Attach-Scoped Layout Readiness
Model: gpt-5.3-codex
Approach: Gate ViewExtensions.OnLoaded on an attached view having measured dimensions. Arm a ViewTreeObserver.GlobalLayout handler per attachment, remove it on detach, invoke once when Width and Height are positive, and dispose all listeners after completion or cancellation.
Mechanism-level difference: This avoids both the PR's unconditional synchronous attach callback, which can expose invalid dimensions, and the existing unconditional view.Post callback, which can run after first visibility and requires a posted-callback detach retry. The candidate instead uses layout readiness before draw with explicit attach-scoped cleanup.
Files changed:
src/Core/src/Platform/Android/ViewExtensions.cs
Result: Blocked
Test command:
pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -TestFilter "FullyQualifiedName~Issue14364"Candidate 2 — One-Shot Pre-Draw Barrier
Model: gpt-5.6-sol
Approach: Arm an Android ViewTreeObserver.IOnPreDrawListener when the view attaches. Android invokes it during rendering after measure/layout but before drawing. The listener invokes Loaded, removes lifecycle and pre-draw listeners exactly once, and permits drawing to continue. Detach removes the old listener while retaining the pending operation so re-attach can arm a fresh observer.
Mechanism-level difference: Unlike the PR's immediate attach callback, this waits until geometry has been established. Unlike view.Post, execution is render-ordered rather than message-queue-ordered. Unlike candidate 1, it does not observe GlobalLayout, poll dimensions, or use a layout-readiness predicate; it observes the next pre-draw boundary.
Files changed:
src/Core/src/Platform/Android/ViewExtensions.cs
Result: Blocked
Test command:
pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -TestFilter "FullyQualifiedName~Issue14364"Test result: The Android HostApp and test project built and the command exited 0, but NUnit discovered 0 of 0 tests and reported No test matches the given testcase filter FullyQualifiedName~Issue14364. The wrapper's later All tests passed / Result: SUCCESS summary was rejected because no test executed.
Failure/blocker analysis: PR #38769 deletes both Issue14364 source files. EstablishBrokenBaseline.ps1 classified only ViewExtensions.cs as a revertible production fix and did not restore deleted test files, so .github/.baseline-state.json forbade restoring or refining them. No permitted focused correction could make the mandated filter discover a test, and compilation alone cannot establish a Pass.
Self-review: 0 findings.
Diff:
diff --git a/src/Core/src/Platform/Android/ViewExtensions.cs b/src/Core/src/Platform/Android/ViewExtensions.cs
index a1c89cf5c0..8a6c8b60fc 100644
--- a/src/Core/src/Platform/Android/ViewExtensions.cs
+++ b/src/Core/src/Platform/Android/ViewExtensions.cs
@@ -624,54 +624,144 @@ namespace Microsoft.Maui.Platform
return new ActionDisposable(() => { });
}
- EventHandler<AView.ViewAttachedToWindowEventArgs>? routedEventHandler = null;
- ActionDisposable? disposable = new ActionDisposable(() =>
+ EventHandler<AView.ViewAttachedToWindowEventArgs>? attachedToWindowHandler = null;
+ EventHandler<AView.ViewDetachedFromWindowEventArgs>? detachedFromWindowHandler = null;
+ ViewTreeObserver? preDrawObserver = null;
+ OnLoadedPreDrawListener? preDrawListener = null;
+ bool cancelled = false;
+ bool completed = false;
+
+ void RemovePreDrawListener()
{
- if (routedEventHandler is not null && view.IsAlive())
+ var observer = preDrawObserver;
+ var listener = preDrawListener;
+
+ preDrawObserver = null;
+ preDrawListener = null;
+
+ if (listener is null)
+ return;
+
+ if (observer?.IsAlive == true)
{
- view.ViewAttachedToWindow -= routedEventHandler;
+ observer.RemoveOnPreDrawListener(listener);
}
- });
- routedEventHandler = (_, __) =>
- {
- if (!view.IsLoaded() && Looper.MyLooper() is Looper q)
- {
- new Handler(q).Post(() =>
- {
- if (disposable is not null)
- action.Invoke();
+ listener.Cancel();
+ }
- disposable?.Dispose();
- disposable = null;
- });
+ ActionDisposable? disposable = null;
+
+ void InvokeOnPreDraw()
+ {
+ if (cancelled || completed)
+ return;
+ if (!view.IsAttachedToWindow)
+ {
+ RemovePreDrawListener();
return;
}
- // Store local reference to allow cancellation inside the Post callback
- var localDisposable = disposable;
+ completed = true;
+ var completionDisposable = disposable;
disposable = null;
- view.Post(() =>
+ completionDisposable?.Dispose();
+ action();
+ }
+
+ void ArmPreDrawListener()
+ {
+ if (cancelled || completed)
+ return;
+
+ RemovePreDrawListener();
+
+ var observer = view.ViewTreeObserver;
+ if (observer is null || !observer.IsAlive)
+ return;
+
+ var listener = new OnLoadedPreDrawListener(InvokeOnPreDraw);
+ preDrawObserver = observer;
+ preDrawListener = listener;
+ observer.AddOnPreDrawListener(listener);
+ }
+
+ disposable = new ActionDisposable(() =>
+ {
+ cancelled = true;
+ RemovePreDrawListener();
+
+ if (view.IsAlive())
{
- if (view.IsAttachedToWindow && localDisposable is not null)
+ if (attachedToWindowHandler is not null)
{
- action();
- localDisposable.Dispose();
+ view.ViewAttachedToWindow -= attachedToWindowHandler;
+ attachedToWindowHandler = null;
}
- else if (localDisposable is not null)
+
+ if (detachedFromWindowHandler is not null)
{
- // View was detached before Post ran (e.g., ViewPager2 detach/re-attach cycle).
- // Restore disposable so the next ViewAttachedToWindow can retry.
- disposable = localDisposable;
+ view.ViewDetachedFromWindow -= detachedFromWindowHandler;
+ detachedFromWindowHandler = null;
}
- });
- };
+ }
+ });
+
+ attachedToWindowHandler = (_, __) => ArmPreDrawListener();
+ detachedFromWindowHandler = (_, __) => RemovePreDrawListener();
+
+ view.ViewAttachedToWindow += attachedToWindowHandler;
+ view.ViewDetachedFromWindow += detachedFromWindowHandler;
+
+ if (view.IsAttachedToWindow)
+ {
+ ArmPreDrawListener();
+ }
- view.ViewAttachedToWindow += routedEventHandler;
return disposable;
}
+ sealed class OnLoadedPreDrawListener : Java.Lang.Object, ViewTreeObserver.IOnPreDrawListener
+ {
+ Action? _action;
+ bool _isInvoking;
+
+ public OnLoadedPreDrawListener(Action action)
+ {
+ _action = action;
+ }
+
+ public bool OnPreDraw()
+ {
+ var action = _action;
+ _action = null;
+ _isInvoking = true;
+
+ try
+ {
+ action?.Invoke();
+ }
+ finally
+ {
+ _isInvoking = false;
+ Dispose();
+ }
+
+ return true;
+ }
+
+ public void Cancel()
+ {
+ _action = null;
+
+ if (!_isInvoking)
+ {
+ Dispose();
+ }
+ }
+ }
+
internal static IDisposable OnUnloaded(this View view, Action action)
{
if (!view.IsLoaded())Validation and Diff for Candidate 1
Test result: The project built and the script exited 0, but NUnit discovered 0 of 0 tests and reported No test matches the given testcase filter FullyQualifiedName~Issue14364. The wrapper's later All tests passed / Result: SUCCESS summary was rejected because no test executed.
Failure/blocker analysis: PR #38769 deletes both Issue14364 files, and the baseline allow-list contains only ViewExtensions.cs. Restoring or refining the missing test was prohibited, so compilation alone could not validate the candidate.
Self-review: 0 findings.
Diff:
diff --git a/src/Core/src/Platform/Android/ViewExtensions.cs b/src/Core/src/Platform/Android/ViewExtensions.cs
index a1c89cf5c0..36d5a56ad6 100644
--- a/src/Core/src/Platform/Android/ViewExtensions.cs
+++ b/src/Core/src/Platform/Android/ViewExtensions.cs
@@ -618,57 +618,98 @@ namespace Microsoft.Maui.Platform
internal static IDisposable OnLoaded(this View view, Action action)
{
- if (view.IsLoaded())
+ if (view.IsLoaded() && view.Width > 0 && view.Height > 0)
{
action();
return new ActionDisposable(() => { });
}
- EventHandler<AView.ViewAttachedToWindowEventArgs>? routedEventHandler = null;
- ActionDisposable? disposable = new ActionDisposable(() =>
+ EventHandler<AView.ViewAttachedToWindowEventArgs>? attachedToWindowHandler = null;
+ EventHandler<AView.ViewDetachedFromWindowEventArgs>? detachedFromWindowHandler = null;
+ EventHandler? globalLayoutHandler = null;
+ ViewTreeObserver? viewTreeObserver = null;
+ bool completed = false;
+ bool cancelled = false;
+
+ void RemoveGlobalLayoutHandler()
{
- if (routedEventHandler is not null && view.IsAlive())
+ if (globalLayoutHandler is null || viewTreeObserver is null)
+ return;
+
+ if (viewTreeObserver.IsAlive)
{
- view.ViewAttachedToWindow -= routedEventHandler;
+ viewTreeObserver.GlobalLayout -= globalLayoutHandler;
}
- });
- routedEventHandler = (_, __) =>
+ viewTreeObserver = null;
+ }
+
+ bool TryInvokeLoaded()
{
- if (!view.IsLoaded() && Looper.MyLooper() is Looper q)
- {
- new Handler(q).Post(() =>
- {
- if (disposable is not null)
- action.Invoke();
+ if (cancelled || completed || !view.IsAttachedToWindow)
+ return false;
- disposable?.Dispose();
- disposable = null;
- });
+ if (view.Width <= 0 || view.Height <= 0)
+ return false;
+ completed = true;
+ RemoveGlobalLayoutHandler();
+ action();
+ return true;
+ }
+
+ void ArmLoadedObserver()
+ {
+ if (cancelled || completed || !view.IsAttachedToWindow)
return;
+
+ RemoveGlobalLayoutHandler();
+
+ var observer = view.ViewTreeObserver;
+ if (observer is null || !observer.IsAlive)
+ return;
+
+ viewTreeObserver = observer;
+ viewTreeObserver.GlobalLayout += globalLayoutHandler;
+
+ // Layout may already be complete for this attachment.
+ TryInvokeLoaded();
+ }
+
+ ActionDisposable? disposable = new ActionDisposable(() =>
+ {
+ cancelled = true;
+ RemoveGlobalLayoutHandler();
+
+ if (attachedToWindowHandler is not null && view.IsAlive())
+ {
+ view.ViewAttachedToWindow -= attachedToWindowHandler;
+ attachedToWindowHandler = null;
}
- // Store local reference to allow cancellation inside the Post callback
- var localDisposable = disposable;
- disposable = null;
- view.Post(() =>
+ if (detachedFromWindowHandler is not null && view.IsAlive())
{
- if (view.IsAttachedToWindow && localDisposable is not null)
- {
- action();
- localDisposable.Dispose();
- }
- else if (localDisposable is not null)
- {
- // View was detached before Post ran (e.g., ViewPager2 detach/re-attach cycle).
- // Restore disposable so the next ViewAttachedToWindow can retry.
- disposable = localDisposable;
- }
- });
+ view.ViewDetachedFromWindow -= detachedFromWindowHandler;
+ detachedFromWindowHandler = null;
+ }
+ });
+
+ globalLayoutHandler = (_, __) =>
+ {
+ if (TryInvokeLoaded())
+ {
+ disposable?.Dispose();
+ disposable = null;
+ }
};
- view.ViewAttachedToWindow += routedEventHandler;
+ attachedToWindowHandler = (_, __) => ArmLoadedObserver();
+ detachedFromWindowHandler = (_, __) => RemoveGlobalLayoutHandler();
+
+ view.ViewAttachedToWindow += attachedToWindowHandler;
+ view.ViewDetachedFromWindow += detachedFromWindowHandler;
+ ArmLoadedObserver();
+
return disposable;
}📝 PR Finalize — Recommended Title & Description
Assessment: ✏️ Recommend updating — the description is accurate and thorough, but the title uses a noisy revert prefix and describes the reverted fix rather than the resulting Android Loaded behavior.
Recommended title
[Android] Loaded: Restore pre-display event timing
Recommended description
### Issue details:
PR #31590 aimed to fix Android controls not reporting valid size when the `Loaded` event fires. To achieve this, it changed `ViewExtensions.OnLoaded` so that the `Loaded` callback runs inside `view.Post()` instead of executing immediately when `ViewAttachedToWindow` fires, deferring it until after the layout pass completes.
After this change merged, the `Loaded` event started firing after the view becomes visible instead of before, which is a behavior change from all prior MAUI versions. This breaks consumers who rely on `Loaded` firing before the view is displayed to run setup logic (e.g., animations, focus, or state initialization) prior to first paint.
### Description of changes:
This reverts the changes introduced in PR #31590, which modified `ViewExtensions.cs` on Android to defer the `Loaded` event via `view.Post()`.
Reverting restores the prior immediate `action()` invocation on `ViewAttachedToWindow`, fixing the `Loaded` event timing regression (#38360). As a side effect, it also reverts the follow-up fix from PR #34734, which patched a `ViewPager2` detach/re-attach race condition that only existed because of the `Post()`-based deferral introduced by #31590; since that deferral no longer exists, the race condition it patched is no longer applicable.
This also removes the `Issue14364` regression tests added by PR #31590.
### Issues Fixed
Fixes https://github.com/dotnet/maui/issues/38360
🏁 Report — Final Recommendation
⚠️ Final Recommendation: REQUEST CHANGES
Winner: pr — the submitted implementation is the least risky of the available candidates, but it is not ready for approval.
The raw PR directly restores the historical Android pre-display Loaded ordering and removes the queued detach/re-attach race with a small, understandable change. It nevertheless knowingly restores the previously demonstrated invalid-size behavior from #14364/#14160, deletes the only focused regression test, and received an expert NEEDS_CHANGES verdict. The trusted Gate was skipped because no tests were detected, so selecting pr here means only that every alternative has weaker current evidence—not that the PR should merge unchanged.
Comparative ranking
| Rank | Candidate | Validation | Assessment |
|---|---|---|---|
| 1 | pr |
Gate skipped; no focused test executed | Smallest and most direct fix for #38360, with one-shot synchronous dispatch and no posted callback race. It has a concrete known regression: layout-dependent values can be invalid during Loaded, and coverage was removed. |
| 2 | try-fix-2 |
Blocked: build completed, but the required filter discovered 0 of 0 tests |
The one-shot pre-draw barrier is the strongest alternative design because it targets the renderer boundary after layout and before draw. It remains unverified, and its mechanism materially overlaps the reviewer candidate whose HostApp validation crashed before assertions. |
| 3 | try-fix-1 |
Blocked: build completed, but the required filter discovered 0 of 0 tests |
Attach-scoped global-layout readiness also seeks the correct ordering, but gating on positive Width and Height can indefinitely suppress Loaded for legitimate zero-sized views. No regression test executed. |
| 4 | pr-plus-reviewer |
Failed: 1 of 1 test discovered; HostApp crashed twice during fixture setup; command exited 1 |
This was the only candidate with restored coverage for both valid geometry and first-draw ordering, and it compiled successfully. Because the app did not survive setup and neither assertion ran, it ranks below candidates without a failing run. The crash root cause is uncertain and no rerun or repair was attempted under the execution contract. |
No candidate passed the required regression command. Accordingly, no failed candidate is ranked above a passing candidate.
Expert review reconciliation
The expert reviewer confirmed the existing MauiBot error at src/Core/src/Platform/Android/ViewExtensions.cs:654: synchronous invocation can expose pre-layout dimensions. Rapid detach/re-attach and cancellation behavior are simpler in the raw PR, but that does not resolve the incompatible size contract. CI/check evidence was pending or unavailable, and the supplied Gate explicitly did not permit approval.
Required changes
Before merge, the submitted PR needs focused Android coverage that proves Loaded completes before the first visible draw and explicitly protects the intended layout-state contract. Any pre-draw/global-layout replacement must also pass that test and preserve exactly-once invocation, cancellation, zero-sized-view behavior, and detach/re-attach cleanup. The current alternatives should not be adopted until their targeted validation completes without an app startup failure.
📱 UI Tests — ViewBaseTests
Detected UI test categories: ViewBaseTests
✅ Deep UI tests — 118 passed, 0 failed, 1 skipped across 1 category on platform-pool agent (replaces in-process counts above).
🧪 UI Test Execution Results (deep, platform pool)
| Category | Tests | Snapshot diffs |
|---|---|---|
ViewBaseTests |
118/119 (1 skipped) ✓ | — |
📎 Download drop-deep-uitests artifact (TRX + snapshot diffs) |
🧭 Next Steps — review latest findings
No alternative fix was selected for this run. Review the session findings and CI results before merging.
…oaded event (#38769) ### Issue details: PR #31590 aimed to fix Android controls not reporting valid size when the `Loaded` event fires. To achieve this, it changed `ViewExtensions.OnLoaded` so that the `Loaded` callback runs inside `view.Post()` instead of executing immediately when `ViewAttachedToWindow` fires, deferring it until after the layout pass completes. After this change merged, the `Loaded` event started firing after the view becomes visible instead of before, which is a behavior change from all prior MAUI versions. This breaks consumers who rely on `Loaded` firing before the view is displayed to run setup logic (e.g., animations, focus, or state initialization) prior to first paint. ### Description of changes: This reverts the changes introduced in PR #31590, which modified `ViewExtensions.cs` on Android to defer the `Loaded` event via `view.Post()`. Reverting restores the prior immediate `action()` invocation on `ViewAttachedToWindow`, fixing the `Loaded` event timing regression (#38360). As a side effect, it also reverts the follow-up fix from PR #34734, which patched a `ViewPager2` detach/re-attach race condition that only existed because of the `Post()`-based deferral introduced by #31590; since that deferral no longer exists, the race condition it patched is no longer applicable. This also removes the `Issue14364` regression tests added by PR #31590. ### Issues Fixed Fixes #38360
…38784) <!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Backports #38769 from `inflight/current` to `inflight/candidate`. - Restores immediate Android `Loaded` callbacks when a view attaches, reverting the `view.Post()` deferral introduced by #31590. - Removes the deferral-specific detach/re-attach workaround from #34734, which is no longer needed. - Removes the `Issue14364` test page and UI test, as in the source PR. The landed commit `c47caea729ac2e9b14e34407f426e6c5c88290e7` was applied without conflicts. The backport is patch-identical to the source commit. ### Issues Fixed Addresses #38360 on `inflight/candidate`, matching #38769. ### Validation - Android Core build succeeded: `dotnet build src/Core/src/Core.csproj -f net10.0-android36.0 -p:TargetFrameworks=net10.0-android36.0` (three Gradle Java 8 obsolescence warnings). - Repository formatting completed, scoped to `src/Core/src/Platform/Android/ViewExtensions.cs`. - Verified matching stable patch IDs and a clean worktree. - Device/UI tests were not run. Co-authored-by: BagavathiPerumal <93652794+BagavathiPerumal@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…oaded event (#38769) ### Issue details: PR #31590 aimed to fix Android controls not reporting valid size when the `Loaded` event fires. To achieve this, it changed `ViewExtensions.OnLoaded` so that the `Loaded` callback runs inside `view.Post()` instead of executing immediately when `ViewAttachedToWindow` fires, deferring it until after the layout pass completes. After this change merged, the `Loaded` event started firing after the view becomes visible instead of before, which is a behavior change from all prior MAUI versions. This breaks consumers who rely on `Loaded` firing before the view is displayed to run setup logic (e.g., animations, focus, or state initialization) prior to first paint. ### Description of changes: This reverts the changes introduced in PR #31590, which modified `ViewExtensions.cs` on Android to defer the `Loaded` event via `view.Post()`. Reverting restores the prior immediate `action()` invocation on `ViewAttachedToWindow`, fixing the `Loaded` event timing regression (#38360). As a side effect, it also reverts the follow-up fix from PR #34734, which patched a `ViewPager2` detach/re-attach race condition that only existed because of the `Post()`-based deferral introduced by #31590; since that deferral no longer exists, the race condition it patched is no longer applicable. This also removes the `Issue14364` regression tests added by PR #31590. ### Issues Fixed Fixes #38360
…38784) <!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Backports #38769 from `inflight/current` to `inflight/candidate`. - Restores immediate Android `Loaded` callbacks when a view attaches, reverting the `view.Post()` deferral introduced by #31590. - Removes the deferral-specific detach/re-attach workaround from #34734, which is no longer needed. - Removes the `Issue14364` test page and UI test, as in the source PR. The landed commit `c47caea729ac2e9b14e34407f426e6c5c88290e7` was applied without conflicts. The backport is patch-identical to the source commit. ### Issues Fixed Addresses #38360 on `inflight/candidate`, matching #38769. ### Validation - Android Core build succeeded: `dotnet build src/Core/src/Core.csproj -f net10.0-android36.0 -p:TargetFrameworks=net10.0-android36.0` (three Gradle Java 8 obsolescence warnings). - Repository formatting completed, scoped to `src/Core/src/Platform/Android/ViewExtensions.cs`. - Verified matching stable patch IDs and a clean worktree. - Device/UI tests were not run. Co-authored-by: BagavathiPerumal <93652794+BagavathiPerumal@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…oaded event (#38769) ### Issue details: PR #31590 aimed to fix Android controls not reporting valid size when the `Loaded` event fires. To achieve this, it changed `ViewExtensions.OnLoaded` so that the `Loaded` callback runs inside `view.Post()` instead of executing immediately when `ViewAttachedToWindow` fires, deferring it until after the layout pass completes. After this change merged, the `Loaded` event started firing after the view becomes visible instead of before, which is a behavior change from all prior MAUI versions. This breaks consumers who rely on `Loaded` firing before the view is displayed to run setup logic (e.g., animations, focus, or state initialization) prior to first paint. ### Description of changes: This reverts the changes introduced in PR #31590, which modified `ViewExtensions.cs` on Android to defer the `Loaded` event via `view.Post()`. Reverting restores the prior immediate `action()` invocation on `ViewAttachedToWindow`, fixing the `Loaded` event timing regression (#38360). As a side effect, it also reverts the follow-up fix from PR #34734, which patched a `ViewPager2` detach/re-attach race condition that only existed because of the `Post()`-based deferral introduced by #31590; since that deferral no longer exists, the race condition it patched is no longer applicable. This also removes the `Issue14364` regression tests added by PR #31590. ### Issues Fixed Fixes #38360
…38784) <!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Backports #38769 from `inflight/current` to `inflight/candidate`. - Restores immediate Android `Loaded` callbacks when a view attaches, reverting the `view.Post()` deferral introduced by #31590. - Removes the deferral-specific detach/re-attach workaround from #34734, which is no longer needed. - Removes the `Issue14364` test page and UI test, as in the source PR. The landed commit `c47caea729ac2e9b14e34407f426e6c5c88290e7` was applied without conflicts. The backport is patch-identical to the source commit. ### Issues Fixed Addresses #38360 on `inflight/candidate`, matching #38769. ### Validation - Android Core build succeeded: `dotnet build src/Core/src/Core.csproj -f net10.0-android36.0 -p:TargetFrameworks=net10.0-android36.0` (three Gradle Java 8 obsolescence warnings). - Repository formatting completed, scoped to `src/Core/src/Platform/Android/ViewExtensions.cs`. - Verified matching stable patch IDs and a clean worktree. - Device/UI tests were not run. Co-authored-by: BagavathiPerumal <93652794+BagavathiPerumal@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…oaded event (#38769) ### Issue details: PR #31590 aimed to fix Android controls not reporting valid size when the `Loaded` event fires. To achieve this, it changed `ViewExtensions.OnLoaded` so that the `Loaded` callback runs inside `view.Post()` instead of executing immediately when `ViewAttachedToWindow` fires, deferring it until after the layout pass completes. After this change merged, the `Loaded` event started firing after the view becomes visible instead of before, which is a behavior change from all prior MAUI versions. This breaks consumers who rely on `Loaded` firing before the view is displayed to run setup logic (e.g., animations, focus, or state initialization) prior to first paint. ### Description of changes: This reverts the changes introduced in PR #31590, which modified `ViewExtensions.cs` on Android to defer the `Loaded` event via `view.Post()`. Reverting restores the prior immediate `action()` invocation on `ViewAttachedToWindow`, fixing the `Loaded` event timing regression (#38360). As a side effect, it also reverts the follow-up fix from PR #34734, which patched a `ViewPager2` detach/re-attach race condition that only existed because of the `Post()`-based deferral introduced by #31590; since that deferral no longer exists, the race condition it patched is no longer applicable. This also removes the `Issue14364` regression tests added by PR #31590. ### Issues Fixed Fixes #38360
…38784) <!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Backports #38769 from `inflight/current` to `inflight/candidate`. - Restores immediate Android `Loaded` callbacks when a view attaches, reverting the `view.Post()` deferral introduced by #31590. - Removes the deferral-specific detach/re-attach workaround from #34734, which is no longer needed. - Removes the `Issue14364` test page and UI test, as in the source PR. The landed commit `c47caea729ac2e9b14e34407f426e6c5c88290e7` was applied without conflicts. The backport is patch-identical to the source commit. ### Issues Fixed Addresses #38360 on `inflight/candidate`, matching #38769. ### Validation - Android Core build succeeded: `dotnet build src/Core/src/Core.csproj -f net10.0-android36.0 -p:TargetFrameworks=net10.0-android36.0` (three Gradle Java 8 obsolescence warnings). - Repository formatting completed, scoped to `src/Core/src/Platform/Android/ViewExtensions.cs`. - Verified matching stable patch IDs and a clean worktree. - Device/UI tests were not run. Co-authored-by: BagavathiPerumal <93652794+BagavathiPerumal@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…oaded event (#38769) ### Issue details: PR #31590 aimed to fix Android controls not reporting valid size when the `Loaded` event fires. To achieve this, it changed `ViewExtensions.OnLoaded` so that the `Loaded` callback runs inside `view.Post()` instead of executing immediately when `ViewAttachedToWindow` fires, deferring it until after the layout pass completes. After this change merged, the `Loaded` event started firing after the view becomes visible instead of before, which is a behavior change from all prior MAUI versions. This breaks consumers who rely on `Loaded` firing before the view is displayed to run setup logic (e.g., animations, focus, or state initialization) prior to first paint. ### Description of changes: This reverts the changes introduced in PR #31590, which modified `ViewExtensions.cs` on Android to defer the `Loaded` event via `view.Post()`. Reverting restores the prior immediate `action()` invocation on `ViewAttachedToWindow`, fixing the `Loaded` event timing regression (#38360). As a side effect, it also reverts the follow-up fix from PR #34734, which patched a `ViewPager2` detach/re-attach race condition that only existed because of the `Post()`-based deferral introduced by #31590; since that deferral no longer exists, the race condition it patched is no longer applicable. This also removes the `Issue14364` regression tests added by PR #31590. ### Issues Fixed Fixes #38360
…38784) <!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Backports #38769 from `inflight/current` to `inflight/candidate`. - Restores immediate Android `Loaded` callbacks when a view attaches, reverting the `view.Post()` deferral introduced by #31590. - Removes the deferral-specific detach/re-attach workaround from #34734, which is no longer needed. - Removes the `Issue14364` test page and UI test, as in the source PR. The landed commit `c47caea729ac2e9b14e34407f426e6c5c88290e7` was applied without conflicts. The backport is patch-identical to the source commit. ### Issues Fixed Addresses #38360 on `inflight/candidate`, matching #38769. ### Validation - Android Core build succeeded: `dotnet build src/Core/src/Core.csproj -f net10.0-android36.0 -p:TargetFrameworks=net10.0-android36.0` (three Gradle Java 8 obsolescence warnings). - Repository formatting completed, scoped to `src/Core/src/Platform/Android/ViewExtensions.cs`. - Verified matching stable patch IDs and a clean worktree. - Device/UI tests were not run. Co-authored-by: BagavathiPerumal <93652794+BagavathiPerumal@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…oaded event (#38769) ### Issue details: PR #31590 aimed to fix Android controls not reporting valid size when the `Loaded` event fires. To achieve this, it changed `ViewExtensions.OnLoaded` so that the `Loaded` callback runs inside `view.Post()` instead of executing immediately when `ViewAttachedToWindow` fires, deferring it until after the layout pass completes. After this change merged, the `Loaded` event started firing after the view becomes visible instead of before, which is a behavior change from all prior MAUI versions. This breaks consumers who rely on `Loaded` firing before the view is displayed to run setup logic (e.g., animations, focus, or state initialization) prior to first paint. ### Description of changes: This reverts the changes introduced in PR #31590, which modified `ViewExtensions.cs` on Android to defer the `Loaded` event via `view.Post()`. Reverting restores the prior immediate `action()` invocation on `ViewAttachedToWindow`, fixing the `Loaded` event timing regression (#38360). As a side effect, it also reverts the follow-up fix from PR #34734, which patched a `ViewPager2` detach/re-attach race condition that only existed because of the `Post()`-based deferral introduced by #31590; since that deferral no longer exists, the race condition it patched is no longer applicable. This also removes the `Issue14364` regression tests added by PR #31590. ### Issues Fixed Fixes #38360
…38784) <!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Backports #38769 from `inflight/current` to `inflight/candidate`. - Restores immediate Android `Loaded` callbacks when a view attaches, reverting the `view.Post()` deferral introduced by #31590. - Removes the deferral-specific detach/re-attach workaround from #34734, which is no longer needed. - Removes the `Issue14364` test page and UI test, as in the source PR. The landed commit `c47caea729ac2e9b14e34407f426e6c5c88290e7` was applied without conflicts. The backport is patch-identical to the source commit. ### Issues Fixed Addresses #38360 on `inflight/candidate`, matching #38769. ### Validation - Android Core build succeeded: `dotnet build src/Core/src/Core.csproj -f net10.0-android36.0 -p:TargetFrameworks=net10.0-android36.0` (three Gradle Java 8 obsolescence warnings). - Repository formatting completed, scoped to `src/Core/src/Platform/Android/ViewExtensions.cs`. - Verified matching stable patch IDs and a clean worktree. - Device/UI tests were not run. Co-authored-by: BagavathiPerumal <93652794+BagavathiPerumal@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Issue details:
PR #31590 aimed to fix Android controls not reporting valid size when the
Loadedevent fires. To achieve this, it changedViewExtensions.OnLoadedso that theLoadedcallback runs insideview.Post()instead of executing immediately whenViewAttachedToWindowfires, deferring it until after the layout pass completes.After this change merged, the
Loadedevent started firing after the view becomes visible instead of before, which is a behavior change from all prior MAUI versions. This breaks consumers who rely onLoadedfiring before the view is displayed to run setup logic (e.g., animations, focus, or state initialization) prior to first paint.Description of changes:
This reverts the changes introduced in PR #31590, which modified
ViewExtensions.cson Android to defer theLoadedevent viaview.Post().Reverting restores the prior immediate
action()invocation onViewAttachedToWindow, fixing theLoadedevent timing regression (#38360). As a side effect, it also reverts the follow-up fix from PR #34734, which patched aViewPager2detach/re-attach race condition that only existed because of thePost()-based deferral introduced by #31590; since that deferral no longer exists, the race condition it patched is no longer applicable.This also removes the
Issue14364regression tests added by PR #31590.Issues Fixed
Fixes #38360