We have the following problem with a .NET Maui app using the Maps SDK:
When the device resumes from sleeping, we get a hard crash, apparently caused by the AuthenticationManager concurrently accessing the same list from different threads:
System.InvalidOperationException: InvalidOperation_EnumFailedVersion
at System.Collections.Generic.List`1.Enumerator[[System.String, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNextRare()
at System.Collections.Generic.List`1.Enumerator[[System.String, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
at Esri.ArcGISRuntime.Security.AuthenticationManager.AddCredential(Credential credential, CredentialAddedContext context, Boolean syncPersistence)
at Esri.ArcGISRuntime.Security.AuthenticationManager.EndSignIn(SignInTask signInTask, Credential crd, Exception error)
at Esri.ArcGISRuntime.Security.AuthenticationManager.DoSignIn(SignInTask signInTask)
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object )
at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
at System.Threading.ThreadPoolWorkQueue.DispatchItemWithAutoreleasePool(Object , Thread )
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
at System.Threading.Thread.StartCallback()
We're observing this problem only on iOS devices and the problem seems to occur more reliably the more layers are added to the map. Our guess is that the layers try to reinitialize after resume and are all concurrently using the AuthenticationManager to do so.
Is this a known problem or are there any suggestions how to work around this?
This sounds like a problem that has been fixed last year. We made AuthenticationManager more resilient to multi-threaded use in ArcGIS Maps SDK version 200.2+. If you are still using an older version, I recommend upgrading to check if this resolves the problem.
We are indeed still on 200.2 as we are waiting for the 200.5 release. We'll test with 200.3 as that should be doable within our current schedule (migrating to .net 8 will take some time).
Thanks for your reply!
Ah, I just noticed that 200.3 is already on .net 8 - that means it will take us a bit longer to deploy the fix. But at least we now have one more reason to speed up the transition.
FYI 200.5 is out as of today. So you should be good to move. .NET MAUI on .NET 7 is also no longer officially supported by Microsoft, and there's so many great bug fixes in .NET8, you really want to upgrade.
I am facing similar issues on 200.7 and .NET 9 MAUI. Last of them is with ArcGIS Runtime:
Esri.ArcGISRuntime.ArcGISRuntimeException: Invalid argument: Scale is less than or equal to zero.
void ArcGISException.HandleCoreError(CoreError error, bool throwException)
Assembly: Esri.ArcGISRuntime Version: 200.7.0.0 PublicKeyToken: xxxxxxxxxxxxxxxx
void Interop.CheckError(IntPtr errorHandle, bool throwOnFailure, GCHandle wrapperHandle)
void CoreMapView.InteractionZoomToScale(double scale, CoreCoordinate2D screenPoint)
bool MapView.OnGeoViewManipulationDelta(PointF origin, PointF screenLocation, double translateX, double translateY, double scale, double rotation, bool isFlick, DeviceIndependentPointingDevice device)
bool UserInteractionHandler.OnManipulationDelta(PointF origin, PointF screenLocation, double translateX, double translateY, double scale, double rotation, bool isFlick, DeviceIndependentPointingDevice device)
bool AndroidDeviceInteractionHandler.OnTouchEvent(MotionEvent ev)
GeoView(CoreGeoView geoView, Context context, IAttributeSet attr)+(object s, TouchEventArgs e) => { }
Called from: bool IOnTouchListenerImplementor.OnTouch(View v, MotionEvent e)
Application life cycle:
Exception - This event error 09:33:30.000 AM
Esri.ArcGISRuntime.ArcGISRuntimeException: Invalid argument: Scale is less than or equal to zero.
Ui Lifecycle info 09:28:57.738 AM
Window.Activated
Ui Lifecycle info 09:28:57.715 AM
Window.Resumed
Ui Lifecycle info 09:28:34.904 AM
Window.Stopped
Ui Lifecycle info 09:28:33.904 AM
Window.Deactivated
All crashes after resume are random and it is not ArcGIS Maps SDK fault.
I have found workaround for map freezing where suggests handle OnResume() event. Would it be helpful to make some delay inside OnResume()? Do you have some experience of handling application resume issues?