AnsweredAssumed Answered

Problem closing parent view of map using Arcgis for Xamarin iOS

Question asked by kjeldsenanderssd on Sep 28, 2017

I have a Xamarin Forms application. I've made a iOS ViewRenderer for the Forms view "MapWrapper". The renderer is called MapRenderer. When the containing MapWrapper is created, a new MapView is created inside MapRenderer. The map appears. However, when I detach one of the parents of MapWrapper from the view tree, my iOS application crashes (I've done the same on Android and UWP, but I don't experience the same problem there).

 

According to the error message, a UIKit method has been called from a non-UI thread. I don't see how that can happen from my code. Is there a bug in Arcgis for iOS or am I missing something?

 

part of my renderer code: 

 

protected override void OnElementChanged(ElementChangedEventArgs<MapWrapper> e)
        {
            if (Control == null && e.NewElement != null)
            {
                mapWrapper = e.NewElement;
                mapView = new MapView();

                routeOverlay = new GraphicsOverlay();
                mapView.GraphicsOverlays.Add(routeOverlay);

                markerOverlay = new GraphicsOverlay();
                mapView.GraphicsOverlays.Add(markerOverlay);

                UpdateConfig();
                UpdateMarkers();
                UpdateViewPoint();
                UpdateRoute();

                base.SetNativeControl(mapView);
            }
 

}

 

The application output is this:

 

Unhandled Exception:
UIKit.UIKitThreadAccessException: UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread.
2017-09-28 16:59:48.077 TrApp.iOS[285:17202] Unhandled managed exception:
UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread. (UIKit.UIKitThreadAccessException)
(null)
2017-09-28 16:59:48.078 TrApp.iOS[285:17202] critical: Stacktrace:

2017-09-28 16:59:48.078 TrApp.iOS[285:17202] critical:
Native stacktrace:

2017-09-28 16:59:48.153 TrApp.iOS[285:17202] critical: 0 TrApp.iOS 0x0000000101f05de8 TrApp.iOS + 31661544
2017-09-28 16:59:48.153 TrApp.iOS[285:17202] critical: 1 libsystem_platform.dylib 0x000000018f2e131c _sigtramp + 52
2017-09-28 16:59:48.153 TrApp.iOS[285:17202] critical: 2 libsystem_pthread.dylib 0x000000018f2e7264 pthread_kill + 112
2017-09-28 16:59:48.153 TrApp.iOS[285:17202] critical: 3 libsystem_c.dylib 0x000000018f1919c4 abort + 140
2017-09-28 16:59:48.153 TrApp.iOS[285:17202] critical: 4 TrApp.iOS 0x0000000102007020 xamarin_get_block_descriptor + 7868
2017-09-28 16:59:48.153 TrApp.iOS[285:17202] critical: 5 TrApp.iOS 0x0000000101f42894 mono_pmip + 214108
2017-09-28 16:59:48.154 TrApp.iOS[285:17202] critical: 6 TrApp.iOS 0x0000000101f05bc4 TrApp.iOS + 31660996
2017-09-28 16:59:48.154 TrApp.iOS[285:17202] critical: 7 TrApp.iOS 0x0000000101f04bfc TrApp.iOS + 31656956
2017-09-28 16:59:48.155 TrApp.iOS[285:17202] critical: 8 TrApp.iOS 0x0000000101efd584 TrApp.iOS + 31626628
2017-09-28 16:59:48.155 TrApp.iOS[285:17202] critical: 9 TrApp.iOS 0x00000001003de3b8 TrApp.iOS + 3187640
2017-09-28 16:59:48.155 TrApp.iOS[285:17202] critical: 10 TrApp.iOS 0x0000000102006d74 xamarin_get_block_descriptor + 7184
2017-09-28 16:59:48.155 TrApp.iOS[285:17202] critical: 11 TrApp.iOS 0x0000000102006bf4 xamarin_get_block_descriptor + 6800
2017-09-28 16:59:48.155 TrApp.iOS[285:17202] critical: 12 TrApp.iOS 0x0000000102006bb0 xamarin_get_block_descriptor + 6732
2017-09-28 16:59:48.155 TrApp.iOS[285:17202] critical: 13 TrApp.iOS 0x0000000101e1bc80 TrApp.iOS + 30702720
2017-09-28 16:59:48.156 TrApp.iOS[285:17202] critical: 14 ArcGIS-arm 0x0000000102757288 _ZNKSt3__18functionIFvPvEEclES1_ + 40
2017-09-28 16:59:48.156 TrApp.iOS[285:17202] critical: 15 ArcGIS-arm 0x00000001027ed478 _ZNK16Esri_runtimecore6Common6SignalIKNS_7Mapping8Geo_viewEJEEclERS4_ + 404
2017-09-28 16:59:48.156 TrApp.iOS[285:17202] critical: 16 ArcGIS-arm 0x00000001028056cc _ZN16Esri_runtimecore7Mapping23Geo_view_draw_requested21draw_request_callbackEv + 48
2017-09-28 16:59:48.156 TrApp.iOS[285:17202] critical: 17 ArcGIS-arm 0x000000010311d210 _ZN16Esri_runtimecore12Map_renderer3Map9on_pulse_Ev + 4700
2017-09-28 16:59:48.156 TrApp.iOS[285:17202] critical: 18 ArcGIS-arm 0x000000010312d23c _ZN16Esri_runtimecore12Map_renderer12Pulse_thread8execute_Ev + 128
2017-09-28 16:59:48.156 TrApp.iOS[285:17202] critical: 19 ArcGIS-arm 0x00000001036d4564 _ZN16Esri_runtimecore6Common6Thread11thread_procEPS1_ + 92
2017-09-28 16:59:48.156 TrApp.iOS[285:17202] critical: 20 ArcGIS-arm 0x00000001036d5d64 _ZNSt3__114__thread_proxyINS_5tupleIJPFvPN16Esri_runtimecore6Common6ThreadEES5_EEEEEPvS9_ + 64
2017-09-28 16:59:48.156 TrApp.iOS[285:17202] critical: 21 libsystem_pthread.dylib 0x000000018f2e568c <redacted> + 240
2017-09-28 16:59:48.156 TrApp.iOS[285:17202] critical: 22 libsystem_pthread.dylib 0x000000018f2e559c <redacted> + 0
2017-09-28 16:59:48.156 TrApp.iOS[285:17202] critical: 23 libsystem_pthread.dylib 0x000000018f2e2cb4 thread_start + 4
2017-09-28 16:59:48.156 TrApp.iOS[285:17202] critical:
=================================================================
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.
=================================================================

@

Outcomes