BreX900 / mek-packages

10 stars 13 forks source link

App crashes when we try to discover Bluetooth devices in IOS Simulator #36

Closed pratikpwr closed 8 months ago

pratikpwr commented 9 months ago

When I try to discover Bluetooth device in ios simulator, the app crashes with following error code in crash report. For the discovering local devices it works well. I have also checked the required permission before initializing terminal.

Exception Type: EXC_CRASH (SIGABRT) 
Exception Codes: 0x0000000000000000, 0x0000000000000000 
Termination Reason: SIGNAL 6 
Abort trap: 6 Terminating Process: pos [12533]

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib              0x7ff8376f4202 __pthread_kill + 10
1   libsystem_pthread.dylib             0x7ff83774cee6 pthread_kill + 263
2   libsystem_c.dylib                   0x7ff800131ef2 __abort + 139
3   libsystem_c.dylib                   0x7ff800131e67 abort + 145
4   StripeTerminal                         0x102515a05 -[SCPTerminal validateInfoPlistForDiscoveryConfiguration:].cold.2 + 104
5   StripeTerminal                         0x1024043b1 -[SCPTerminal validateInfoPlistForDiscoveryConfiguration:] + 188
6   StripeTerminal                         0x102404824 -[SCPTerminal discoverReaders:delegate:completion:] + 87
7   mek_stripe_terminal                    0x101b97a03 DiscoveryDelegatePlugin.onListen(_:_:) + 515 (DiscoveryDelegatePlugin.swift:40)
8   mek_stripe_terminal                    0x101bf20db implicit closure #2 in implicit closure #1 in TerminalPlugin.setupDiscoverReaders() + 75 (TerminalPlugin.swift:88)
9   mek_stripe_terminal                    0x101ba320f closure #1 in DiscoverReadersControllerApi.setHandler(_:_:) + 783 (TerminalApi.swift:254)
10  mek_stripe_terminal                    0x101ba2405 ControllerHandler.onListen(withArguments:eventSink:) + 149 (TerminalApi.swift:86)
11  mek_stripe_terminal                    0x101ba254e @objc ControllerHandler.onListen(withArguments:eventSink:) + 222
12  Flutter                                0x108def4d4 invocation function for block in SetStreamHandlerMessageHandlerOnChannel(NSObject<FlutterStreamHandler>*, NSString*, NSObject<FlutterBinaryMessenger>*, NSObject<FlutterMethodCodec>*, NSObject<FlutterTaskQueue>*) + 524
13  Flutter                                0x1087b0f52 invocation function for block in flutter::PlatformMessageHandlerIos::HandlePlatformMessage(std::_LIBCPP_ABI_NAMESPACE::unique_ptr<flutter::PlatformMessage, std::_LIBCPP_ABI_NAMESPACE::default_delete<flutter::PlatformMessage>>) + 94
14  libdispatch.dylib                   0x7ff80013be40 _dispatch_call_block_and_release + 12
15  libdispatch.dylib                   0x7ff80013d0d9 _dispatch_client_callout + 8
16  libdispatch.dylib                   0x7ff80014cb86 _dispatch_main_queue_drain + 1330
17  libdispatch.dylib                   0x7ff80014c646 _dispatch_main_queue_callback_4CF + 31
18  CoreFoundation                      0x7ff8003b26cc __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
19  CoreFoundation                      0x7ff8003acfbe __CFRunLoopRun + 2429
20  CoreFoundation                      0x7ff8003ac264 CFRunLoopRunSpecific + 560
21  GraphicsServices                    0x7ff809b4024e GSEventRunModal + 139
22  UIKitCore                              0x1050827bf -[UIApplication _run] + 994
23  UIKitCore                              0x1050875de UIApplicationMain + 123
24  pos                                    0x1009e186f main + 63 (AppDelegate.swift:5)
25  dyld_sim                               0x100ba0384 start_sim + 10
26  dyld                                   0x10867f41f start + 1903

checked about SIGABRT error happens due to https://developer.apple.com/documentation/xcode/understanding-the-exception-types-in-a-crash-report#EXCCRASH-SIGABRT

Simulator : ios 16.4 Flutter version : 3.13.7 Mek package version : 3.1.1

pratikpwr commented 9 months ago

Got the issue. I did not added the following in Info.plist. But I guess it should have been handle and proper TerminalException to be thrown

<key>UIBackgroundModes</key>
    <array>
        <string>bluetooth-central</string>
    </array>
SimoneBressan commented 8 months ago

It seems like an error in the official iOS SDK, there's nothing I can do about it :(