From bb30e5f8f0867cfb6053c75b61989564fed0af92 Mon Sep 17 00:00:00 2001 From: Biruk Dubale <64862608+callbiruk@users.noreply.github.com> Date: Fri, 18 Dec 2020 08:16:46 -0500 Subject: [PATCH] The alert should be called in the main thread. This fix resolves: (NSException *) exception = 0x0000000280f86df0 name: "NSInternalInconsistencyException" - reason: "Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread." --- packages/local_auth/ios/Classes/FLTLocalAuthPlugin.m | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/local_auth/ios/Classes/FLTLocalAuthPlugin.m b/packages/local_auth/ios/Classes/FLTLocalAuthPlugin.m index aa0c217ef543..c5ec801aab0d 100644 --- a/packages/local_auth/ios/Classes/FLTLocalAuthPlugin.m +++ b/packages/local_auth/ios/Classes/FLTLocalAuthPlugin.m @@ -62,9 +62,15 @@ - (void)alertMessage:(NSString *)message }]; [alert addAction:additionalAction]; } - [[UIApplication sharedApplication].delegate.window.rootViewController presentViewController:alert - animated:YES - completion:nil]; + + @try { + dispatch_async(dispatch_get_main_queue(), ^{ + [[UIApplication sharedApplication].delegate.window.rootViewController presentViewController:alert animated:YES completion:nil]; + }); + } @catch (NSException *exception) { + NSLog(@"Exception presentViewController: %@", exception); + } @finally { + } } - (void)getAvailableBiometrics:(FlutterResult)result {