Skip to content

[inflight/candidate] Fix iOS PageSheet ScrollView flicker - #39330

Merged
kubaflo merged 1 commit into
inflight/candidatefrom
backport/pr-39219-to-inflight/candidate
Oct 12, 2026
Merged

kubaflo merged 1 commit into
inflight/candidatefrom
backport/pr-39219-to-inflight/candidate

Conversation

@github-actions

@github-actions github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

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 3d96e23006ea80f58ff2946017eb4593f63a46c6 b4daa1a7581c7532856d31de55a3555219c967ad | git patch-id --stable — passed: complete source patch identity matches ede509d67f5c128501ef292da125bf98dc814db4.
  • git diff --check 3d96e23006ea80f58ff2946017eb4593f63a46c6 b4daa1a7581c7532856d31de55a3555219c967ad — 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

Fixes #38272 in the SR12 Candidate selection.

/cc @kubaflo @Dhivya-SF4094

… 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"> 
|
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@kubaflo kubaflo changed the title [inflight/candidate] [iOS] Fix ScrollView introduces flickering in bottom sheets with .NET 10 [inflight/candidate] Fix iOS PageSheet ScrollView flicker Oct 12, 2026
@kubaflo
kubaflo merged commit a91544c into inflight/candidate Oct 12, 2026
32 of 35 checks passed
@kubaflo
kubaflo deleted the backport/pr-39219-to-inflight/candidate branch October 12, 2026 14:38
@github-actions github-actions Bot added this to the .NET 10 SR12 milestone Oct 12, 2026
kubaflo pushed a commit that referenced this pull request Oct 13, 2026
<!-- 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>
kubaflo pushed a commit that referenced this pull request Oct 14, 2026
<!-- 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>
kubaflo pushed a commit that referenced this pull request Oct 18, 2026
<!-- 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>
kubaflo added a commit that referenced this pull request Oct 19, 2026
…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
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants