FeatureTable.AddFeatureAsync() throws exception on iOS when running in background

725
1
Jump to solution
03-05-2019 12:34 PM
JamisonLovely
New Contributor

I'm building a data collection app fairly similar to this sample app (downloaded map for offline work, location tracking, recording survey data at a point location) using Xamarin Forms. It periodically records the user's location, and while that works just fine if the app is in the foreground, while responding to location change events in the background calling FeatureTable.AddFeatureAsync() throws an ArcGISRuntimeException with the message "Some kind of disk I/O error occurred: disk I/O error". The stack trace is:

at Esri.ArcGISRuntime.ArcGISException.HandleCoreError (RuntimeCoreNet.GeneratedWrappers.CoreError error, System.Boolean throwException) [0x00013] in C:\daily_r\api_xam\dotnet\api\src\Esri.ArcGISRuntime\Esri.ArcGISRuntime.Shared\ArcGISExceptions.cs:75
at RuntimeCoreNet.GeneratedWrappers.Interop.CheckError (System.IntPtr errorHandle, System.Boolean throwOnFailure, System.Runtime.InteropServices.GCHandle wrapperHandle) [0x00025] in C:\daily_r\api_xam\dotnet\api_generated_interop\managed_wrappers\Interop.cs:104
at RuntimeCoreNet.GeneratedWrappers.CoreTask.Get () [0x00019] in C:\daily_r\api_xam\dotnet\api_generated_interop\managed_wrappers\CoreTask.cs:249
at Esri.ArcGISRuntime.Internal.CoreTaskExtensions+TaskCompletedCallbackHandler`1.OnCompleted (System.Object sender, System.EventArgs e) [0x00034] in C:\daily_r\api_xam\dotnet\api\src\Esri.ArcGISRuntime\Esri.ArcGISRuntime.Shared\Internal\CoreTaskExtensions.cs:188
--- End of stack trace from previous location where exception was thrown ---
at (wrapper unknown) System.Object.gsharedvt_out()
at Esri.ArcGISRuntime.Internal.CoreTaskExtensions+TaskCompletedCallbackHandler`1+<CreateInternal>d__7.MoveNext () [0x00038] in C:\daily_r\api_xam\dotnet\api\src\Esri.ArcGISRuntime\Esri.ArcGISRuntime.Shared\Internal\CoreTaskExtensions.cs:173
--- End of stack trace from previous location where exception was thrown ---
at Esri.ArcGISRuntime.Data.FeatureTable+<AddFeatureAsync>d__62.MoveNext () [0x00048] in C:\daily_r\api_xam\dotnet\api\src\Esri.ArcGISRuntime\Esri.ArcGISRuntime.Shared\Data\FeatureTable.cs:488
--- End of stack trace from previous location where exception was thrown ---
at [redacted].Models.LocationRecorder+<AddFeature>d__16.MoveNext () [0x00074] in [redacted]\Models\LocationRecorder.cs:64

0 Kudos
1 Solution

Accepted Solutions
JamisonLovely
New Contributor

Turns out that it's not running in the background in general that causes this problem, but rather the specific case that the app is running in the background because the phone is locked with a passcode. The fix is for the connections to any geodatabases to be opened using SQLiteOpenFlags.ProtectionCompleteUnlessOpen, but in the absence of a patch to resolve this I managed to work around the issue by setting the file protection attribute of the geodatabase file and the containing folder hierarchy to NSFileProtectionCompleteUnlessOpen.

View solution in original post

0 Kudos
1 Reply
JamisonLovely
New Contributor

Turns out that it's not running in the background in general that causes this problem, but rather the specific case that the app is running in the background because the phone is locked with a passcode. The fix is for the connections to any geodatabases to be opened using SQLiteOpenFlags.ProtectionCompleteUnlessOpen, but in the absence of a patch to resolve this I managed to work around the issue by setting the file protection attribute of the geodatabase file and the containing folder hierarchy to NSFileProtectionCompleteUnlessOpen.

0 Kudos