Skip to content

[release/10.0.1xx-sr7] Fix iOS/Catalyst MapPool retention with MapElements#35690

Merged
PureWeen merged 1 commit into
release/10.0.1xx-sr7from
backport/pr-35480-to-release/10.0.1xx-sr7
Jun 2, 2026
Merged

[release/10.0.1xx-sr7] Fix iOS/Catalyst MapPool retention with MapElements#35690
PureWeen merged 1 commit into
release/10.0.1xx-sr7from
backport/pr-35480-to-release/10.0.1xx-sr7

Conversation

@kubaflo

@kubaflo kubaflo commented Jun 1, 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!

Backport of #35480 to release/10.0.1xx-sr7.
/cc @PureWeen

### Description of Change

Fixes an iOS/Mac Catalyst `MapHandler` pooling leak where a disconnected
`MauiMKMapView` was returned to `MapPool` without clearing native map
state. If the map contained `MapElement`s, the pooled native map kept
overlays alive, which retained the MAUI map elements and their owning
page/view-model graph after navigation.

The fix prepares pooled map views for reuse by clearing tracked map
elements, removing native overlays/annotations, and clearing transient
touch state before the native map is added back to the pool.

Mac Catalyst repro results using `MapPoolLeakRepro` with 30 pages/run,
40 `MapElement`s/page, 2 MB payload/page, 120 ms dwell/page:

| Metric | Before fix | After fix | Change |
|---|---:|---:|---:|
| MAUI Map views alive | 30/30 | 0/30 | -100.0% |
| Payload view models alive | 30/30 | 0/30 | -100.0% |
| Map elements alive | 1200/1200 | 0/1200 | -100.0% |
| Retained payload | 60.0 MB | 0 B | -100.0% |
| Managed heap delta after GC | 63.8 MB | 228.1 KB | -99.7% |
| GC heap delta after GC | 65.0 MB | 896.0 KB | -98.7% |

Also adds a device regression test covering disconnect/pool cleanup for
pins, native annotations, map elements, native overlays, and
`MapElementId`.

### Issues Fixed

Fixes #35479

---------

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
(cherry picked from commit 1889fdb)
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 35690

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 35690"

@kubaflo

kubaflo commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 3 pipeline(s).

@kubaflo

kubaflo commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

Failures are unrelated

@kubaflo kubaflo enabled auto-merge (squash) June 2, 2026 14:40
This was referenced Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants