mirror of
https://github.com/bitwarden/android.git
synced 2025-01-12 11:17:30 +03:00
EC-255 fix crash when scanning TOTP; BeginInvokeOnMainThread doesn't bubble up the exception, just crashes because it throws the exception to the current main thread context; so it was changed to InvokeOnMainThreadAsync which does bubble up the exception. (#1942)
This commit is contained in:
parent
0a64e4c918
commit
b223f5f16e
1 changed files with 7 additions and 2 deletions
|
@ -45,6 +45,8 @@ namespace Bit.App.Pages
|
|||
_autofocusCts = new CancellationTokenSource(TimeSpan.FromMinutes(3));
|
||||
|
||||
var autofocusCts = _autofocusCts;
|
||||
// this task is needed to be awaited OnDisappearing to avoid some crashes
|
||||
// when changing the value of _zxing.IsScanning
|
||||
_continuousAutofocusTask = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
|
@ -52,7 +54,7 @@ namespace Bit.App.Pages
|
|||
while (!autofocusCts.IsCancellationRequested)
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(2), autofocusCts.Token);
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
await Device.InvokeOnMainThreadAsync(() =>
|
||||
{
|
||||
if (!autofocusCts.IsCancellationRequested)
|
||||
{
|
||||
|
@ -73,7 +75,10 @@ namespace Bit.App.Pages
|
|||
{
|
||||
_autofocusCts?.Cancel();
|
||||
|
||||
await _continuousAutofocusTask;
|
||||
if (_continuousAutofocusTask != null)
|
||||
{
|
||||
await _continuousAutofocusTask;
|
||||
}
|
||||
_zxing.IsScanning = false;
|
||||
|
||||
base.OnDisappearing();
|
||||
|
|
Loading…
Reference in a new issue