aws-amplify / amplify-ui-swift-liveness

This repository offers a UI component for Amazon Rekognition Face Liveness, enabling developers to ensure that only authentic users, and not bad actors using spoofs, can access their services.
https://ui.docs.amplify.aws/swift/connected-components/liveness
Apache License 2.0
9 stars 20 forks source link

App crashing wiith error :- NSInternalInconsistencyException - Call must be made on main thread #156

Closed yogeshelevn closed 2 months ago

yogeshelevn commented 3 months ago

Describe the bug

Hi team, We are using the Amplify SDK (AmplifyUiLiveness) version 1.2.12 and Amplify version 2.29.3. We encountered a crash while performing live verification.

Steps To Reproduce

There is no steps to reproduce this issue.

Expected behavior

App should not crash while performing verification

Swift Liveness Version

1.2.12

Xcode version

15.0.1

Relevant log output

# Crashlytics - Stack trace
# Platform: apple
# Version: 1.1.1 (134)
# Issue: 0f41460f8d53881f83d904467fd1404c
# Session: e3cc880589124cc1925afbce570f1fa7_DNE_0_v2
# Date: Tue Jul 02 2024 14:56:07 GMT+0530 (India Standard Time)

Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x83f20 __exceptionPreprocess
1  libobjc.A.dylib                0x16018 objc_exception_throw
2  Foundation                     0x6de868 _userInfoForFileAndLine
3  UIKitCore                      0x2fad28 -[UIApplication _performAfterCATransactionCommitsWithLegacyRunloopObserverBasedTiming:block:]
4  UIKitCore                      0x2bb54c +[UIViewController _scheduleTransition:]
5  UIKitCore                      0x2bb118 +[UIPresentationController _scheduleTransition:]
6  UIKitCore                      0x2b7974 -[UIPresentationController runTransitionForCurrentState]
7  UIKitCore                      0x3df048 -[UIPresentationController _dismissWithAnimationController:interactionController:target:didFinish:]
8  UIKitCore                      0x8ea740 -[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:]
9  UIKitCore                      0x8e9d18 -[UIViewController _dismissViewControllerWithTransition:from:completion:]
10 UIKitCore                      0x569da4 -[UIViewController dismissViewControllerWithTransition:completion:]
11 UIKitCore                      0x569c20 -[UIViewController dismissViewControllerWithTransition:completion:]
12 UIKitCore                      0x56981c -[UIViewController _performCoordinatedPresentOrDismiss:animated:]
13 UIKitCore                      0x569614 -[UIViewController dismissViewControllerAnimated:completion:]
14 Runner                         0x9dc8 FaceLiveDetectionController.callback(_:) + 45 (FaceLiveDetectionController.swift:45)
15 Runner                         0x9d74 closure #1 in FaceLiveDetectionController.configureFaceDetection()
16 Runner                         0x24ee4 closure #1 in map(detectionCompletion:) + 281 (FaceLivenessDetectionView.swift:281)
17 Runner                         0x8a1d88 partial apply for closure #1 in static AWSPredictionsPlugin.startFaceLivenessSession(withID:credentialsProvider:region:options:completion:) + 42 (AWSPredictionsPlugin+Liveness.swift:42)
18 Runner                         0x8a3654 FaceLivenessSession.receive(result:) + 159 (FaceLivenessSession.swift:159)
19 Runner                         0x8a3030 closure #1 in FaceLivenessSession.init(websocket:signer:baseURL:) + 39 (FaceLivenessSession.swift:39)
20 Runner                         0x8a59e0 closure #1 in WebSocketSession.receive(shouldContinue:) + 45 (WebSocketSession.swift:45)
21 Foundation                     0x465498 closure #1 in NSURLSessionWebSocketTask.receive(completionHandler:)
22 Foundation                     0x4655a8 thunk for @escaping @callee_guaranteed @Sendable (@guaranteed NSURLSessionWebSocketMessage?, @guaranteed Error?) -> ()
23 Foundation                     0x1cbe0 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__
24 Foundation                     0x1caa0 -[NSBlockOperation main]
25 Foundation                     0x1c8a0 __NSOPERATION_IS_INVOKING_MAIN__
26 Foundation                     0x1ab40 -[NSOperation start]
27 Foundation                     0x9f558 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__
28 Foundation                     0x9f1a4 __NSOQSchedule_f
29 libdispatch.dylib              0x12e5c _dispatch_block_async_invoke2
30 libdispatch.dylib              0x3dd4 _dispatch_client_callout
31 libdispatch.dylib              0x72d8 _dispatch_continuation_pop
32 libdispatch.dylib              0x68f4 _dispatch_async_redirect_invoke
33 libdispatch.dylib              0x15894 _dispatch_root_queue_drain
34 libdispatch.dylib              0x1609c _dispatch_worker_thread2
35 libsystem_pthread.dylib        0x48f8 _pthread_wqthread
36 libsystem_pthread.dylib        0x10cc start_wqthread

com.apple.main-thread
0  libsystem_kernel.dylib         0x1808 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x5008 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x4f20 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x4d60 mach_msg + 24
4  CoreFoundation                 0x53f5c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x53600 __CFRunLoopRun + 1208
6  CoreFoundation                 0x52cd8 CFRunLoopRunSpecific + 608
7  GraphicsServices               0x11a8 GSEventRunModal + 164
8  UIKitCore                      0x40a90c -[UIApplication _run] + 888
9  UIKitCore                      0x4be9d0 UIApplicationMain + 340
10 Runner                         0x9210 main + 7 (AppDelegate.swift:7)
11 ???                            0x1b6775e4c (Missing)

com.apple.uikit.eventfetch-thread
0  libsystem_kernel.dylib         0x1808 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x5008 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x4f20 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x4d60 mach_msg + 24
4  CoreFoundation                 0x53f5c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x53600 __CFRunLoopRun + 1208
6  CoreFoundation                 0x52cd8 CFRunLoopRunSpecific + 608
7  Foundation                     0xc7e4c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
8  Foundation                     0xc7c9c -[NSRunLoop(NSRunLoop) runUntilDate:] + 64
9  UIKitCore                      0x41e640 -[UIEventFetcher threadMain] + 420
10 Foundation                     0xde718 __NSThread__start__ + 732
11 libsystem_pthread.dylib        0x606c _pthread_start + 136
12 libsystem_pthread.dylib        0x10d8 thread_start + 8

io.flutter.1.ui
0  libsystem_kernel.dylib         0x1808 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x5008 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x4f20 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x4d60 mach_msg + 24
4  CoreFoundation                 0x53f5c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x53600 __CFRunLoopRun + 1208
6  CoreFoundation                 0x52cd8 CFRunLoopRunSpecific + 608
7  Flutter                        0x2ec7a8 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
8  Flutter                        0x2ebe20 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
9  libsystem_pthread.dylib        0x606c _pthread_start + 136
10 libsystem_pthread.dylib        0x10d8 thread_start + 8

io.flutter.1.raster
0  libsystem_kernel.dylib         0x1808 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x5008 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x4f20 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x4d60 mach_msg + 24
4  CoreFoundation                 0x53f5c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x53600 __CFRunLoopRun + 1208
6  CoreFoundation                 0x52cd8 CFRunLoopRunSpecific + 608
7  Flutter                        0x2ec7a8 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
8  Flutter                        0x2ebe20 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
9  libsystem_pthread.dylib        0x606c _pthread_start + 136
10 libsystem_pthread.dylib        0x10d8 thread_start + 8

io.flutter.1.io
0  libsystem_kernel.dylib         0x1808 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x5008 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x4f20 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x4d60 mach_msg + 24
4  CoreFoundation                 0x53f5c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x53600 __CFRunLoopRun + 1208
6  CoreFoundation                 0x52cd8 CFRunLoopRunSpecific + 608
7  Flutter                        0x2ec7a8 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
8  Flutter                        0x2ebe20 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
9  libsystem_pthread.dylib        0x606c _pthread_start + 136
10 libsystem_pthread.dylib        0x10d8 thread_start + 8

io.worker.1
0  libsystem_kernel.dylib         0x71cc __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x36e4 _pthread_cond_wait + 1228
2  Flutter                        0x58ca4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
3  Flutter                        0x2e60e4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
4  libsystem_pthread.dylib        0x606c _pthread_start + 136
5  libsystem_pthread.dylib        0x10d8 thread_start + 8

io.worker.2
0  libsystem_kernel.dylib         0x71cc __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x36e4 _pthread_cond_wait + 1228
2  Flutter                        0x58ca4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
3  Flutter                        0x2e60e4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
4  libsystem_pthread.dylib        0x606c _pthread_start + 136
5  libsystem_pthread.dylib        0x10d8 thread_start + 8

io.worker.3
0  libsystem_kernel.dylib         0x71cc __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x36e4 _pthread_cond_wait + 1228
2  Flutter                        0x58ca4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
3  Flutter                        0x2e60e4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
4  libsystem_pthread.dylib        0x606c _pthread_start + 136
5  libsystem_pthread.dylib        0x10d8 thread_start + 8

io.worker.4
0  libsystem_kernel.dylib         0x71cc __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x36e4 _pthread_cond_wait + 1228
2  Flutter                        0x58ca4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
3  Flutter                        0x2e60e4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
4  libsystem_pthread.dylib        0x606c _pthread_start + 136
5  libsystem_pthread.dylib        0x10d8 thread_start + 8

io.worker.5
0  libsystem_kernel.dylib         0x71cc __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x36e4 _pthread_cond_wait + 1228
2  Flutter                        0x58ca4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
3  Flutter                        0x2e60e4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
4  libsystem_pthread.dylib        0x606c _pthread_start + 136
5  libsystem_pthread.dylib        0x10d8 thread_start + 8

io.worker.6
0  libsystem_kernel.dylib         0x71cc __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x36e4 _pthread_cond_wait + 1228
2  Flutter                        0x58ca4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
3  Flutter                        0x2e60e4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
4  libsystem_pthread.dylib        0x606c _pthread_start + 136
5  libsystem_pthread.dylib        0x10d8 thread_start + 8

dart:io EventHandler
0  libsystem_kernel.dylib         0x8608 kevent + 8
1  Flutter                        0x57a3e8 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
2  Flutter                        0x5a7f48 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
3  libsystem_pthread.dylib        0x606c _pthread_start + 136
4  libsystem_pthread.dylib        0x10d8 thread_start + 8

io.worker.1
0  libsystem_kernel.dylib         0x71cc __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x36e4 _pthread_cond_wait + 1228
2  Flutter                        0x58ca4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
3  Flutter                        0x2e60e4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
4  libsystem_pthread.dylib        0x606c _pthread_start + 136
5  libsystem_pthread.dylib        0x10d8 thread_start + 8

io.worker.2
0  libsystem_kernel.dylib         0x71cc __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x36e4 _pthread_cond_wait + 1228
2  Flutter                        0x58ca4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
3  Flutter                        0x2e60e4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
4  libsystem_pthread.dylib        0x606c _pthread_start + 136
5  libsystem_pthread.dylib        0x10d8 thread_start + 8

io.worker.3
0  libsystem_kernel.dylib         0x71cc __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x36e4 _pthread_cond_wait + 1228
2  Flutter                        0x58ca4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
3  Flutter                        0x2e60e4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
4  libsystem_pthread.dylib        0x606c _pthread_start + 136
5  libsystem_pthread.dylib        0x10d8 thread_start + 8

io.worker.4
0  libsystem_kernel.dylib         0x71cc __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x36e4 _pthread_cond_wait + 1228
2  Flutter                        0x58ca4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
3  Flutter                        0x2e60e4 (Missing UUID 4c4c44bd55553144a1714204dc08bdb2)
4  libsystem_pthread.dylib        0x606c _pthread_start + 136
5  libsystem_pthread.dylib        0x10d8 thread_start + 8

com.google.firebase.crashlytics.MachExceptionServer
0  libsystem_kernel.dylib         0x1808 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x5008 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x4f20 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x4d60 mach_msg + 24
4  FirebaseCrashlytics            0x174f8 FIRCLSMachExceptionServer + 194 (FIRCLSMachException.c:194)
5  libsystem_pthread.dylib        0x606c _pthread_start + 136
6  libsystem_pthread.dylib        0x10d8 thread_start + 8

com.apple.NSURLConnectionLoader
0  libsystem_kernel.dylib         0x1808 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x5008 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x4f20 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x4d60 mach_msg + 24
4  CoreFoundation                 0x53f5c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x53600 __CFRunLoopRun + 1208
6  CoreFoundation                 0x52cd8 CFRunLoopRunSpecific + 608
7  CFNetwork                      0xfdc90 _CFHostIsDomainTopLevel + 108176
8  Foundation                     0xde718 __NSThread__start__ + 732
9  libsystem_pthread.dylib        0x606c _pthread_start + 136
10 libsystem_pthread.dylib        0x10d8 thread_start + 8

Thread
0  libsystem_kernel.dylib         0x1590 __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x4980 _pthread_wqthread + 364
2  libsystem_pthread.dylib        0x10cc start_wqthread + 8

Thread
0  libsystem_kernel.dylib         0x1590 __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x4980 _pthread_wqthread + 364
2  libsystem_pthread.dylib        0x10cc start_wqthread + 8

DartWorker
0  libsystem_kernel.dylib         0x71cc __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x3710 _pthread_cond_wait + 1272
2  Flutter                        0x6765ec InternalFlutterGpu_Texture_AsImage + 751784
3  Flutter                        0x6b1404 InternalFlutterGpu_Texture_AsImage + 992960
4  Flutter                        0x675fb8 InternalFlutterGpu_Texture_AsImage + 750196
5  libsystem_pthread.dylib        0x606c _pthread_start + 136
6  libsystem_pthread.dylib        0x10d8 thread_start + 8

DartWorker
0  libsystem_kernel.dylib         0x71cc __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x3710 _pthread_cond_wait + 1272
2  Flutter                        0x6765ec InternalFlutterGpu_Texture_AsImage + 751784
3  Flutter                        0x6b1404 InternalFlutterGpu_Texture_AsImage + 992960
4  Flutter                        0x675fb8 InternalFlutterGpu_Texture_AsImage + 750196
5  libsystem_pthread.dylib        0x606c _pthread_start + 136
6  libsystem_pthread.dylib        0x10d8 thread_start + 8

DartWorker
0  libsystem_kernel.dylib         0x71cc __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x3710 _pthread_cond_wait + 1272
2  Flutter                        0x6765ec InternalFlutterGpu_Texture_AsImage + 751784
3  Flutter                        0x6b1404 InternalFlutterGpu_Texture_AsImage + 992960
4  Flutter                        0x675fb8 InternalFlutterGpu_Texture_AsImage + 750196
5  libsystem_pthread.dylib        0x606c _pthread_start + 136
6  libsystem_pthread.dylib        0x10d8 thread_start + 8

DartWorker
0  libsystem_kernel.dylib         0x71cc __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x3710 _pthread_cond_wait + 1272
2  Flutter                        0x6765ec InternalFlutterGpu_Texture_AsImage + 751784
3  Flutter                        0x6b1404 InternalFlutterGpu_Texture_AsImage + 992960
4  Flutter                        0x675fb8 InternalFlutterGpu_Texture_AsImage + 750196
5  libsystem_pthread.dylib        0x606c _pthread_start + 136
6  libsystem_pthread.dylib        0x10d8 thread_start + 8

DartWorker
0  libsystem_kernel.dylib         0x71cc __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x3710 _pthread_cond_wait + 1272
2  Flutter                        0x6765ec InternalFlutterGpu_Texture_AsImage + 751784
3  Flutter                        0x6b1404 InternalFlutterGpu_Texture_AsImage + 992960
4  Flutter                        0x675fb8 InternalFlutterGpu_Texture_AsImage + 750196
5  libsystem_pthread.dylib        0x606c _pthread_start + 136
6  libsystem_pthread.dylib        0x10d8 thread_start + 8

DartWorker
0  libsystem_kernel.dylib         0x71cc __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x3710 _pthread_cond_wait + 1272
2  Flutter                        0x6765ec InternalFlutterGpu_Texture_AsImage + 751784
3  Flutter                        0x60d918 InternalFlutterGpu_Texture_AsImage + 322516
4  Flutter                        0x6b1438 InternalFlutterGpu_Texture_AsImage + 993012
5  Flutter                        0x675fb8 InternalFlutterGpu_Texture_AsImage + 750196
6  libsystem_pthread.dylib        0x606c _pthread_start + 136
7  libsystem_pthread.dylib        0x10d8 thread_start + 8

Thread
0  libsystem_pthread.dylib        0x10c4 start_wqthread + 8320745666

Thread
0  libsystem_kernel.dylib         0x1590 __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x4980 _pthread_wqthread + 364
2  libsystem_pthread.dylib        0x10cc start_wqthread + 8

DartWorker
0  libsystem_kernel.dylib         0x71cc __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x3710 _pthread_cond_wait + 1272
2  Flutter                        0x6765ec InternalFlutterGpu_Texture_AsImage + 751784
3  Flutter                        0x6b1404 InternalFlutterGpu_Texture_AsImage + 992960
4  Flutter                        0x675fb8 InternalFlutterGpu_Texture_AsImage + 750196
5  libsystem_pthread.dylib        0x606c _pthread_start + 136
6  libsystem_pthread.dylib        0x10d8 thread_start + 8

Thread
0  libsystem_pthread.dylib        0x10c4 start_wqthread + 8320745666

Thread
0  libsystem_pthread.dylib        0x10c4 start_wqthread + 8320745666

H11ANEServicesThread
0  libsystem_kernel.dylib         0x1808 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x5008 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x4f20 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x4d60 mach_msg + 24
4  CoreFoundation                 0x53f5c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x53600 __CFRunLoopRun + 1208
6  CoreFoundation                 0x52cd8 CFRunLoopRunSpecific + 608
7  CoreFoundation                 0xc0f04 CFRunLoopRun + 64
8  ANEServices                    0x3ab8 H11ANE::H11ANEServicesThreadStart(H11ANE::H11ANEServicesThreadParams*) + 148
9  libsystem_pthread.dylib        0x606c _pthread_start + 136
10 libsystem_pthread.dylib        0x10d8 thread_start + 8

H11ANEServicesThread
0  libsystem_kernel.dylib         0x1808 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x5008 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x4f20 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x4d60 mach_msg + 24
4  CoreFoundation                 0x53f5c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x53600 __CFRunLoopRun + 1208
6  CoreFoundation                 0x52cd8 CFRunLoopRunSpecific + 608
7  CoreFoundation                 0xc0f04 CFRunLoopRun + 64
8  ANEServices                    0x3ab8 H11ANE::H11ANEServicesThreadStart(H11ANE::H11ANEServicesThreadParams*) + 148
9  libsystem_pthread.dylib        0x606c _pthread_start + 136
10 libsystem_pthread.dylib        0x10d8 thread_start + 8

com.apple.coremedia.sharedRootQueue.47
0  libsystem_kernel.dylib         0x179c semaphore_timedwait_trap + 8
1  libdispatch.dylib              0x43ec _dispatch_sema4_timedwait + 64
2  libdispatch.dylib              0x49e8 _dispatch_semaphore_wait_slow + 76
3  libdispatch.dylib              0x15668 _dispatch_worker_thread + 328
4  libsystem_pthread.dylib        0x606c _pthread_start + 136
5  libsystem_pthread.dylib        0x10d8 thread_start + 8

AwsLogger
0  libsystem_kernel.dylib         0x71cc __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x36e4 _pthread_cond_wait + 1228
2  Runner                         0x1e5910 aws_condition_variable_wait + 76 (condition_variable.c:76)
3  Runner                         0x1de528 aws_condition_variable_wait_pred + 15 (condition_variable.c:15)
4  Runner                         0x1e4644 aws_background_logger_thread + 342 (array_list.inl:342)
5  Runner                         0x1e6908 thread_fn + 183 (thread.c:183)
6  libsystem_pthread.dylib        0x606c _pthread_start + 136
7  libsystem_pthread.dylib        0x10d8 thread_start + 8

AwsEventLoop 1
0  libsystem_kernel.dylib         0x8608 kevent + 8
1  Runner                         0x1ec550 aws_event_loop_thread + 876 (kqueue_event_loop.c:876)
2  Runner                         0x1e6908 thread_fn + 183 (thread.c:183)
3  libsystem_pthread.dylib        0x606c _pthread_start + 136
4  libsystem_pthread.dylib        0x10d8 thread_start + 8

AWSFoundationStreamBridge
0  libsystem_kernel.dylib         0x1808 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x5008 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x4f20 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0x4d60 mach_msg + 24
4  CoreFoundation                 0x53f5c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x53600 __CFRunLoopRun + 1208
6  CoreFoundation                 0x52cd8 CFRunLoopRunSpecific + 608
7  Foundation                     0xc7e4c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
8  Foundation                     0xc7d20 -[NSRunLoop(NSRunLoop) run] + 64
9  Runner                         0x27dacc closure #1 in closure #1 in variable initialization expression of static FoundationStreamBridge.thread + 66 (FoundationStreamBridge.swift:66)
10 Runner                         0x27dc98 thunk for @escaping @callee_guaranteed @Sendable () -> () + 4368243864 (<compiler-generated>:4368243864)
11 Foundation                     0xde718 __NSThread__start__ + 732
12 libsystem_pthread.dylib        0x606c _pthread_start + 136
13 libsystem_pthread.dylib        0x10d8 thread_start + 8

Thread
0  libsystem_kernel.dylib         0x1590 __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x4980 _pthread_wqthread + 364
2  libsystem_pthread.dylib        0x10cc start_wqthread + 8

Crashed: com.google.firebase.crashlytics.ios.exception
0  FirebaseCrashlytics            0x1dad0 FIRCLSProcessRecordAllThreads + 392 (FIRCLSProcess.c:392)
1  FirebaseCrashlytics            0x1deb0 FIRCLSProcessRecordAllThreads + 423 (FIRCLSProcess.c:423)
2  FirebaseCrashlytics            0x14db0 FIRCLSHandler + 34 (FIRCLSHandler.m:34)
3  FirebaseCrashlytics            0xf9e8 __FIRCLSExceptionRecord_block_invoke + 240 (FIRCLSException.mm:240)
4  libdispatch.dylib              0x3dd4 _dispatch_client_callout + 20
5  libdispatch.dylib              0x132c4 _dispatch_lane_barrier_sync_invoke_and_complete + 56
6  FirebaseCrashlytics            0xe990 FIRCLSExceptionRecord + 242 (FIRCLSException.mm:242)
7  FirebaseCrashlytics            0xf4ac FIRCLSExceptionRecordNSException + 126 (FIRCLSException.mm:126)
8  FirebaseCrashlytics            0xe598 FIRCLSTerminateHandler() + 407 (FIRCLSException.mm:407)
9  libc++abi.dylib                0x14068 std::__terminate(void (*)()) + 16
10 libc++abi.dylib                0x1400c std::terminate() + 108
11 libobjc.A.dylib                0x3cafc objc_terminate + 16
12 libdispatch.dylib              0x3de8 _dispatch_client_callout + 40
13 libdispatch.dylib              0x72d8 _dispatch_continuation_pop + 600
14 libdispatch.dylib              0x68f4 _dispatch_async_redirect_invoke + 584
15 libdispatch.dylib              0x15894 _dispatch_root_queue_drain + 392
16 libdispatch.dylib              0x1609c _dispatch_worker_thread2 + 156
17 libsystem_pthread.dylib        0x48f8 _pthread_wqthread + 228
18 libsystem_pthread.dylib        0x10cc start_wqthread + 8

com.apple.coremedia.sharedRootQueue.47
0  libsystem_kernel.dylib         0x179c semaphore_timedwait_trap + 8
1  libdispatch.dylib              0x43ec _dispatch_sema4_timedwait + 64
2  libdispatch.dylib              0x49e8 _dispatch_semaphore_wait_slow + 76
3  libdispatch.dylib              0x15668 _dispatch_worker_thread + 328
4  libsystem_pthread.dylib        0x606c _pthread_start + 136
5  libsystem_pthread.dylib        0x10d8 thread_start + 8

Is this a regression?

No

Regression additional context

No response

OS Version

17.4.1

Device

iphone13

Specific to simulators

No response

Additional context

No response

yogeshelevn commented 2 months ago

@phantumcode I hope you are doing well. I am writing to inform you about this issue. When I am on a call with someone, this issue arises. I hope this will help to rectify the problem. Thanks

harsh62 commented 2 months ago

@yogeshelevn

It seems like something in your call back is not running on the main thread

14 Runner  0x9dc8 FaceLiveDetectionController.callback(_:) + 45 (FaceLiveDetectionController.swift:45)

Can you share your code snippets and validate everything is correctly configured in your controller?

yogeshelevn commented 2 months ago

@harsh62 Thanks for writing back to me. Here is the code snippet. Please check it. I just wanted to inform you that we have created a Flutter app and then integrated this library natively. Thanks for your help; it is much appreciated.

//
//  FaceLiveDetectionController.swift
//  Runner
//
//  Created by Yogesh on 05/12/23.
//

import Foundation
import SwiftUI
import UIKit
import FaceLiveness

class FaceLiveDetectionController: UIViewController {
    var sessionId: String?
    var flutterResult: FlutterResult!
    var hostingController: UIHostingController<FaceLivenessDetectorView>?
    override func viewDidLoad() {
        super.viewDidLoad();
        configureFaceDetection()
    }
    private func configureFaceDetection() {
        if let sessionID = self.sessionId {
            let faceView = FaceLivenessDetectorView(
                sessionID: sessionID,
                region: "ap-south-1",
                disableStartView: true,
                isPresented: .constant(true),
                onCompletion: { result in
                    switch result {
                    case .success:
                        self.callback("success")
                    case .failure(let error):
                        self.callback(error.message)
                    }
                }
            )
            hostingController = createHostingController(with: faceView)
            addHostingControllerAsChild(hostingController!)
            configureConstraints(for: hostingController!.view)
        }

    }

    private func callback(_ res: String) {
        hostingController?.dismiss(animated: true, completion: nil)
        if (res == "success") {
            flutterResult("success")
        } else {
            flutterResult(FlutterError(code: "error", message: res,details: nil))
        }

    }

    private func createHostingController(with rootView: FaceLivenessDetectorView) -> UIHostingController<FaceLivenessDetectorView> {
            return UIHostingController(rootView: rootView)
        }

        private func addHostingControllerAsChild(_ hostingController: UIHostingController<FaceLivenessDetectorView>) {
            addChild(hostingController)
            view.addSubview(hostingController.view)
        }

        private func configureConstraints(for view: UIView) {
            view.translatesAutoresizingMaskIntoConstraints = false
            NSLayoutConstraint.activate([
                view.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 10),
                view.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),
                view.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
                view.trailingAnchor.constraint(equalTo: self.view.trailingAnchor)
            ])
        }
}

Main Delegate file

import UIKit
import Flutter
import Amplify
import AWSCognitoAuthPlugin

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
      do {
            try Amplify.add(plugin: AWSCognitoAuthPlugin())
            try Amplify.configure()
            print("Amplify configured with auth plugin")
        } catch {
            print("Failed to initialize Amplify with \(error)")
              }
      let controller: FlutterViewController = window?.rootViewController as! FlutterViewController
      let methodChannel = FlutterMethodChannel(name: "LIVE_VERIFICATION_CHANNEL", binaryMessenger: controller.binaryMessenger)
      methodChannel.setMethodCallHandler { [weak self] (call, result) in
            if call.method == "startLiveVerification" {
                guard let args = call.arguments as? [String: Any],
                      let sessionId = args["sessionId"] as? String else {
                                 result(FlutterError(code: "INVALID_ARGUMENT", message: "Invalid session Id",details: nil))
                                    return
                                }
                print("session id is \(sessionId)")
                let faceLivenessController = FaceLiveDetectionController()
                faceLivenessController.sessionId = sessionId
                faceLivenessController.flutterResult = result
                faceLivenessController.modalPresentationStyle = .fullScreen
                controller.present(faceLivenessController,
                                                                animated: true,
                                                                completion: nil)
            } else {
              result(FlutterMethodNotImplemented)
            }
          }

    if #available(iOS 10.0, *) {
      UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate
    }

    GeneratedPluginRegistrant.register(with: self)

    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}
harsh62 commented 2 months ago

Your onCompletion if handling UI should run on the main thread.

onCompletion: { result in
                    switch result {
                    case .success:
                        self.callback("success")
                    case .failure(let error):
                        self.callback(error.message)
                    }
                }

It should look something like this.

DispatchQueue.main.async {
                    switch result {
                    case .success:
                        self.callback("success")
                    case .failure(let error):
                        self.callback(error.message)
                    }
}
yogeshelevn commented 2 months ago

@harsh62 will check. Thanks

github-actions[bot] commented 2 months ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.