[release/10.0.1xx-sr7] Gate SafeArea inset listeners in recycler items#35693
Merged
PureWeen merged 3 commits intoJun 2, 2026
Merged
Conversation
This PR reduces Android `CollectionView`/`CarouselView` item allocation overhead from SafeArea inset listener attachment. The Android SafeArea implementation currently attaches inset listeners to item views under `IMauiRecyclerView`, even when those item views have default `SafeAreaEdges` behavior. This is expensive during item realization/recycling and materially increases allocations and GC pressure in scroll-heavy CollectionView scenarios. This change gates Android inset listener attachment for descendants of `IMauiRecyclerView` so listeners are only attached when the target platform view backs an `ISafeAreaView2` with explicitly configured `SafeAreaEdges`. The fix also preserves behavior for dynamic SafeArea changes: - default item views do not attach inset listeners; - explicit `SafeAreaEdges` values, including `SafeAreaEdges.None`, remain eligible; - changing from default to explicit refreshes and attaches the listener; - clearing/changing back to default removes the listener and resets applied padding; - existing `AppBarLayout`, `MaterialToolbar`, and `MauiScrollView` exclusions are preserved. Validation completed: - `dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --filter FullyQualifiedName~SafeAreaTests --nologo` - Android device test build and CollectionView SafeArea listener tests - MauiAppGC repro, Release Android, explicit APK install, `Reset -> End -> Start -> End`, 5 repeats: - `10.0.70`: ~270 MB allocated, `65/2/2` GCs - SafeArea gating patch: ~151 MB allocated, `38/0/0` GCs Fixes #35344 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com> (cherry picked from commit 8079709)
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 35693Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 35693" |
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
This was referenced Jun 2, 2026
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Fix GroupableItemsViewAdapter double-bind of GroupHeader/Footer causing unbounded logical children growth on recycle
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
PureWeen
approved these changes
Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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!
Backport of #35664 to
release/10.0.1xx-sr7./cc @PureWeen