Open awasilik opened 8 months ago
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.
I am also experiencing this issue. In my case I'm seeing the error when clearing and adding MapElements to my map on the second map page load. Thanks to @awasilik for the workaround of commenting out DisconnectHandler().
The problem is the handler constructor and the use of a MapPool.
protected override MauiMKMapView CreatePlatformView()
{
return MapPool.Get() ?? new MauiMKMapView(this);
}
it will reuse the MapView from the pool, but it was constructed with a previous handler that was disposed (virtual view will be null). a work around I found is to overload the DisconnectHandler to prevent the call to MapPool.Add(platformView) in the base class.
I think a good way to fix this problem is to allow the handler to be set outside of the constructor, and we can just set it after we get the map from the pool.
Description
In my company application we have a map control with logic that moves Map to specific region when data loads. We have a custom Handler for which we call DisconnectHandler.
After second time page is opened and region is changed there is a crash with
System.InvalidOperationException: VirtualView cannot be null here
I've prepared a Sandbox application that reproduces the issue easily: https://github.com/awasilik/MauiMapBug
Steps to Reproduce
Crash occurs
Link to public reproduction project repository
https://github.com/awasilik/MauiMapBug
Version with bug
8.0.6 SR1
Is this a regression from previous behavior?
No, this is something new
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iPhone 8 with iOS 15.6 (other iPhones have the same issue)
Did you find any workaround?
Commenting out base.DisconnectHandler(mapView);
in custom map handler.
Relevant log output