I'm getting an UnobservedTaskException "Unable to synchronize replica" when synchronizing a replica (upload edits).
I don't always get the error - only occasionally. I'm using ArcGIS Runtime 100.3 and AGOL hosted feature layers.
at Esri.ArcGISRuntime.Http.ArcGISHttpClientHandler.ArcGISClientHandlerInternal.<SendAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Net.Http.HttpClient.<FinishSendAsyncUnbuffered>d__59.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Esri.ArcGISRuntime.Internal.RequestRequiredHandler.<IssueRequestAndRespond>d__14.MoveNext()
I'm watching for unobserved task exceptions this way:
TaskScheduler.UnobservedTaskException += (sender, args) =>
{
Logger.Warn($"TaskScheduler.UnobservedTaskException:\n{args.Exception.Message}\n{args.Exception.InnerException?.Message}");
#if DEBUG
DisplayError($"Unobserved task exception: {args.Exception.Message}\n{args.Exception.InnerException?.Message}");
#endif
};
Hi Jeff,
Can you please share a code snippet so I can better understand what's going on?
Thanks,
Nathan C.
Are you calling any Task-returning methods without awaiting their result? (ie missing an 'await' - you should see warnings in your build about that)
I don't believe I'm calling any task returning methods without await their result.
Below is the code from the view model for a command that is bound to the view using data binding. Note that the code below is 'simplified' so that is sufficiently illustrative of what I'm trying to achieve.
There are no warnings in the build about non-awaited tasks.
I have verified that exceptions are caught by putting a throw new Exception() inside of the second SubmitEditsAsync(Map map), and the error is caught and handled. It looks like the error is occurring outside of the call stack (on a separate thread) in the ArcGIS Runtime.
private async void SubmitEditsAsync(OfflineArea offlineArea)
{
try
{
await SubmitEditsAsync(offlineArea.Map);
}
catch (Exception e)
{
await _dialogHandler.ShowAlertAsync(e);
}
}
private async Task SubmitEditsAsync(Map map)
{
// Create the sync task
var syncTask = await OfflineMapSyncTask.CreateAsync(map);
syncTask.SyncOfflineMap(new OfflineMapSyncParameters() { SyncDirection = SyncDirection.Upload });
// Create the job
var job = syncTask.SyncOfflineMap(new OfflineMapSyncParameters()
{
RollbackOnFailure = true,
SyncDirection = SyncDirection.Upload
});
// Await result
var result = await job.GetResultAsync();
}
I am also seeing intermittent sync (and initial download) issues. I am not able to duplicate it reliably as it happens maybe 1 in 10 times when syncing. I have noticed several observations (these were all tested using UWP 100.3):
The stack trace I get on a failed download is this:
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.IO.WinRtToNetFxStreamAdapter.<ReadAsyncInternal>d__43.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.IO.BufferedStream.<ReadFromUnderlyingStreamAsync>d__47.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Esri.ArcGISRuntime.Internal.FileRequestHelper.<DownloadAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Esri.ArcGISRuntime.Internal.FileRequestHelper.<DownloadAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Esri.ArcGISRuntime.Internal.RequestRequiredHandler.<IssueRequestAndRespond>d__14.MoveNext()
I have added some code to my app to catch/store these exceptions and the download/sync log entries so that I can begin collecting more data about what is happening during user testing.