Hello @Connor Patchett ,
On iOS, app suspension and the main RunLoop’s scheduling can delay or stall UI updates; if a backgrounded network await never completes, InvokeAsync(StateHasChanged) waits and the overlay stays up.
I recommend adding timeouts/cancellation to ensure the UI clears.
private async Task Sync()
{
using var cts = new CancellationTokenSource(TimeSpan. FromSeconds(10));
try
{
showLoadingRipple = true;
syncIconClass = "spin-image";
selectedNotice = null;
await InvokeAsync(StateHasChanged);
// Pass cancellation token to all async operations
await ListUserAlerts(cts.Token);
await DriversCompanionLogin(cts.Token);
await PopupNotices(cts.Token);
}
catch (OperationCanceledException)
{
// Handle timeout gracefully
await LogAsync("Sync operation timed out");
}
catch (Exception ex)
{
await LogAsync($"Sync error: {ex.Message}");
}
finally
{
// Ensure UI updates on main thread for iOS
await MainThread.InvokeAsync(() =>
{
showLoadingRipple = false;
syncIconClass = string.Empty;
StateHasChanged();
});
}
}
For more robust iOS support, you might want to explore using background URL sessions for network operations that need to complete even when the app is suspended.
While this is not a Microsoft website, it is the official site of Apple.