PM-3350 Commented event collection upload on the timer and when sending the app to background to see if that prevents the app from crashing on release mode.

This commit is contained in:
Federico Maccaroni 2024-01-25 13:22:42 -03:00
parent 05677f93c5
commit c74636ffa5
No known key found for this signature in database
GPG key ID: 5D233F8F2B034536

View file

@ -462,20 +462,21 @@ namespace Bit.iOS
_eventTimer?.Invalidate();
_eventTimer?.Dispose();
_eventTimer = null;
MainThread.BeginInvokeOnMainThread(() =>
{
try
{
_eventTimer = NSTimer.CreateScheduledTimer(60, true, timer =>
{
_eventService?.UploadEventsAsync().FireAndForget();
});
}
catch (Exception ex)
{
LoggerHelper.LogEvenIfCantBeResolved(ex);
}
});
// TODO: Uncomment, this is just a test to see if this is causing the background crash on release when sending the app to background
//MainThread.BeginInvokeOnMainThread(() =>
//{
// try
// {
// _eventTimer = NSTimer.CreateScheduledTimer(60, true, timer =>
// {
// _eventService?.UploadEventsAsync().FireAndForget();
// });
// }
// catch (Exception ex)
// {
// LoggerHelper.LogEvenIfCantBeResolved(ex);
// }
//});
}
private async Task StopEventTimerAsync()
@ -485,19 +486,20 @@ namespace Bit.iOS
_eventTimer?.Invalidate();
_eventTimer?.Dispose();
_eventTimer = null;
if (_eventBackgroundTaskId > 0)
{
UIApplication.SharedApplication.EndBackgroundTask(_eventBackgroundTaskId);
_eventBackgroundTaskId = 0;
}
_eventBackgroundTaskId = UIApplication.SharedApplication.BeginBackgroundTask(() =>
{
UIApplication.SharedApplication.EndBackgroundTask(_eventBackgroundTaskId);
_eventBackgroundTaskId = 0;
});
await _eventService.UploadEventsAsync();
UIApplication.SharedApplication.EndBackgroundTask(_eventBackgroundTaskId);
_eventBackgroundTaskId = 0;
// TODO: Uncomment, this is just a test to see if this is causing the background crash on release when sending the app to background
//if (_eventBackgroundTaskId > 0)
//{
// UIApplication.SharedApplication.EndBackgroundTask(_eventBackgroundTaskId);
// _eventBackgroundTaskId = 0;
//}
//_eventBackgroundTaskId = UIApplication.SharedApplication.BeginBackgroundTask(() =>
//{
// UIApplication.SharedApplication.EndBackgroundTask(_eventBackgroundTaskId);
// _eventBackgroundTaskId = 0;
//});
//await _eventService.UploadEventsAsync();
//UIApplication.SharedApplication.EndBackgroundTask(_eventBackgroundTaskId);
//_eventBackgroundTaskId = 0;
}
catch (Exception ex)
{