Good Morning.
I have a Xamarin Forms app. I am also using the Shell control to host my pages.
The Shell provides a tab page like interface. I have four pages in the Shell. The issue I am seeing is as I move between these pages and I return to the page hosting your MapView control I get the following.
System.ObjectDisposedException
Message=Cannot access a disposed object.
Object name: 'ThinkGeo.UI.Android.MapView'.
The page is still in scope as it’s ctor is not fired again and all that is fired are the OnAppearing and onDisappearing methods. I assume you are a little quick to dispose the platforms implementation of the MapView control??
Here are the details of how my Shell is setup.
<FlyoutItem Route="main"
FlyoutDisplayOptions="AsMultipleItems"
Title="FlyoutItem">
<ShellContent Title="Selected Jobs"
Icon="Job.png"
ContentTemplate="{DataTemplate JobsView:SelectedJobsPage}" />
<ShellContent Title="Maps"
Icon="MapIconSmall.png"
ContentTemplate="{DataTemplate map:MapPage}" />
<ShellContent Title="Chat"
Icon="Chat.png"
ContentTemplate="{DataTemplate chat:ChatPage}" />
<ShellContent Title="Browse"
Icon="tab_feed.png"
ContentTemplate="{DataTemplate localViews:ItemsPage}" />
</FlyoutItem>
The use of ContentTemplate and a DataTemplate for the pages means the pages are Lazy Instantiated. I have switched that out to normal instantiation and it did not change the outcome.
My map page xaml is:
<ContentPage.Content>
<ThinkGeo:MapView x:Name="mapView"
VerticalOptions="FillAndExpand"
MapLongPress="mapView_MapLongPress" />
</ContentPage.Content>
and the page is quite normal and is very similar to your samples. I would not expect the MapView control to go out of scope and get disposed when the page it is on is still in scope.
In addition to the above issue I am also seeing the following during the initial MapView setup. As per your samples I am adding Overlays and Layers along with 4 features. This is all being done from the OnAppearing method wrapped in a first time if statement check.
System.ObjectDisposedException
Message=Cannot access a disposed object.
Object name: 'ThinkGeo.UI.Android.LayerTileView'.
This is not occurring every time but “most of the time”. I cannot see a pattern to the frequency.
I am currently using the OSM overlay if that is important.
This is happening on Android at the moment and I am unable to confirm if it occurring on iOS as I have a pending bug on iOS and unable to test there.
I hope this is enough for you?
If not I am more than happy to provide further details.
Cheers
Chris …
Here are my env details:
Microsoft Visual Studio Professional 2019
Version 16.9.4
VisualStudio.16.Release/16.9.4+31205.134
Microsoft .NET Framework
Version 4.8.04084
Xamarin 16.9.000.273 (d16-9@1bba9e0)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Templates 16.9.72 (426ebf6)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.
Xamarin.Android SDK 11.2.2.1 (d16-9/877f572)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: 5e9cb6d
Java.Interop: xamarin/java.interop/d16-9@54f8c24
ProGuard: Guardsquare/proguard/v7.0.1@912d149
SQLite: xamarin/sqlite/3.34.1@daff8f4
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-9@d210f11
Xamarin.iOS and Xamarin.Mac SDK 14.14.2.5 (3836759d4)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
ThinkGeo.UI.XamarinForms v12.3.10
Xamarin Forms v4.8.0.1687