Closed
Description
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
- Open Sandbox application
- Click OpenMap button
- Let the region change and press "Go back" button
- Click OpenMap button again
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
System.InvalidOperationException: VirtualView cannot be null here
at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.Maps.IMap, Microsoft.Maui.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Maps.Platform.MauiMKMapView, Microsoft.Maui.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].get_VirtualView()
at Microsoft.Maui.Maps.Handlers.MapHandler.Microsoft.Maui.Maps.Handlers.IMapHandler.get_VirtualView()
at Microsoft.Maui.Maps.Platform.MauiMKMapView.MkMapViewOnRegionChanged(Object sender, MKMapViewChangeEventArgs e)
at MapKit.MKMapView._MKMapViewDelegate.RegionChanged(MKMapView mapView, Boolean animated) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/dotnet/ios/generated-sources/MapKit/MKMapView.g.cs:line 1956
at MapKit.MKMapView.SetRegion(MKCoordinateRegion region, Boolean animated) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/dotnet/ios/generated-sources/MapKit/MKMapView.g.cs:line 759
at Microsoft.Maui.Maps.Handlers.MapHandler.MoveToRegion(MapSpan mapSpan, Boolean animated)
at Microsoft.Maui.Maps.Handlers.MapHandler.MapMoveToRegion(IMapHandler handler, IMap map, Object arg)
at Microsoft.Maui.CommandMapper`2.<>c__DisplayClass6_0[[Microsoft.Maui.Maps.IMap, Microsoft.Maui.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Maps.Handlers.IMapHandler, Microsoft.Maui.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v, Object o)
at Microsoft.Maui.CommandMapper.InvokeCore(String key, IElementHandler viewHandler, IElement virtualView, Object args)
at Microsoft.Maui.CommandMapper.Invoke(IElementHandler viewHandler, IElement virtualView, String property, Object args)
at Microsoft.Maui.Handlers.ElementHandler.Invoke(String command, Object args)
at Microsoft.Maui.Controls.Maps.Map.MoveToRegion(MapSpan mapSpan)
at MapBugApp.MapPage.<MoveMap>b__1_0() in /Users/ADWA/Desktop/MapBugApp/MauiMapBug/MapBugApp/MapPage.xaml.cs:line 24
at Foundation.NSAsyncActionDispatcher.Apply() in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSAction.cs:line 150
at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58
at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94
at MapBugApp.Program.Main(String[] args) in /Users/ADWA/Desktop/MapBugApp/MauiMapBug/MapBugApp/Platforms/iOS/Program.cs:line 13
2024-02-15 15:40:52.268 MapBugApp[99574:28420853] Unhandled managed exception: VirtualView cannot be null here (System.InvalidOperationException)
at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.Maps.IMap, Microsoft.Maui.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Maps.Platform.MauiMKMapView, Microsoft.Maui.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].get_VirtualView()
at Microsoft.Maui.Maps.Handlers.MapHandler.Microsoft.Maui.Maps.Handlers.IMapHandler.get_VirtualView()
at Microsoft.Maui.Maps.Platform.MauiMKMapView.MkMapViewOnRegionChanged(Object sender, MKMapViewChangeEventArgs e)
at MapKit.MKMapView._MKMapViewDelegate.RegionChanged(MKMapView mapView, Boolean animated) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/dotnet/ios/generated-sources/MapKit/MKMapView.g.cs:line 1956
at MapKit.MKMapView.SetRegion(MKCoordinateRegion region, Boolean animated) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/dotnet/ios/generated-sources/MapKit/MKMapView.g.cs:line 759
at Microsoft.Maui.Maps.Handlers.MapHandler.MoveToRegion(MapSpan mapSpan, Boolean animated)
at Microsoft.Maui.Maps.Handlers.MapHandler.MapMoveToRegion(IMapHandler handler, IMap map, Object arg)
at Microsoft.Maui.CommandMapper`2.<>c__DisplayClass6_0[[Microsoft.Maui.Maps.IMap, Microsoft.Maui.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Maps.Handlers.IMapHandler, Microsoft.Maui.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v, Object o)
at Microsoft.Maui.CommandMapper.InvokeCore(String key, IElementHandler viewHandler, IElement virtualView, Object args)
at Microsoft.Maui.CommandMapper.Invoke(IElementHandler viewHandler, IElement virtualView, String property, Object args)
at Microsoft.Maui.Handlers.ElementHandler.Invoke(String command, Object args)
at Microsoft.Maui.Controls.Maps.Map.MoveToRegion(MapSpan mapSpan)
at MapBugApp.MapPage.<MoveMap>b__1_0() in /Users/ADWA/Desktop/MapBugApp/MauiMapBug/MapBugApp/MapPage.xaml.cs:line 24
at Foundation.NSAsyncActionDispatcher.Apply() in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSAction.cs:line 150
at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58
at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94
at MapBugApp.Program.Main(String[] args) in /Users/ADWA/Desktop/MapBugApp/MauiMapBug/MapBugApp/Platforms/iOS/Program.cs:line 13
=================================================================
Native Crash Reporting
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
=================================================================
Native stacktrace:
=================================================================
0x10487e5b0 - /private/var/containers/Bundle/Application/7000E81D-4B95-4035-9FA5-AC7499DC165B/MapBugApp.app/MapBugApp : AppleCryptoNative_X509ImportCollection
0x10486949c - /private/var/containers/Bundle/Application/7000E81D-4B95-4035-9FA5-AC7499DC165B/MapBugApp.app/MapBugApp : AppleCryptoNative_X509ImportCollection
0x1049b7a30 - /private/var/containers/Bundle/Application/7000E81D-4B95-4035-9FA5-AC7499DC165B/MapBugApp.app/MapBugApp : AppleCryptoNative_X509ImportCollection
0x10487dda0 - /private/var/containers/Bundle/Application/7000E81D-4B95-4035-9FA5-AC7499DC165B/MapBugApp.app/MapBugApp : AppleCryptoNative_X509ImportCollection
0x1dc05cd48 - /usr/lib/system/libsystem_platform.dylib : <redacted>
0x1dc074854 - /usr/lib/system/libsystem_pthread.dylib : pthread_kill
0x18b4056ac - /usr/lib/system/libsystem_c.dylib : abort
0x1045562c8 - /private/var/containers/Bundle/Application/7000E81D-4B95-4035-9FA5-AC7499DC165B/MapBugApp.app/MapBugApp : xamarin_find_protocol_wrapper_type
0x1047b4264 - /private/var/containers/Bundle/Application/7000E81D-4B95-4035-9FA5-AC7499DC165B/MapBugApp.app/MapBugApp : AppleCryptoNative_X509ImportCollection
0x104853fbc - /private/var/containers/Bundle/Application/7000E81D-4B95-4035-9FA5-AC7499DC165B/MapBugApp.app/MapBugApp : AppleCryptoNative_X509ImportCollection
0x104568fb8 - /private/var/containers/Bundle/Application/7000E81D-4B95-4035-9FA5-AC7499DC165B/MapBugApp.app/MapBugApp : xamarin_get_original_working_directory_path
0x1048bc4f8 - /private/var/containers/Bundle/Application/7000E81D-4B95-4035-9FA5-AC7499DC165B/MapBugApp.app/MapBugApp : AppleCryptoNative_X509ImportCollection
0x104f984d0 - Unknown
=================================================================
Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x1bb5e6bbc):0x1bb5e6bac c0 03 5f d6 c0 03 5f d6 10 29 80 d2 01 10 00 d4 .._..._..)......
0x1bb5e6bbc e3 00 00 54 fd 7b bf a9 fd 03 00 91 91 ee ff 97 ...T.{..........
0x1bb5e6bcc bf 03 00 91 fd 7b c1 a8 c0 03 5f d6 c0 03 5f d6 .....{...._..._.
0x1bb5e6bdc fd 7b bf a9 fd 03 00 91 50 00 80 d2 01 10 00 d4 .{......P.......
=================================================================
Managed Stacktrace:
=================================================================
=================================================================