Hello,
I'm using nuget Esri.ArcGISRuntime.Xamarin.Forms v. 100.9.0 on Android platform everything works fine, but on IOS i found bug which I was also able to reproduce in a clean project.
It is this exception:
Exception
- $exception {System.ObjectDisposedException: Cannot access a disposed object. - $exception {System.ObjectDisposedException: Cannot access a disposed object. |
Exception appearing alwayse when i have loaded MapView on current page. Then I go to another page. Then send app to background. Do work and return back to the app. And when app is send from backgroud to foreground it will crash on System.ObjectDisposedException: Cannot access a disposed object.Object name: 'MapView' . On physical device it happen almost everytime on simulator sometimes not.
If I send app to backgroud and current page is page with MapView it works fine.
Example in suffix.
Thanks for your help
T. Zachoval
Solved! Go to Solution.
Hi Tomáš,
I have exactly the same symtoms with my iOS app. Fixed it with a custom renderer for MapView:
[assembly: ExportRenderer(typeof(Esri.ArcGISRuntime.Xamarin.Forms.MapView), typeof(MyMapViewRenderer))]
namespace xxx.Forms.iOS
{
public class MyMapViewRenderer : MapViewRenderer
{
protected override bool ManageNativeControlLifetime => false;
}
}
This is enough to make my app work as expected! Maybe this can help you too.
regards,
Hannes
Hi Tomáš,
I have exactly the same symtoms with my iOS app. Fixed it with a custom renderer for MapView:
[assembly: ExportRenderer(typeof(Esri.ArcGISRuntime.Xamarin.Forms.MapView), typeof(MyMapViewRenderer))]
namespace xxx.Forms.iOS
{
public class MyMapViewRenderer : MapViewRenderer
{
protected override bool ManageNativeControlLifetime => false;
}
}
This is enough to make my app work as expected! Maybe this can help you too.
regards,
Hannes
Hello, Johannes
Your solution works amazing, I am really grateful. Thank you so much for your help.
I wish you happy coding.
Tomas
Hi- Can you share how you implemented your custom renderer? I've been scratching my head for an hour or two.
Thank you for the sample app.
I've been trying to reproduce this with the above provided app. The about page is binding to a Map in the AbouveViewModel, but that property doesn't seem to exist. I added it, so I get a map, and tried navigating around, but not getting the crash.
Do you have an updated sample app with some specific repro steps that demonstrates the problem?
Also we did do some fixes in Update 10, especially around ensuring null-checks, so there's a good chance this issue has been resolved. However I'd like to try and repro in Update 9, just to make sure.
Thanks
...actually ignore that. I was finally able to reproduce in update 9 and 10.
Hi- I'm able to reproduce using MapView, SceneView and ARSceneView. I've tried adding the map views programmatically and removing them when the OnDisappering event fires, but it still throws an error when navigating away from a page that uses a MapView. I've tried opening as a "modal" and it still crashes it. So, it's seems to be a pretty serious bug (for me at least).
Steps to reproduce:
1. Open Page with MapView, SceneView or ARSceneView.
2. Go Back or Close Page
3. Open Another App on Phone. (i.e. Send MapApp to Background)
4. Re-Open MapApp
5. Crash
Runtime 100.10.0
Any updates to a fix? I am getting this also in 100.10.
We've run into this issue ourselves. We'll try the work-around and look forward to a fix in the Runtime.
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'MapView'.**
**Stack trace**:
- at Foundation.NSObject.get_SuperHandle ()
- at UIKit.UIView.get_Bounds ()
- at Esri.ArcGISRuntime.UI.Controls.GeoView.ApplicationDidBecomeActive (System.WeakReference<T>[T] geoview)
- at Esri.ArcGISRuntime.UI.Controls.GeoView+<>c__DisplayClass47_0.<SetupApplicationNotificationHandlers>b__3 (System.Object s, Foundation.NSNotificationEventArgs e)
- at UIKit.UIApplication+Notifications+<>c__DisplayClass4_0.<ObserveDidBecomeActive>b__0 (Foundation.NSNotification notification)
- at Foundation.InternalNSNotificationHandler.Post (Foundation.NSNotification s)
- at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
- at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate)
- at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName)
Just to follow up on this. We'll have a fix for this in Update 11. The above proposed workaround with a renderer is a good way to do it for now - the only downside might be that if you create A LOT of MapView instances, it might leak a bit of memory, but if you're not you should be fine.