Repository navigation
[iOS] Fix Infinite Measure Looping on iOS - #38197
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 38197Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 38197" |
|
Hey there @@HarishwaranVijayakumar! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
|
/azp run maui-pr-uitests , maui-pr-devicetests |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
This comment has been minimized.
This comment has been minimized.
MauiBot
left a comment
There was a problem hiding this comment.
Expert Review — 2 findings
See inline comments for details.
|
could you please resolve conflicts |
<!-- 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 Adds `10.0.110` to both version dropdowns in the bug report issue template: - Version with bug - Last version that worked well This keeps the dropdowns consistent for the .NET 10 SR11 release.
Performance Review Summary
📊 Performance Results
Timings are per 1,000 injected inset callbacks. Three ABBA blocks per workload, 24 launches total, 120,000 measured changes per variant/workload. Subpixel timing ranges never overlapped; full-pixel ranges did. Allocation measures the managed UI thread, not native memory. Experimental native ScrollView workloads: quarter-pixel noise and one-pixel changes, against merge-base 🔧 Findings & Follow-upRedundant remeasurement is suppressed: subpixel changes went from 1,000 to 0 ScrollView measure callbacks per batch. Full-pixel changes still produced 1,000 on both revisions, with essentially unchanged managed allocation. Native inset/geometry checks passed, and unchanged-inset callbacks caused no remeasurement on either revision. Scope: these are controlled inset injections through the real |
<!-- 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 Adds `11.0.0-rc.1` to both version dropdowns in the bug report issue template: - Version with bug - Last version that worked well This keeps the dropdowns current for the .NET 11 RC1 release. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
<!-- 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! ## Summary Advance `main` to the .NET 10 SR12 development cycle now that `release/10.0.1xx-sr11` has been cut from the merge of dotnet#37393 (`e047434fd22752a3e96187d55cd554a4a1c200b5`). Change only `PatchVersion` in `eng/Versions.props` from `110` to `120`. Keep `SdkBandVersion=10.0.100`, `PreReleaseVersionLabel=ci.main` (including the inflight override), and `StabilizePackageVersion=false` unchanged. This is separate from the SR11 servicing-flip PR and does not change the release branch. Related: dotnet#38210. ## Validation - Evaluated `eng/Versions.props` using `dotnet msbuild -getProperty`: version `10.0.120`, SDK band `10.0.100`, prerelease label `ci.main`, stable versions disabled. - Ran the repository formatter scoped to `eng/Versions.props` and confirmed the final diff is exactly one changed line.
Resolve the MauiScrollView safe-area conflict by retaining main's shared live UIKit compensation predicate and making its inset check tolerant at device-pixel precision. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 169298fa-95aa-47a4-ad1c-512dc3f97871
|
Resolved the conflicts with current The Validation completed:
GitHub now reports the PR as mergeable; remaining |
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved test guards, alert detection, and safe-area cache invalidation issues remain.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (3)
src/Controls/tests/TestCases.HostApp/Issues/Issue37892.cs:181
- The PR description says this test is skipped on iOS 26+, but this branch explicitly applies
IOS26BoundaryConfigurationand then continues into the settle assertion. As written, iOS 26 runs the test rather than skipping it; either return/skip before the polling loop or update the description to document the iOS 26-specific reproduction configuration.
if (IsIOS26OrHigher())
{
ApplyConfiguration(IOS26BoundaryConfiguration);
await Task.Delay(TimeSpan.FromMilliseconds(100));
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue37892.cs:27
FindElements(string)performs an accessibility-id query, but the repro suppliesLayout Loop Detectedonly as the DisplayAlert title and does not set that as an AutomationId. This branch therefore cannot observe the loop alert; it waits the full 15 seconds and reports the generic settle timeout instead of the intended loop-specific failure. UseHasStatus("Layout Loop Detected")here or give the alert state an explicit automation id.
if (App.FindElements("Layout Loop Detected").Count > 0)
src/Core/src/Platform/iOS/MauiScrollView.cs:441
- Although this new comparison is pixel-level, a sub-pixel change in a non-empty
_safeAreastill reaches the exactoldSafeArea.Equalscheck immediately below and callsInvalidateConstraintsCache(). That clears the measure/arrange cache, so the nextLayoutSubviewsremeasures even thoughValidateSafeAreareturns true at line 454; repeated UIKit inset fluctuations can therefore still drive a local measure/arrange loop. Compare_safeAreaat pixel level for this cache invalidation as well.
if (!_systemAdjustedContentInset.EqualsAtPixelLevel(systemAdjustedContentInset))
{
InvalidateConstraintsCache();
_systemAdjustedContentInset = systemAdjustedContentInset;
- Files reviewed: 6/6 changed files
- Comments generated: 1
- Review effort level: Lite
| public void ScrollViewLayoutShouldSettle() | ||
| { |
<!-- 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. !!!!!!! --> ### Issue Details: - A `ScrollView` can enter an infinite layout and measure-invalidation loop when its content height is effectively equal to its viewport height. The repeated layout invalidations keep the UI thread busy, making the application unresponsive. - The reproduction depends on device dimensions, text wrapping, font measurements, and safe-area geometry because these factors determine whether the content lands precisely at the `ScrollView` scrollability boundary. ### Root Cause of the issue: - This regression was introduced by #30629, which updated safe-area measurement and arrangement behavior in `MauiScrollView`. - Near the scrollability boundary, UIKit can alternate `AdjustedContentInset` between zero and a microscopic floating-point value. Although this difference is much smaller than one physical pixel and has no visible effect, .NET MAUI compares the raw inset values exactly and treats every fluctuation as a meaningful change. - Each reported inset change causes `MauiScrollView` to invalidate its measure and the measures of its ancestors. Remeasuring the layout causes UIKit to recalculate the adjusted inset, producing another tiny change and repeating the cycle: ```text Subpixel adjusted-inset change → measure invalidation → ancestor remeasurement → adjusted-inset recalculation → another subpixel change → infinite layout loop ``` ### Description of Change **Test coverage and reproduction:** * Added new test case and reproduction page (`Issue37892`) to detect and verify infinite measure/layout loops in `ScrollView` on iOS. The test uses automation to check for loop detection and layout settling, and is skipped on iOS 26+ where the issue cannot be reliably reproduced. **Safe area and layout logic improvements:** * Changed internal representation of system-adjusted content inset in `MauiScrollView` from `UIEdgeInsets` to `SafeAreaPadding` for consistency and improved comparison logic. (`src/Core/src/Platform/iOS/MauiScrollView.cs`) * Updated safe area validation logic to use pixel-level equality checks (`EqualsAtPixelLevel` and new `IsEmptyAtPixelLevel`) to avoid unnecessary invalidations and layout recalculations, preventing the infinite layout loop caused by subpixel inset fluctuations. (`src/Core/src/Platform/iOS/MauiScrollView.cs`, `src/Core/src/Platform/iOS/SafeAreaPadding.cs`) * Ensured arrangement logic in `MauiScrollView` uses the updated pixel-level empty check for `_systemAdjustedContentInset` to further prevent spurious layout passes. (`src/Core/src/Platform/iOS/MauiScrollView.cs`) ### 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 #37892 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [ ] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/2906a921-4905-4276-836a-3d96db15e85f"> | <video src="https://github.com/user-attachments/assets/da9cf3c0-f19f-499f-b7dc-1350e3ba3399"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- 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. !!!!!!! --> ### Issue Details: - A `ScrollView` can enter an infinite layout and measure-invalidation loop when its content height is effectively equal to its viewport height. The repeated layout invalidations keep the UI thread busy, making the application unresponsive. - The reproduction depends on device dimensions, text wrapping, font measurements, and safe-area geometry because these factors determine whether the content lands precisely at the `ScrollView` scrollability boundary. ### Root Cause of the issue: - This regression was introduced by #30629, which updated safe-area measurement and arrangement behavior in `MauiScrollView`. - Near the scrollability boundary, UIKit can alternate `AdjustedContentInset` between zero and a microscopic floating-point value. Although this difference is much smaller than one physical pixel and has no visible effect, .NET MAUI compares the raw inset values exactly and treats every fluctuation as a meaningful change. - Each reported inset change causes `MauiScrollView` to invalidate its measure and the measures of its ancestors. Remeasuring the layout causes UIKit to recalculate the adjusted inset, producing another tiny change and repeating the cycle: ```text Subpixel adjusted-inset change → measure invalidation → ancestor remeasurement → adjusted-inset recalculation → another subpixel change → infinite layout loop ``` ### Description of Change **Test coverage and reproduction:** * Added new test case and reproduction page (`Issue37892`) to detect and verify infinite measure/layout loops in `ScrollView` on iOS. The test uses automation to check for loop detection and layout settling, and is skipped on iOS 26+ where the issue cannot be reliably reproduced. **Safe area and layout logic improvements:** * Changed internal representation of system-adjusted content inset in `MauiScrollView` from `UIEdgeInsets` to `SafeAreaPadding` for consistency and improved comparison logic. (`src/Core/src/Platform/iOS/MauiScrollView.cs`) * Updated safe area validation logic to use pixel-level equality checks (`EqualsAtPixelLevel` and new `IsEmptyAtPixelLevel`) to avoid unnecessary invalidations and layout recalculations, preventing the infinite layout loop caused by subpixel inset fluctuations. (`src/Core/src/Platform/iOS/MauiScrollView.cs`, `src/Core/src/Platform/iOS/SafeAreaPadding.cs`) * Ensured arrangement logic in `MauiScrollView` uses the updated pixel-level empty check for `_systemAdjustedContentInset` to further prevent spurious layout passes. (`src/Core/src/Platform/iOS/MauiScrollView.cs`) ### 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 #37892 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [ ] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/2906a921-4905-4276-836a-3d96db15e85f"> | <video src="https://github.com/user-attachments/assets/da9cf3c0-f19f-499f-b7dc-1350e3ba3399"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- 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. !!!!!!! --> ### Issue Details: - A `ScrollView` can enter an infinite layout and measure-invalidation loop when its content height is effectively equal to its viewport height. The repeated layout invalidations keep the UI thread busy, making the application unresponsive. - The reproduction depends on device dimensions, text wrapping, font measurements, and safe-area geometry because these factors determine whether the content lands precisely at the `ScrollView` scrollability boundary. ### Root Cause of the issue: - This regression was introduced by #30629, which updated safe-area measurement and arrangement behavior in `MauiScrollView`. - Near the scrollability boundary, UIKit can alternate `AdjustedContentInset` between zero and a microscopic floating-point value. Although this difference is much smaller than one physical pixel and has no visible effect, .NET MAUI compares the raw inset values exactly and treats every fluctuation as a meaningful change. - Each reported inset change causes `MauiScrollView` to invalidate its measure and the measures of its ancestors. Remeasuring the layout causes UIKit to recalculate the adjusted inset, producing another tiny change and repeating the cycle: ```text Subpixel adjusted-inset change → measure invalidation → ancestor remeasurement → adjusted-inset recalculation → another subpixel change → infinite layout loop ``` ### Description of Change **Test coverage and reproduction:** * Added new test case and reproduction page (`Issue37892`) to detect and verify infinite measure/layout loops in `ScrollView` on iOS. The test uses automation to check for loop detection and layout settling, and is skipped on iOS 26+ where the issue cannot be reliably reproduced. **Safe area and layout logic improvements:** * Changed internal representation of system-adjusted content inset in `MauiScrollView` from `UIEdgeInsets` to `SafeAreaPadding` for consistency and improved comparison logic. (`src/Core/src/Platform/iOS/MauiScrollView.cs`) * Updated safe area validation logic to use pixel-level equality checks (`EqualsAtPixelLevel` and new `IsEmptyAtPixelLevel`) to avoid unnecessary invalidations and layout recalculations, preventing the infinite layout loop caused by subpixel inset fluctuations. (`src/Core/src/Platform/iOS/MauiScrollView.cs`, `src/Core/src/Platform/iOS/SafeAreaPadding.cs`) * Ensured arrangement logic in `MauiScrollView` uses the updated pixel-level empty check for `_systemAdjustedContentInset` to further prevent spurious layout passes. (`src/Core/src/Platform/iOS/MauiScrollView.cs`) ### 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 #37892 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [ ] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/2906a921-4905-4276-836a-3d96db15e85f"> | <video src="https://github.com/user-attachments/assets/da9cf3c0-f19f-499f-b7dc-1350e3ba3399"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- 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. !!!!!!! --> ### Issue Details: - A `ScrollView` can enter an infinite layout and measure-invalidation loop when its content height is effectively equal to its viewport height. The repeated layout invalidations keep the UI thread busy, making the application unresponsive. - The reproduction depends on device dimensions, text wrapping, font measurements, and safe-area geometry because these factors determine whether the content lands precisely at the `ScrollView` scrollability boundary. ### Root Cause of the issue: - This regression was introduced by #30629, which updated safe-area measurement and arrangement behavior in `MauiScrollView`. - Near the scrollability boundary, UIKit can alternate `AdjustedContentInset` between zero and a microscopic floating-point value. Although this difference is much smaller than one physical pixel and has no visible effect, .NET MAUI compares the raw inset values exactly and treats every fluctuation as a meaningful change. - Each reported inset change causes `MauiScrollView` to invalidate its measure and the measures of its ancestors. Remeasuring the layout causes UIKit to recalculate the adjusted inset, producing another tiny change and repeating the cycle: ```text Subpixel adjusted-inset change → measure invalidation → ancestor remeasurement → adjusted-inset recalculation → another subpixel change → infinite layout loop ``` ### Description of Change **Test coverage and reproduction:** * Added new test case and reproduction page (`Issue37892`) to detect and verify infinite measure/layout loops in `ScrollView` on iOS. The test uses automation to check for loop detection and layout settling, and is skipped on iOS 26+ where the issue cannot be reliably reproduced. **Safe area and layout logic improvements:** * Changed internal representation of system-adjusted content inset in `MauiScrollView` from `UIEdgeInsets` to `SafeAreaPadding` for consistency and improved comparison logic. (`src/Core/src/Platform/iOS/MauiScrollView.cs`) * Updated safe area validation logic to use pixel-level equality checks (`EqualsAtPixelLevel` and new `IsEmptyAtPixelLevel`) to avoid unnecessary invalidations and layout recalculations, preventing the infinite layout loop caused by subpixel inset fluctuations. (`src/Core/src/Platform/iOS/MauiScrollView.cs`, `src/Core/src/Platform/iOS/SafeAreaPadding.cs`) * Ensured arrangement logic in `MauiScrollView` uses the updated pixel-level empty check for `_systemAdjustedContentInset` to further prevent spurious layout passes. (`src/Core/src/Platform/iOS/MauiScrollView.cs`) ### 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 #37892 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [ ] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/2906a921-4905-4276-836a-3d96db15e85f"> | <video src="https://github.com/user-attachments/assets/da9cf3c0-f19f-499f-b7dc-1350e3ba3399"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- 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. !!!!!!! --> ### Issue Details: - A `ScrollView` can enter an infinite layout and measure-invalidation loop when its content height is effectively equal to its viewport height. The repeated layout invalidations keep the UI thread busy, making the application unresponsive. - The reproduction depends on device dimensions, text wrapping, font measurements, and safe-area geometry because these factors determine whether the content lands precisely at the `ScrollView` scrollability boundary. ### Root Cause of the issue: - This regression was introduced by #30629, which updated safe-area measurement and arrangement behavior in `MauiScrollView`. - Near the scrollability boundary, UIKit can alternate `AdjustedContentInset` between zero and a microscopic floating-point value. Although this difference is much smaller than one physical pixel and has no visible effect, .NET MAUI compares the raw inset values exactly and treats every fluctuation as a meaningful change. - Each reported inset change causes `MauiScrollView` to invalidate its measure and the measures of its ancestors. Remeasuring the layout causes UIKit to recalculate the adjusted inset, producing another tiny change and repeating the cycle: ```text Subpixel adjusted-inset change → measure invalidation → ancestor remeasurement → adjusted-inset recalculation → another subpixel change → infinite layout loop ``` ### Description of Change **Test coverage and reproduction:** * Added new test case and reproduction page (`Issue37892`) to detect and verify infinite measure/layout loops in `ScrollView` on iOS. The test uses automation to check for loop detection and layout settling, and is skipped on iOS 26+ where the issue cannot be reliably reproduced. **Safe area and layout logic improvements:** * Changed internal representation of system-adjusted content inset in `MauiScrollView` from `UIEdgeInsets` to `SafeAreaPadding` for consistency and improved comparison logic. (`src/Core/src/Platform/iOS/MauiScrollView.cs`) * Updated safe area validation logic to use pixel-level equality checks (`EqualsAtPixelLevel` and new `IsEmptyAtPixelLevel`) to avoid unnecessary invalidations and layout recalculations, preventing the infinite layout loop caused by subpixel inset fluctuations. (`src/Core/src/Platform/iOS/MauiScrollView.cs`, `src/Core/src/Platform/iOS/SafeAreaPadding.cs`) * Ensured arrangement logic in `MauiScrollView` uses the updated pixel-level empty check for `_systemAdjustedContentInset` to further prevent spurious layout passes. (`src/Core/src/Platform/iOS/MauiScrollView.cs`) ### 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 #37892 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [ ] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/2906a921-4905-4276-836a-3d96db15e85f"> | <video src="https://github.com/user-attachments/assets/da9cf3c0-f19f-499f-b7dc-1350e3ba3399"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- 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. !!!!!!! --> ### Issue Details: - A `ScrollView` can enter an infinite layout and measure-invalidation loop when its content height is effectively equal to its viewport height. The repeated layout invalidations keep the UI thread busy, making the application unresponsive. - The reproduction depends on device dimensions, text wrapping, font measurements, and safe-area geometry because these factors determine whether the content lands precisely at the `ScrollView` scrollability boundary. ### Root Cause of the issue: - This regression was introduced by #30629, which updated safe-area measurement and arrangement behavior in `MauiScrollView`. - Near the scrollability boundary, UIKit can alternate `AdjustedContentInset` between zero and a microscopic floating-point value. Although this difference is much smaller than one physical pixel and has no visible effect, .NET MAUI compares the raw inset values exactly and treats every fluctuation as a meaningful change. - Each reported inset change causes `MauiScrollView` to invalidate its measure and the measures of its ancestors. Remeasuring the layout causes UIKit to recalculate the adjusted inset, producing another tiny change and repeating the cycle: ```text Subpixel adjusted-inset change → measure invalidation → ancestor remeasurement → adjusted-inset recalculation → another subpixel change → infinite layout loop ``` ### Description of Change **Test coverage and reproduction:** * Added new test case and reproduction page (`Issue37892`) to detect and verify infinite measure/layout loops in `ScrollView` on iOS. The test uses automation to check for loop detection and layout settling, and is skipped on iOS 26+ where the issue cannot be reliably reproduced. **Safe area and layout logic improvements:** * Changed internal representation of system-adjusted content inset in `MauiScrollView` from `UIEdgeInsets` to `SafeAreaPadding` for consistency and improved comparison logic. (`src/Core/src/Platform/iOS/MauiScrollView.cs`) * Updated safe area validation logic to use pixel-level equality checks (`EqualsAtPixelLevel` and new `IsEmptyAtPixelLevel`) to avoid unnecessary invalidations and layout recalculations, preventing the infinite layout loop caused by subpixel inset fluctuations. (`src/Core/src/Platform/iOS/MauiScrollView.cs`, `src/Core/src/Platform/iOS/SafeAreaPadding.cs`) * Ensured arrangement logic in `MauiScrollView` uses the updated pixel-level empty check for `_systemAdjustedContentInset` to further prevent spurious layout passes. (`src/Core/src/Platform/iOS/MauiScrollView.cs`) ### 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 #37892 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [ ] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/2906a921-4905-4276-836a-3d96db15e85f"> | <video src="https://github.com/user-attachments/assets/da9cf3c0-f19f-499f-b7dc-1350e3ba3399"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- 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. !!!!!!! --> ### Issue Details: - A `ScrollView` can enter an infinite layout and measure-invalidation loop when its content height is effectively equal to its viewport height. The repeated layout invalidations keep the UI thread busy, making the application unresponsive. - The reproduction depends on device dimensions, text wrapping, font measurements, and safe-area geometry because these factors determine whether the content lands precisely at the `ScrollView` scrollability boundary. ### Root Cause of the issue: - This regression was introduced by #30629, which updated safe-area measurement and arrangement behavior in `MauiScrollView`. - Near the scrollability boundary, UIKit can alternate `AdjustedContentInset` between zero and a microscopic floating-point value. Although this difference is much smaller than one physical pixel and has no visible effect, .NET MAUI compares the raw inset values exactly and treats every fluctuation as a meaningful change. - Each reported inset change causes `MauiScrollView` to invalidate its measure and the measures of its ancestors. Remeasuring the layout causes UIKit to recalculate the adjusted inset, producing another tiny change and repeating the cycle: ```text Subpixel adjusted-inset change → measure invalidation → ancestor remeasurement → adjusted-inset recalculation → another subpixel change → infinite layout loop ``` ### Description of Change **Test coverage and reproduction:** * Added new test case and reproduction page (`Issue37892`) to detect and verify infinite measure/layout loops in `ScrollView` on iOS. The test uses automation to check for loop detection and layout settling, and is skipped on iOS 26+ where the issue cannot be reliably reproduced. **Safe area and layout logic improvements:** * Changed internal representation of system-adjusted content inset in `MauiScrollView` from `UIEdgeInsets` to `SafeAreaPadding` for consistency and improved comparison logic. (`src/Core/src/Platform/iOS/MauiScrollView.cs`) * Updated safe area validation logic to use pixel-level equality checks (`EqualsAtPixelLevel` and new `IsEmptyAtPixelLevel`) to avoid unnecessary invalidations and layout recalculations, preventing the infinite layout loop caused by subpixel inset fluctuations. (`src/Core/src/Platform/iOS/MauiScrollView.cs`, `src/Core/src/Platform/iOS/SafeAreaPadding.cs`) * Ensured arrangement logic in `MauiScrollView` uses the updated pixel-level empty check for `_systemAdjustedContentInset` to further prevent spurious layout passes. (`src/Core/src/Platform/iOS/MauiScrollView.cs`) ### 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 #37892 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [ ] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/2906a921-4905-4276-836a-3d96db15e85f"> | <video src="https://github.com/user-attachments/assets/da9cf3c0-f19f-499f-b7dc-1350e3ba3399"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- 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. !!!!!!! --> ### Issue Details: - A `ScrollView` can enter an infinite layout and measure-invalidation loop when its content height is effectively equal to its viewport height. The repeated layout invalidations keep the UI thread busy, making the application unresponsive. - The reproduction depends on device dimensions, text wrapping, font measurements, and safe-area geometry because these factors determine whether the content lands precisely at the `ScrollView` scrollability boundary. ### Root Cause of the issue: - This regression was introduced by #30629, which updated safe-area measurement and arrangement behavior in `MauiScrollView`. - Near the scrollability boundary, UIKit can alternate `AdjustedContentInset` between zero and a microscopic floating-point value. Although this difference is much smaller than one physical pixel and has no visible effect, .NET MAUI compares the raw inset values exactly and treats every fluctuation as a meaningful change. - Each reported inset change causes `MauiScrollView` to invalidate its measure and the measures of its ancestors. Remeasuring the layout causes UIKit to recalculate the adjusted inset, producing another tiny change and repeating the cycle: ```text Subpixel adjusted-inset change → measure invalidation → ancestor remeasurement → adjusted-inset recalculation → another subpixel change → infinite layout loop ``` ### Description of Change **Test coverage and reproduction:** * Added new test case and reproduction page (`Issue37892`) to detect and verify infinite measure/layout loops in `ScrollView` on iOS. The test uses automation to check for loop detection and layout settling, and is skipped on iOS 26+ where the issue cannot be reliably reproduced. **Safe area and layout logic improvements:** * Changed internal representation of system-adjusted content inset in `MauiScrollView` from `UIEdgeInsets` to `SafeAreaPadding` for consistency and improved comparison logic. (`src/Core/src/Platform/iOS/MauiScrollView.cs`) * Updated safe area validation logic to use pixel-level equality checks (`EqualsAtPixelLevel` and new `IsEmptyAtPixelLevel`) to avoid unnecessary invalidations and layout recalculations, preventing the infinite layout loop caused by subpixel inset fluctuations. (`src/Core/src/Platform/iOS/MauiScrollView.cs`, `src/Core/src/Platform/iOS/SafeAreaPadding.cs`) * Ensured arrangement logic in `MauiScrollView` uses the updated pixel-level empty check for `_systemAdjustedContentInset` to further prevent spurious layout passes. (`src/Core/src/Platform/iOS/MauiScrollView.cs`) ### 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 #37892 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [ ] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/2906a921-4905-4276-836a-3d96db15e85f"> | <video src="https://github.com/user-attachments/assets/da9cf3c0-f19f-499f-b7dc-1350e3ba3399"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
<!-- 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. !!!!!!! --> ### Issue Details: - A `ScrollView` can enter an infinite layout and measure-invalidation loop when its content height is effectively equal to its viewport height. The repeated layout invalidations keep the UI thread busy, making the application unresponsive. - The reproduction depends on device dimensions, text wrapping, font measurements, and safe-area geometry because these factors determine whether the content lands precisely at the `ScrollView` scrollability boundary. ### Root Cause of the issue: - This regression was introduced by #30629, which updated safe-area measurement and arrangement behavior in `MauiScrollView`. - Near the scrollability boundary, UIKit can alternate `AdjustedContentInset` between zero and a microscopic floating-point value. Although this difference is much smaller than one physical pixel and has no visible effect, .NET MAUI compares the raw inset values exactly and treats every fluctuation as a meaningful change. - Each reported inset change causes `MauiScrollView` to invalidate its measure and the measures of its ancestors. Remeasuring the layout causes UIKit to recalculate the adjusted inset, producing another tiny change and repeating the cycle: ```text Subpixel adjusted-inset change → measure invalidation → ancestor remeasurement → adjusted-inset recalculation → another subpixel change → infinite layout loop ``` ### Description of Change **Test coverage and reproduction:** * Added new test case and reproduction page (`Issue37892`) to detect and verify infinite measure/layout loops in `ScrollView` on iOS. The test uses automation to check for loop detection and layout settling, and is skipped on iOS 26+ where the issue cannot be reliably reproduced. **Safe area and layout logic improvements:** * Changed internal representation of system-adjusted content inset in `MauiScrollView` from `UIEdgeInsets` to `SafeAreaPadding` for consistency and improved comparison logic. (`src/Core/src/Platform/iOS/MauiScrollView.cs`) * Updated safe area validation logic to use pixel-level equality checks (`EqualsAtPixelLevel` and new `IsEmptyAtPixelLevel`) to avoid unnecessary invalidations and layout recalculations, preventing the infinite layout loop caused by subpixel inset fluctuations. (`src/Core/src/Platform/iOS/MauiScrollView.cs`, `src/Core/src/Platform/iOS/SafeAreaPadding.cs`) * Ensured arrangement logic in `MauiScrollView` uses the updated pixel-level empty check for `_systemAdjustedContentInset` to further prevent spurious layout passes. (`src/Core/src/Platform/iOS/MauiScrollView.cs`) ### 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 #37892 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [ ] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/2906a921-4905-4276-836a-3d96db15e85f"> | <video src="https://github.com/user-attachments/assets/da9cf3c0-f19f-499f-b7dc-1350e3ba3399"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
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 Details:
ScrollViewcan enter an infinite layout and measure-invalidation loop when its content height is effectively equal to its viewport height. The repeated layout invalidations keep the UI thread busy, making the application unresponsive.ScrollViewscrollability boundary.Root Cause of the issue:
This regression was introduced by [net10.0] Fix SafeArea management on iOS #30629, which updated safe-area measurement and arrangement behavior in
MauiScrollView.Near the scrollability boundary, UIKit can alternate
AdjustedContentInsetbetween zero and a microscopic floating-point value. Although this difference is much smaller than one physical pixel and has no visible effect, .NET MAUI compares the raw inset values exactly and treats every fluctuation as a meaningful change.Each reported inset change causes
MauiScrollViewto invalidate its measure and the measures of its ancestors. Remeasuring the layout causes UIKit to recalculate the adjusted inset, producing another tiny change and repeating the cycle:Description of Change
Test coverage and reproduction:
Issue37892) to detect and verify infinite measure/layout loops inScrollViewon iOS. The test uses automation to check for loop detection and layout settling, and is skipped on iOS 26+ where the issue cannot be reliably reproduced.Safe area and layout logic improvements:
MauiScrollViewfromUIEdgeInsetstoSafeAreaPaddingfor consistency and improved comparison logic. (src/Core/src/Platform/iOS/MauiScrollView.cs)EqualsAtPixelLeveland newIsEmptyAtPixelLevel) to avoid unnecessary invalidations and layout recalculations, preventing the infinite layout loop caused by subpixel inset fluctuations. (src/Core/src/Platform/iOS/MauiScrollView.cs,src/Core/src/Platform/iOS/SafeAreaPadding.cs)MauiScrollViewuses the updated pixel-level empty check for_systemAdjustedContentInsetto further prevent spurious layout passes. (src/Core/src/Platform/iOS/MauiScrollView.cs)Issues Fixed
Fixes #37892
Tested the behavior in the following platforms
Output
Beforefix-37892.mov
Afterfix-37892.mov