Repository navigation
[iOS] Fix ScrollView introduces flickering in bottom sheets with .NET 10 - #39219
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39219Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 39219" |
|
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.
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
Note 🔍
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Note 🔍
|
There was a problem hiding this comment.
🟡 Changes recommended
Automatic sheet presentations are not detected, and the new behavior lacks regression tests.
2 open findings
What changed in this PR
Updates iOS/MacCatalyst MauiScrollView behavior to avoid content-size inflation within page sheets.
Changes:
- Detects and caches page-sheet containment.
- Skips the
Bounds + 1workaround inside detected sheets.
| File | Description |
|---|---|
src/Core/src/Platform/iOS/MauiScrollView.cs |
Adjusts sheet-specific scroll layout behavior. |
🧠 Review effort: Balanced
| if (responder is UIViewController { ModalPresentationStyle: UIModalPresentationStyle.PageSheet }) | ||
| { | ||
| _isInsidePageSheet = true; | ||
| return true; | ||
| } |
| // ensuring the scroll view remains in "scrollable mode" and keeps safe area insets at the scroll view level. | ||
| // This avoids inset flip-flopping and keeps layout behavior stable and predictable. | ||
| if (ContentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentBehavior.Automatic) | ||
| if (ContentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentBehavior.Automatic && !IsInsidePageSheet()) |
This comment has been minimized.
This comment has been minimized.
|
Note 🔍
|
MauiBot
left a comment
There was a problem hiding this comment.
AI Review Summary
@Dhivya-SF4094 — new AI review results are available based on commit
1df0c54.
🗂️ 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
Pre-Flight Context
Scope and provenance
- PR #39219 is open against
main, with immutable base84b1fb39ad56e22a51d29d4bbf141b03b02e4648and submitted head1df0c5483c2d0a53ae7f53b306ee814b34b7a7fd. - The submitted diff changes one file:
src/Core/src/Platform/iOS/MauiScrollView.cs(+31/-3). - This context comes from the submitted diff, exact base/head source, #38272, nearby tests/samples, and PR discussion. No files were edited and no commands or tests were run.
- This is context gathering, not an exhaustive code review or recommendation.
Reported problem
Linked issue #38272 reports an iOS regression beginning with .NET 10 Preview 7 and reproduced through 10.0.100; 9.0.120 reportedly works.
The reported flicker occurs when:
- A native bottom sheet is near a medium/half-height detent.
- Its content is wrapped in a
ScrollView. - The user drags on the sheet content across its resting detent.
- The content is too short to scroll normally.
The issue reports that dragging the native handle does not flicker, sufficiently long/scrollable content does not flicker, and both a MAUI ScrollView and a native UIScrollView wrapper can reproduce it when their child content is MAUI-based. The public issue originally referenced a private reproduction; a later comment attached ScrollViewIssue.zip, but that attachment and the videos were not independently inspected.
The PR description attributes the behavior to a feedback loop between MAUI’s automatic safe-area content-size stabilization, UIKit’s changing AdjustedContentInset, and repeated layout while the sheet is interactively resized. That causal explanation remains author-reported rather than independently validated here.
Changed mechanism
MauiScrollView.CrossPlatformArrange currently contains an iOS safe-area workaround for ContentInsetAdjustmentBehavior.Automatic. When arranged content is near the visible bounds, it artificially enlarges ContentSize to keep UIKit treating the view as scrollable and prevent adjusted-inset state from flipping.
The submitted change:
- Adds nullable cache
_isInsidePageSheet. - Adds
IsInsidePageSheet(), which walksNextResponderfrom the scroll view and returns true when it encounters aUIViewControllerwhoseModalPresentationStyleis exactlyUIModalPresentationStyle.PageSheet. - Changes the automatic-inset workaround condition to run only when
!IsInsidePageSheet(). Thus both horizontal and vertical artificial content-size adjustments are bypassed for a detected page sheet. - Clears the new cache in
MovedToWindow(), alongside existing hierarchy/safe-area caches. - Leaves the preceding safe-area arrangement and measurement logic intact, as well as the non-automatic inset branch.
- Includes a nonfunctional indentation adjustment to two XML-documentation lines.
The detection caches both positive and negative results, avoiding responder traversal on each layout pass.
Platform-sensitive paths
- The modified file is UIKit-specific and contains explicit iOS/MacCatalyst behavior. The requested validation platform is iOS.
- The behavior is in a layout/safe-area hot path and can affect
ContentSize, scrollability, adjusted insets, clipping, and repeated layout. - The branch only applies when
ContentInsetAdjustmentBehaviorisAutomatic; non-automatic behavior is unchanged. - The implementation recognizes an explicitly assigned
.PageSheetpresentation style. It does not directly inspectSheetPresentationControlleror other effective sheet presentations. - Nearby repository sample
Issue32983configuresviewControllerToPresent.SheetPresentationControllerand custom detents without assigningModalPresentationStyle. That sample is separate from #38272, but demonstrates an existing UIKit sheet path in which the submitted detector may cachefalse. - Existing
Issue32983UI coverage is iOS-only; its source notes that MacCatalyst ignores the custom detents and presents full height. - The issue reports reproduction with a native
UIScrollViewas well asMauiScrollView, while this PR directly changes onlyMauiScrollView; how the native-wrapper case is addressed is not established by the submitted source.
Validation context and requirements
Gate:
Earlier automated PR comments report 112 existing ViewBaseTests passing, but those runs contain no submitted regression test for this behavior and do not establish that the flicker path was exercised. Later maui-pr-uitests and maui-pr-devicetests runs were requested; their final results are unknown from the inspected context.
Relevant validation should cover:
- An iOS regression scenario matching #38272: medium detent, short MAUI content, dragging on content across the detent, with visible flicker assessed before and after the change.
- Explicit
.PageSheetand UIKit’s effective/default sheet presentation usingSheetPresentationControllerwith no explicit modal style. - Both the MAUI
ScrollViewand nativeUIScrollViewwrapper configurations reported by the issue. - Negative controls: dragging by the native handle, sufficiently scrollable content, and a non-sheet
ScrollView. - Focused iOS device tests around
MauiScrollView.ContentSize: a detected sheet should not receive the artificial bounds inflation, while a non-sheet using automatic adjustment should retain existing behavior.src/Core/tests/DeviceTests/Handlers/ScrollView/ScrollViewHandlerTests.iOS.csalready contains basicContentSizecoverage. - Safe-area behavior after bypassing the workaround, including absence of clipped/off-screen content and stable scrollability.
- Cache lifecycle when the view is attached, removed, reparented between sheet and non-sheet controllers, or when presentation configuration changes without an obvious window transition.
- At least build/smoke consideration for MacCatalyst because the shared UIKit source is compiled there, while acknowledging that the issue and required functional validation are iOS-specific.
Remaining uncertainties
- Whether #38272’s actual controller has explicit
.PageSheet, default.Automatic, or another effective sheet style is unknown from the inspected issue text. - An unresolved PR review thread raises the automatic-sheet detection gap; repository source confirms such a presentation pattern exists, but its relevance to the attached #38272 reproduction remains unknown.
- It is unknown whether
MovedToWindow()invalidation covers every hierarchy or presentation-style transition that can make a cached result stale, particularly a cachedfalseobtained before full controller attachment. - It is unknown whether bypassing both horizontal and vertical inflation is required for the reported vertical flicker or has additional safe-area consequences.
- The claimed content-size/inset feedback loop has not been corroborated with layout traces or instrumentation.
- No submitted test proves failure without the change and success with it.
- Current CI completion, attached-reproduction behavior, device/iOS-version coverage, and the separate expert review outcome are unknown.
🔬 Code Review — Deep Analysis
Code Review — PR #39219
Independent Assessment
What this changes: The submitted iOS implementation adds a cached responder-chain check for an ancestor UIViewController whose ModalPresentationStyle is PageSheet. MauiScrollView.CrossPlatformArrange then skips its automatic-inset content-size inflation for such a sheet while retaining the existing safe-area arrangement paths.
Inferred motivation: The bypass is intended to prevent the artificial Bounds + 1 content extent from changing UIKit's scrollability and AdjustedContentInset state while a page sheet is interactively resized.
Reconciliation with PR Narrative
Author claims: The flicker is a feedback loop between MAUI's automatic-inset stabilization and UIKit's dynamic adjusted insets during page-sheet detent resizing, and the change bypasses only the artificial inflation in that context.
Agreement/disagreement: The submitted diff implements that stated mechanism. The source does not independently prove the reported feedback loop, that the reproduction's controller has an explicit PageSheet style, or that bypassing both axes is required.
Prior Review Reconciliation
No prior ❌ Error findings were established by the trusted context. An existing discussion concern about effective sheets whose controller retains ModalPresentationStyle.Automatic remains unresolved, but the single expert pass did not validate it as a source-line defect.
Blast Radius Assessment
- Runs for all instances: Every
MauiScrollViewusing automatic inset adjustment calls the new detector; the responder chain is walked once and the result is cached. Behavior changes only when an explicitPageSheetcontroller is found. - Startup impact: No; this runs during
CrossPlatformArrange. - Static/shared state: No; the nullable cache is per scroll view.
- Platform scope: The file compiles for iOS and MacCatalyst. The reported behavior and requested validation are iOS-specific.
CI Status
- Required-check result: Unknown from the trusted context.
- Gate result:
⚠️ SKIPPED — no tests detected in the submitted PR. - Classification: Validation coverage is undetermined. Existing test runs do not exercise the submitted page-sheet regression.
- Action taken: Gate was not rerun, as required; confidence is capped at low.
Findings
The single maui-expert-reviewer pass produced no validated inline findings; inline-findings.json is [].
⚠️ Warning — Submitted behavior has no regression validation
No submitted test demonstrates the failing short-content page-sheet path, verifies that the artificial content-size inflation is omitted for the target presentation, or preserves the existing non-sheet behavior. The trusted Gate therefore skipped rather than validating the fix.
Failure-Mode Probing
- Effective/default sheet presentation: Repository source demonstrates
SheetPresentationControllerconfiguration without explicitly assigningModalPresentationStyle.PageSheet. The submitted detector checks only the explicit enum value, so coverage of UIKit's effective.Automaticsheet path remains unknown rather than proven correct or incorrect for #38272. - Cache lifecycle:
_isInsidePageSheetis cleared inMovedToWindow, which covers attachment/removal and window moves. The evidence does not establish whether controller/presentation changes can occur while the view remains in the same window, so stale negative caching remains an unverified risk. - Non-sheet behavior: The existing inflation remains unchanged when no explicit page-sheet controller is found.
- Axis behavior: A detected sheet bypasses both horizontal and vertical inflation. No submitted regression test establishes the adjacent horizontal-safe-area behavior.
External Output Contract
Not applicable.
Verdict: NEEDS_DISCUSSION
Confidence: low
Summary: The expert dimension pass found no concrete blocking source defect, so there is no evidence-backed basis for a reviewer refinement. Approval is still unsupported because the trusted Gate skipped, the fix has no submitted regression test, and key presentation/cache scenarios remain unvalidated.
Refinement Decision
Not generated. The expert findings did not identify a concrete actionable defect or source/test-backed unresolved mechanism that meets the evidence-first refinement threshold.
🛠️ 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.
📝 PR Finalize — Recommended Title & Description
Assessment: ✏️ Recommend updating — the current title is grammatically unclear and does not follow the [Platform] Component: What changed form, while the otherwise strong description has a typo and can name the submitted implementation more precisely.
Recommended title
[iOS] ScrollView: Prevent PageSheet flicker during detent resizing
Recommended description
### Issue detail
On iOS, a `ScrollView` inside a `PageSheet` flickers when the sheet is interactively resized between detents.
### Root cause
- The flicker is caused by the interaction between MAUI's automatic safe-area stabilization logic and UIKit's dynamic `AdjustedContentInset` handling during an interactive `PageSheet` resize.
- When the `PageSheet` is dragged, the `ScrollView` bounds continuously change. MAUI's existing automatic-inset workaround can increase the content size to slightly exceed the bounds, causing UIKit to change its scrollability and `AdjustedContentInset` state. That inset change triggers another MAUI layout pass, which can change the content size again. This creates a repeated content-size → adjusted-inset → layout feedback loop, resulting in visible flickering.
### Description of Change
- Update `MauiScrollView.CrossPlatformArrange` to skip the automatic content-size inflation workaround for scroll views hosted inside a `UIViewController` whose `ModalPresentationStyle` is `UIModalPresentationStyle.PageSheet`.
- Add `IsInsidePageSheet` to detect that host through the responder chain.
- Cache the page-sheet detection result and clear it from `MovedToWindow`, avoiding repeated responder-chain traversal during layout passes while allowing the result to be recomputed when the view hierarchy moves to a window.
- Preserve the existing safe-area arrangement and measurement logic. Only the artificial bounds-plus-one content-size adjustment is bypassed for a detected `PageSheet`.
### Validated the behaviour in the following platforms
- [ ] Android
- [ ] Windows
- [x] iOS
- [ ] Mac
### Issues Fixed
Fixes #38272
### Screenshots
| Before | After |
|---|---|
| <video src="https://github.com/user-attachments/assets/2f807cf2-548c-4333-8d95-436c062fa18f"> | <video src="https://github.com/user-attachments/assets/6fb7b0f0-7f57-4266-94ad-e0c25b3968e2"> |
🏁 Report — Final Recommendation
⚠️ Final Recommendation: REQUEST CHANGES
Phase Status
| Phase | Status | Notes |
|---|---|---|
| Pre-Flight | ✅ COMPLETE | Trusted evidence-first context consumed |
| Code Review | NEEDS_DISCUSSION (low) | 0 validated inline errors; 1 validation warning |
| Gate | No tests detected in the submitted PR | |
| Try-Fix | not requested | Intentional evidence-first omission; no alternative candidates generated |
| Refinement | Not generated | Expert findings did not meet the evidence-backed refinement threshold |
| Report | ✅ COMPLETE |
Code Review and Candidate Comparison
| Candidate | Implementation | Validation | Expert Findings | Rank |
|---|---|---|---|---|
pr |
Submitted fix; skips automatic content-size inflation for an explicitly detected PageSheet |
Gate skipped; no submitted regression test | No validated inline findings; effective-sheet and cache-lifecycle coverage remain uncertain | 1 |
pr is the only real candidate and therefore wins the comparison. No pr-plus-reviewer candidate was implemented, and routine Try-Fix alternatives were intentionally not requested. Winning a one-candidate comparison does not make the submitted change merge-ready: the trusted Gate did not validate the target behavior or adjacent non-sheet behavior.
Summary
The submitted implementation is localized, preserves the existing non-sheet path, and caches its responder-chain lookup in the layout hot path. The single expert dimension review produced no validated inline findings. However, approval is vetoed by the skipped Gate and low-confidence evidence: there is no submitted regression test for the reported iOS page-sheet resize flicker, and the trusted context leaves UIKit's effective .Automatic sheet presentation and cache invalidation scenarios unverified.
Root Cause
The PR attributes the flicker to a feedback loop in which MAUI's automatic safe-area stabilization inflates ContentSize, UIKit changes scrollability and AdjustedContentInset while a page sheet is resized between detents, and those inset changes trigger repeated layout. The diff is consistent with that theory, but the mechanism has not been independently demonstrated by traces or a failing-then-passing regression test.
Fix Quality
The implementation changes one iOS/MacCatalyst platform file, bypasses only the automatic-inset inflation branch for a detected explicit PageSheet, and invalidates its per-instance cache from MovedToWindow. Those are appropriately scoped choices, and no concrete source defect was validated. Before approval, the submitted fix needs focused iOS regression evidence covering the reported short-content detent-resize scenario and a negative non-sheet control; coverage should also establish whether the target presentation uses explicit .PageSheet or UIKit's effective .Automatic sheet path.
Selected Fix: PR — sole implemented candidate; no evidence-backed reviewer refinement was warranted.
🔗 Regression Cross-Reference
🔍 Regression Cross-Reference
⚠ Overlaps with prior bug-fix PRs — same files modified, but no exact line revert detected.
| File | Fix PR | Fixed issue(s) |
|---|---|---|
src/Core/src/Platform/iOS/MauiScrollView.cs |
#35234 | #7580, #9095, #11402, #12916, #13243, #13801, #15806, #19560, #19690, #19866, #20028, #26103, #26366, #27554, #29529, #29772, #30192, #30199, #30254, #31658, #31799, #32971, #33065, #33241, #33334, #33373, #33500, #33615, #33767, #33783, #34101, #34257, #34266, #34402, #34504, #34551, #34611, #34662, #34671, #34716, #34755, #34759, #34771, #34772, #34842, #34846, #34848, #34861, #34889, #34892, #34897, #34898, #34900, #34917, #34925, #34953, #34975, #35005, #35018, #35063, #35116, #35119, #35125, #35127 |
📱 UI Tests — ViewBaseTests
Detected UI test categories: ViewBaseTests
✅ Deep UI tests — 112 passed, 0 failed across 1 category on platform-pool agent (replaces in-process counts above).
🧪 UI Test Execution Results (deep, platform pool)
| Category | Tests | Snapshot diffs |
|---|---|---|
ViewBaseTests |
112/112 ✓ | — |
📎 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.
This comment has been minimized.
This comment has been minimized.
Performance Review Summary
Performance ResultsVerdict: 🟢 No performance blocker found; coverage incomplete The pinned diff adds a cached PageSheet responder-chain check to the native scroll-view content-size path; static inspection identifies no concrete hot-path performance regression. The selector classifies src/Core/src/Platform/iOS/MauiScrollView.cs as static-only, with no direct or sampled managed suite and no selected device scenario; no run manifest, comparison summary, or measurement table was supplied. 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: 1; directly managed-measured: 0; device-required: 0; static-reviewed: 1. Sampled subsets: managed 0, device 0. Findings & Follow-upStatic hot-path reviewIn src/Core/src/Platform/iOS/MauiScrollView.cs:638, the new check is short-circuited unless ContentInsetAdjustmentBehavior is Automatic. At lines 705-727, IsInsidePageSheet walks NextResponder only when its nullable Boolean cache is unset, then returns the cached result on subsequent calls; line 901 resets that cache in MovedToWindow. This adds a cold-cache responder traversal, but the changed code contains no new repeated enumeration, captured closure, formatting, or explicit per-layout managed allocation. Skipping the existing content-size inflation for PageSheet changes native layout behavior, whose actual layout frequency, bridge costs, and correctness are not measured here. No concrete static hot-path performance concern was identified; this is not empirical clearance of the native path. Recommended next action
The deterministic baseline calls for no performance action because static inspection supplies no concrete optimization concern, not because measurements passed. There are no selected managed benchmarks and no measured results to interpret; the absence of a run manifest prevents execution and revision-match verification. Native coverage remains absent, and rerunning managed library benchmarks cannot exercise UIKit responder traversal or PageSheet layout. Any decision requiring native performance or correctness assurance needs human discussion and device evidence outside this workflow; no follow-up device run is selected or scheduled here.
|
|
/backport to inflight/candidate |
|
Started backporting to |
<!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Backport of #39219 to `inflight/candidate`, intentionally targeting the SR12 staging branch rather than `main`. Fixes the documented ScrollView bottom-sheet flicker regression introduced in .NET 10 Preview 7. Avoids artificial content-size inflation inside a PageSheet while preserving the existing behavior for other presentations. PageSheet controller detection is cached and reset when the scroll view changes windows. Exactly the original `MauiScrollView.cs` change is carried; no dependencies, SDK pins or unrelated fixes are included. Source merge: `c6ad18ac7d6a89b806377f4490f5998527e7f2a7`. Backport head: `b4daa1a7581c7532856d31de55a3555219c967ad`. **Validation** - `git diff --binary 3d96e23 b4daa1a | git patch-id --stable` — passed: complete source patch identity matches `ede509d67f5c128501ef292da125bf98dc814db4`. - `git diff --check 3d96e23 b4daa1a` — passed. - The source PR contains no dedicated regression test. Local builds and native/runtime tests were not rerun for this unchanged automated replay. PR-head CI and runtime verification are pending; this is not a merge-readiness verdict. No XCTest, Appium, simulator/emulator or GUI execution was performed. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #38272 in the SR12 Candidate selection. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> /cc @kubaflo @Dhivya-SF4094 Co-authored-by: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com>
… 10 (#39219) <!-- 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! ### Issue detail On iOS, a ScrollView inside a PageSheet flickers when the sheet is interactively resized between detents. ### Root cause - The flicker is caused by the interaction between MAUI's automatic safe-area stabilization logic and UIKit's dynamic AdjustedContentInset handling during an interactive PageSheet resize. - When the PageSheet is dragged, the ScrollView bounds continuously change. MAUI's existing automatic-inset workaround can increase the content size to slightly exceed the bounds, causing UIKit to change its scrollability and AdjustedContentInset state. That inset change triggers another MAUI layout pass, which can change the content size again. This creates a repeated content-size → adjusted-inset → layout feedback loop, resulting in visible flickering. ### Description of Change - Skip the automatic content-size inflation workaround for ScrollViews hosted inside a PageSheet. - The fix detects whether the ScrollView is hosted in a UIViewController whose ModalPresentationStyle is PageSheetand bypasses only the artificial Bounds + 1 adjustment in that scenario. - The PageSheet detection result is cached and reset when the view moves to a different window, avoiding repeated responder-chain traversal during layout passes. - Importantly, this doesn't disable safe-area handling. The existing logic for handling the actual safe-area size is still preserved. Only the artificial Bounds + 1 adjustment is skipped for PageSheet. ### Validated the behaviour in the following platforms - [ ] Android - [ ] Windows - [x] iOS - [ ] Mac ### Issues Fixed: Fixes #38272 ### Screenshots | Before | After | |---------|--------| | <video src="https://github.com/user-attachments/assets/2f807cf2-548c-4333-8d95-436c062fa18f"> | <video src="https://github.com/user-attachments/assets/6fb7b0f0-7f57-4266-94ad-e0c25b3968e2"> |
<!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Backport of #39219 to `inflight/candidate`, intentionally targeting the SR12 staging branch rather than `main`. Fixes the documented ScrollView bottom-sheet flicker regression introduced in .NET 10 Preview 7. Avoids artificial content-size inflation inside a PageSheet while preserving the existing behavior for other presentations. PageSheet controller detection is cached and reset when the scroll view changes windows. Exactly the original `MauiScrollView.cs` change is carried; no dependencies, SDK pins or unrelated fixes are included. Source merge: `c6ad18ac7d6a89b806377f4490f5998527e7f2a7`. Backport head: `b4daa1a7581c7532856d31de55a3555219c967ad`. **Validation** - `git diff --binary 3d96e23 b4daa1a | git patch-id --stable` — passed: complete source patch identity matches `ede509d67f5c128501ef292da125bf98dc814db4`. - `git diff --check 3d96e23 b4daa1a` — passed. - The source PR contains no dedicated regression test. Local builds and native/runtime tests were not rerun for this unchanged automated replay. PR-head CI and runtime verification are pending; this is not a merge-readiness verdict. No XCTest, Appium, simulator/emulator or GUI execution was performed. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #38272 in the SR12 Candidate selection. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> /cc @kubaflo @Dhivya-SF4094 Co-authored-by: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com>
… 10 (#39219) <!-- 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! ### Issue detail On iOS, a ScrollView inside a PageSheet flickers when the sheet is interactively resized between detents. ### Root cause - The flicker is caused by the interaction between MAUI's automatic safe-area stabilization logic and UIKit's dynamic AdjustedContentInset handling during an interactive PageSheet resize. - When the PageSheet is dragged, the ScrollView bounds continuously change. MAUI's existing automatic-inset workaround can increase the content size to slightly exceed the bounds, causing UIKit to change its scrollability and AdjustedContentInset state. That inset change triggers another MAUI layout pass, which can change the content size again. This creates a repeated content-size → adjusted-inset → layout feedback loop, resulting in visible flickering. ### Description of Change - Skip the automatic content-size inflation workaround for ScrollViews hosted inside a PageSheet. - The fix detects whether the ScrollView is hosted in a UIViewController whose ModalPresentationStyle is PageSheetand bypasses only the artificial Bounds + 1 adjustment in that scenario. - The PageSheet detection result is cached and reset when the view moves to a different window, avoiding repeated responder-chain traversal during layout passes. - Importantly, this doesn't disable safe-area handling. The existing logic for handling the actual safe-area size is still preserved. Only the artificial Bounds + 1 adjustment is skipped for PageSheet. ### Validated the behaviour in the following platforms - [ ] Android - [ ] Windows - [x] iOS - [ ] Mac ### Issues Fixed: Fixes #38272 ### Screenshots | Before | After | |---------|--------| | <video src="https://github.com/user-attachments/assets/2f807cf2-548c-4333-8d95-436c062fa18f"> | <video src="https://github.com/user-attachments/assets/6fb7b0f0-7f57-4266-94ad-e0c25b3968e2"> |
<!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Backport of #39219 to `inflight/candidate`, intentionally targeting the SR12 staging branch rather than `main`. Fixes the documented ScrollView bottom-sheet flicker regression introduced in .NET 10 Preview 7. Avoids artificial content-size inflation inside a PageSheet while preserving the existing behavior for other presentations. PageSheet controller detection is cached and reset when the scroll view changes windows. Exactly the original `MauiScrollView.cs` change is carried; no dependencies, SDK pins or unrelated fixes are included. Source merge: `c6ad18ac7d6a89b806377f4490f5998527e7f2a7`. Backport head: `b4daa1a7581c7532856d31de55a3555219c967ad`. **Validation** - `git diff --binary 3d96e23 b4daa1a | git patch-id --stable` — passed: complete source patch identity matches `ede509d67f5c128501ef292da125bf98dc814db4`. - `git diff --check 3d96e23 b4daa1a` — passed. - The source PR contains no dedicated regression test. Local builds and native/runtime tests were not rerun for this unchanged automated replay. PR-head CI and runtime verification are pending; this is not a merge-readiness verdict. No XCTest, Appium, simulator/emulator or GUI execution was performed. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #38272 in the SR12 Candidate selection. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> /cc @kubaflo @Dhivya-SF4094 Co-authored-by: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com>
… 10 (#39219) <!-- 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! ### Issue detail On iOS, a ScrollView inside a PageSheet flickers when the sheet is interactively resized between detents. ### Root cause - The flicker is caused by the interaction between MAUI's automatic safe-area stabilization logic and UIKit's dynamic AdjustedContentInset handling during an interactive PageSheet resize. - When the PageSheet is dragged, the ScrollView bounds continuously change. MAUI's existing automatic-inset workaround can increase the content size to slightly exceed the bounds, causing UIKit to change its scrollability and AdjustedContentInset state. That inset change triggers another MAUI layout pass, which can change the content size again. This creates a repeated content-size → adjusted-inset → layout feedback loop, resulting in visible flickering. ### Description of Change - Skip the automatic content-size inflation workaround for ScrollViews hosted inside a PageSheet. - The fix detects whether the ScrollView is hosted in a UIViewController whose ModalPresentationStyle is PageSheetand bypasses only the artificial Bounds + 1 adjustment in that scenario. - The PageSheet detection result is cached and reset when the view moves to a different window, avoiding repeated responder-chain traversal during layout passes. - Importantly, this doesn't disable safe-area handling. The existing logic for handling the actual safe-area size is still preserved. Only the artificial Bounds + 1 adjustment is skipped for PageSheet. ### Validated the behaviour in the following platforms - [ ] Android - [ ] Windows - [x] iOS - [ ] Mac ### Issues Fixed: Fixes #38272 ### Screenshots | Before | After | |---------|--------| | <video src="https://github.com/user-attachments/assets/2f807cf2-548c-4333-8d95-436c062fa18f"> | <video src="https://github.com/user-attachments/assets/6fb7b0f0-7f57-4266-94ad-e0c25b3968e2"> |
<!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Backport of #39219 to `inflight/candidate`, intentionally targeting the SR12 staging branch rather than `main`. Fixes the documented ScrollView bottom-sheet flicker regression introduced in .NET 10 Preview 7. Avoids artificial content-size inflation inside a PageSheet while preserving the existing behavior for other presentations. PageSheet controller detection is cached and reset when the scroll view changes windows. Exactly the original `MauiScrollView.cs` change is carried; no dependencies, SDK pins or unrelated fixes are included. Source merge: `c6ad18ac7d6a89b806377f4490f5998527e7f2a7`. Backport head: `b4daa1a7581c7532856d31de55a3555219c967ad`. **Validation** - `git diff --binary 3d96e23 b4daa1a | git patch-id --stable` — passed: complete source patch identity matches `ede509d67f5c128501ef292da125bf98dc814db4`. - `git diff --check 3d96e23 b4daa1a` — passed. - The source PR contains no dedicated regression test. Local builds and native/runtime tests were not rerun for this unchanged automated replay. PR-head CI and runtime verification are pending; this is not a merge-readiness verdict. No XCTest, Appium, simulator/emulator or GUI execution was performed. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #38272 in the SR12 Candidate selection. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> /cc @kubaflo @Dhivya-SF4094 Co-authored-by: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com>
…reverting the flicker fix (#39472) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> **This PR now contains a targeted repair, not a revert.** The initial rollback remains in commit history, followed by a regular commit restoring the PageSheet flicker protection with corrected detection. Review the aggregate diff against `inflight/candidate`. Intentionally targets **`inflight/candidate`**, the source branch of the reported failure. #39330, the backport of #39219, is not on `main`. The previous detector treated any responder-chain controller with `ModalPresentationStyle=PageSheet` as an active sheet, even when it was not presented or was only a child controller. That could disable automatic safe-area stabilization on ordinary pages. It also cached presentation state until `MovedToWindow`, although that state can change without a window move. Finally, putting the PageSheet exemption on the outer `Automatic` condition allowed exempt sheets to fall through to manual safe-area padding when their system-adjusted inset was zero. The repair: - Checks the active modal root (`ParentViewController == null`, `PresentingViewController != null`) and its actual presentation style; unpresented and child-controller styles cannot masquerade as the modal presentation. - Does not retain a stale presentation-state cache. The responder chain is inspected only when an axis is near the safe-area threshold and would otherwise receive artificial content-size inflation, not on ordinary scroll frames. - Keeps `Automatic` handling in its own branch. Real PageSheets still skip artificial content-size inflation, without falling through into manual-padding logic. The existing `ScrollViewInitialOffsetInGridRow` UI test is unchanged. Its Mac assertion already avoids Appium screen-coordinate comparisons and checks native inset-aware position and managed `ScrollY`. The reported state (`offset=0`, adjusted top `36`, `ScrollY=36`) is an unwanted initial scroll, not a desktop-coordinate mismatch. This PR preserves the PageSheet behavior intended for #38272 rather than accepting the tradeoff of a complete revert. **Original CI evidence:** - Before #39330, [build 1631902, log 6647](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1631902/logs/6647) passed `AsyncContentUnderTheBar` twice with `offset=-36`, adjusted top `36`, `ScrollY=0`. - Afterward, [build 1633482, log 6656](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1633482/logs/6656) and the [reported build 1639699, log 7442](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1639699/logs/7442) failed that case twice with an unwanted 36-point initial scroll. - The closed rollback experiment #39401 passed the same test in [build 1636985, log 5408](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1636985/logs/5408). That isolates the regression, but a rollback also removes the intended PageSheet protection, so it is no longer the proposed solution. **New native regression coverage and causal comparison:** `Microsoft.Maui.DeviceTests.MauiScrollViewTests` has 11 cases covering unpresented PageSheet-style controllers, real presented sheets, zero/nonzero adjusted inset, full-screen/automatic styles, child-controller styles, presentation transitions without a window move, and actual UIKit PageSheet and FullScreen presentations. Assertions exercise the production `MauiScrollView.LayoutSubviews` content-size behavior, not source-text matching. On **iPhone 17e, iOS 26.5 CoreSimulator**, with exactly the same test fixture: | Production source | Repetitions | Result per repetition | | --- | --- | --- | | Original #39330 implementation | 3 | 7 passed, 4 expected regression failures | | Full revert | 3 | 6 passed, 5 expected PageSheet failures | | Targeted repair | 3 | **11 passed, 0 failed** | The trigger-removed control (same unpresented controller with `FullScreen` instead of `PageSheet` style) passed on every run. Original-code failures were stable: an ordinary PageSheet-style page incorrectly retained height `580` instead of receiving stabilization to `601`; a presented sheet with zero system inset incorrectly received manual padding to `616` instead of remaining `580`. The full revert incorrectly inflated actual PageSheet content to `601`. The repair satisfies both requirements. **Commands and results:** - `dotnet build Microsoft.Maui.BuildTasks.slnf -p:TreatWarningsAsErrors=false -v:quiet` — passed; 3 existing Gradle Java 8 deprecation warnings. - `dotnet build src/Core/tests/DeviceTests/Core.DeviceTests.csproj -c Debug -f net10.0-ios -r iossimulator-arm64 -p:TreatWarningsAsErrors=false -p:CodesignRequireProvisioningProfile=false -v:quiet` — passed on final source, 0 warnings and 0 errors. - `dotnet <nuget-cache>/microsoft.dotnet.xharness.cli/11.0.0-prerelease.26506.1/tools/net10.0/any/Microsoft.DotNet.XHarness.CLI.dll apple test --app artifacts/bin/Core.DeviceTests/Debug/net10.0-ios/iossimulator-arm64/Microsoft.Maui.Core.DeviceTests.app --target ios-simulator-64_26.5 --device EC2DD435-0C77-4AFF-9D99-65D757FB87C7 -o <unique-output-directory> --timeout 00:05:00 --set-env=NUNIT_SKIPPED_CLASSES=Microsoft.Maui.DeviceTests.MauiScrollViewTests` — final repair passed 11/11 on each of 3 runs; control-source results are listed above. Each fresh xUnit XML was checked for the exact fixture, all 11 expected cases, outcomes, and absence of unrelated executed tests. - `dotnet format Microsoft.Maui.sln --no-restore --include src/Core/src/Platform/iOS/MauiScrollView.cs src/Core/tests/DeviceTests/Platform/iOS/MauiScrollViewTests.iOS.cs --exclude Templates/src --exclude-diagnostics CA1822 --verify-no-changes --verbosity quiet` — passed. - `git diff --cached --check` — passed before commit. The repository wrapper initially could not run because its pinned XHarness selected an unavailable .NET 11 RC runtime; the same pinned package's supported `net10.0` CLI target was used instead. The wrapper also expected an older `testResults.xml` filename, so the fresh `xunit-test-*.xml` files were read directly; no failed wrapper invocation is reported as a passing test run. No XCTest, Appium, or host MacCatalyst UI automation was run locally. The new native tests verify the stabilization mechanism and real modal presentation boundaries; they do not claim a replay of the original drag/flicker gesture. Fresh macOS 14/15 CI must still confirm the original Mac UI failure is resolved by this final repair. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes the regression introduced by #39330 demonstrated in [build 1639699](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1639699&view=logs&s=122e92b9-0d0c-54f9-8b8c-2ad8bf075511&j=80d2be95-1c2f-5715-79d0-806ff2907928), while retaining the PageSheet protection for #38272. Supersedes the rollback approach explored in the closed testing-only PR #39401. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7b60cc75-5f0e-4d39-a325-ef73b2fada65


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!
Issue detail
On iOS, a ScrollView inside a PageSheet flickers when the sheet is interactively resized between detents.
Root cause
Description of Change
Validated the behaviour in the following platforms
Issues Fixed:
Fixes #38272
Screenshots
38272_BeforeFix.mov
38272_AfterFix.mov