mobillium/MobilliumQRCodeReader

[BUG] Thread performance

Closed this issue · 0 comments

Step 1: Describe your environment

  • Xcode version: 14.1
  • iOS version: 16.1
  • MobilliumQRCodeReader Version: 1.1.0
  • Installation method (Cocapods or SPM): Cocoapods

Step 2: Describe the problem

Problem description:

What is the problem?

Thread Performance Checker mentions that calling AVCaptureSession startRunning on the main thread can lead to UI unresponsiveness and this function should be called from background thread.

Steps to reproduce [Good to Know]:

How can we reproduce the problem?
Run the example project and open QRCodeReaderViewController from QR Code Reader button on HomeViewController

Output:

Thread Performance Checker: -[AVCaptureSession startRunning] should be called from background thread. Calling it on the main thread can lead to UI unresponsiveness
PID: 4153, TID: 78651
Backtrace:

3 MobilliumQRCodeReader 0x0000000105527764 $s21MobilliumQRCodeReader0bC14ViewControllerC14viewWillAppearyySbF + 540
4 MobilliumQRCodeReader 0x000000010552780c $s21MobilliumQRCodeReader0bC14ViewControllerC14viewWillAppearyySbFTo + 56
5 UIKitCore 0x000000010c04a8fc -[UIViewController _setViewAppearState:isAnimating:] + 612
6 UIKitCore 0x000000010c04b110 -[UIViewController __viewWillAppear:] + 100
7 UIKitCore 0x000000010bf6d3b0 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_3 + 740
8 UIKitCore 0x000000010cb109f0 -[_UIAfterCACommitBlock run] + 64
9 UIKitCore 0x000000010cb10e24 -[_UIAfterCACommitQueue flush] + 172
10 libdispatch.dylib 0x00000001056ac594 _dispatch_call_block_and_release + 24
11 libdispatch.dylib 0x00000001056add5c _dispatch_client_callout + 16
12 libdispatch.dylib 0x00000001056be808 _dispatch_main_queue_drain + 1316
13 libdispatch.dylib 0x00000001056be2d4 _dispatch_main_queue_callback_4CF + 40
14 CoreFoundation 0x0000000180372cf4 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 12
15 CoreFoundation 0x000000018036d3b0 __CFRunLoopRun + 1956
16 CoreFoundation 0x000000018036c7f4 CFRunLoopRunSpecific + 584
17 GraphicsServices 0x0000000188faec98 GSEventRunModal + 160
18 UIKitCore 0x000000010c6cc5d4 -[UIApplication _run] + 868
19 UIKitCore 0x000000010c6d05cc UIApplicationMain + 124
20 MobilliumQRCodeReader_Example 0x0000000104f98e58 main + 64