Skip to content

[iOS] Fixed the App crashes when navigating to a page containing a map more than once #29369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 9, 2025

Conversation

Ahamed-Ali
Copy link
Contributor

@Ahamed-Ali Ahamed-Ali commented May 7, 2025

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!

Root Cause of the issue

  • The crash occurred because the handler was set inside the constructor, which prevents it from being reused from the map pool.

Description of Change

  • Move the handler assignment outside the constructor so that when it is reused from the pool, the handler is not null and does not cause a crash.

Issues Fixed

Fixes #20612
Fixes #29346

Fix Reference

#28795

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Screenshot

Before Issue Fix After Issue Fix
MapCrash.mov
MapCrashFix.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label May 7, 2025
Copy link
Contributor

Hey there @@Ahamed-Ali! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label May 7, 2025
@Ahamed-Ali Ahamed-Ali marked this pull request as ready for review May 7, 2025 11:03
@Copilot Copilot AI review requested due to automatic review settings May 7, 2025 11:03
@Ahamed-Ali Ahamed-Ali requested a review from a team as a code owner May 7, 2025 11:03
@Ahamed-Ali Ahamed-Ali requested review from mattleibow and PureWeen May 7, 2025 11:03
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR resolves an iOS crash that occurred when navigating back to a page containing a map by ensuring that the map’s handler is properly assigned when the view is reused from the pool.

  • Moved the handler assignment logic in MauiMKMapView outside the constructor.
  • Updated the MapPool to assign the handler when retrieving a map from the pool.
  • Modified MapHandler.iOS to utilize the new overload in MapPool for proper handler assignment.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Core/maps/src/Platform/iOS/MauiMKMapView.cs Added an internal Handler property using a weak reference to the map handler.
src/Core/maps/src/Platform/iOS/MapPool.cs Added a new Get overload to assign the IMapHandler when reusing a map view.
src/Core/maps/src/Handlers/Map/MapHandler.iOS.cs Updated to use the new MapPool.Get overload with the handler parameter.
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue20612.cs Added a test case to verify that the crash is fixed.
src/Controls/tests/TestCases.HostApp/Issues/Issue20612.cs Updated the sample app to support testing the fixed behavior.

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

rmarinho
rmarinho previously approved these changes May 9, 2025
@rmarinho
Copy link
Member

rmarinho commented May 9, 2025

/azp run MAUI-DeviceTests-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@PureWeen PureWeen changed the base branch from main to inflight/current May 9, 2025 15:02
@PureWeen PureWeen dismissed rmarinho’s stale review May 9, 2025 15:02

The base branch was changed.

@PureWeen PureWeen merged commit 51405ec into dotnet:inflight/current May 9, 2025
112 checks passed
PureWeen pushed a commit that referenced this pull request May 13, 2025
…p more than once (#29369)

* Committed the test case and sample

* committed the fix

* Modified the test sample

* Updated the Test condition for windows

* Removed unwanted spaces

* Optimized the fix

* Change the code into modern c#
github-actions bot pushed a commit that referenced this pull request May 13, 2025
…p more than once (#29369)

* Committed the test case and sample

* committed the fix

* Modified the test sample

* Updated the Test condition for windows

* Removed unwanted spaces

* Optimized the fix

* Change the code into modern c#
PureWeen pushed a commit that referenced this pull request May 14, 2025
…p more than once (#29369)

* Committed the test case and sample

* committed the fix

* Modified the test sample

* Updated the Test condition for windows

* Removed unwanted spaces

* Optimized the fix

* Change the code into modern c#
PureWeen pushed a commit that referenced this pull request May 14, 2025
…p more than once (#29369)

* Committed the test case and sample

* committed the fix

* Modified the test sample

* Updated the Test condition for windows

* Removed unwanted spaces

* Optimized the fix

* Change the code into modern c#
github-actions bot pushed a commit that referenced this pull request May 15, 2025
…p more than once (#29369)

* Committed the test case and sample

* committed the fix

* Modified the test sample

* Updated the Test condition for windows

* Removed unwanted spaces

* Optimized the fix

* Change the code into modern c#
PureWeen added a commit that referenced this pull request May 21, 2025
For more information about inflight process check
https://github.com/dotnet/maui/wiki/Inflight-Branch-Process

# .NET MAUI Release Notes

## New Release: May 21, 2025

We're excited to announce a new release of .NET MAUI with several bug
fixes and improvements across various platforms.

### Bug Fixes

#### iOS
- **Map Control**: Fixed crash when navigating to a page containing a
map more than once (#29369)
- **CarouselView**: Fixed bounce-back behavior when Loop=false, ensuring
proper scrolling experience (#29318)
- **UIView**: Fixed NullReferenceException for UIView not being in
UIWindow (#29460)

#### Windows
- **CarouselView**: Fixed HorizontalScrollBarVisibility="Never" not
working properly (#29343)
- **UI Controls**: Fixed the color not being applied to the
Expand/Collapse Chevron icon (#29140)

#### Windows & macOS
- **Modal Navigation**: Fixed issue where Disappearing event was not
triggered when closing a window with a modal page (#29129)

#### Android
- **Modal Pages**: Improved inheritance of StatusBar and NavigationBar
background colors (#28568)
- **Footer Scrolling**: Fixed footer scrolling issues in list controls
(#29381)
- **Modal Pages**: Improved inheritance of StatusBar and NavigationBar
background colors on modal pages (#28568)

#### Cross-Platform
- **CarouselView**: Fixed ItemsLayout runtime updates to ensure proper
layout behavior (#29447)
- **CollectionView**: Fixed various issues in CollectionView
implementation (#29423)

### Testing Improvements
- Added feature matrix UITest cases for CollectionView dynamic changes
(#29424)

### Code Quality
- Fixed code formatting issues across the codebase
- Minor typo corrections (#29379)

### Contributors

This release was made possible by the hard work of our dedicated team
and community contributors. We'd like to extend our gratitude to
everyone who has contributed to this release.

### Installation

This update is available through NuGet and the .NET SDK. Update your
projects to get access to these fixes.

### Known Issues

Please refer to our issue tracker for any known issues and their
workarounds.

---

For more information about .NET MAUI, visit [the official
documentation](https://docs.microsoft.com/dotnet/maui/).
PureWeen pushed a commit that referenced this pull request May 21, 2025
…p more than once (#29369)

* Committed the test case and sample

* committed the fix

* Modified the test sample

* Updated the Test condition for windows

* Removed unwanted spaces

* Optimized the fix

* Change the code into modern c#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-map Map / Maps community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/ios
Projects
None yet
5 participants