myTargetSDK / mytarget-ios

ios myTarget sdk
GNU Lesser General Public License v3.0
5 stars 5 forks source link

Crashes app on launch (+load) #11

Closed xoridius closed 3 years ago

xoridius commented 3 years ago

SDK initializes itself in MTRGManager +load and immediately accesses UIKit classes from background thread, causing a crash.

Please do not use +load in SDK and let developer decide on the right time for initialization.

Stack trace:

Thread 1 Queue : com.apple.main-thread (serial)
#0  0x00007fff60305cde in __psynch_cvwait ()
#1  0x00007fff60343e49 in _pthread_cond_wait ()
#2  0x00007fff20179ec0 in WAITING_FOR_ANOTHER_THREAD_TO_FINISH_CALLING_+initialize ()
#3  0x00007fff2017acb5 in initializeNonMetaClass ()
#4  0x00007fff2017bd89 in initializeAndMaybeRelock(objc_class*, objc_object*, mutex_tt<false>&, bool) ()
#5  0x00007fff20187879 in lookUpImpOrForward ()
#6  0x00007fff20175d1b in _objc_msgSend_uncached ()
#7  0x00007fff249561d2 in -[_UIContentSizeCategoryPreferenceSystem _updateContentSizeCategory:carPlay:postingNotification:] ()
#8  0x00007fff249560c2 in -[_UIContentSizeCategoryPreferenceSystem _updateContentSizeCategoriesFromUserDefaultsPostingNotification:] ()
#9  0x00007fff24955d0a in -[_UIContentSizeCategoryPreferenceSystem _readAndObservePreferences] ()
#10 0x00007fff2495566a in +[UIContentSizeCategoryPreference system] ()
#11 0x00007fff246ba5fa in -[UIApplication init] ()
#12 0x00007fff246c6202 in UIApplicationInstantiateSingleton ()
#13 0x00007fff246c6723 in _UIApplicationMainPreparations ()
#14 0x00007fff246c6380 in UIApplicationMain ()
#15 0x000000010697af21 in main
#16 0x00007fff2025abbd in start ()
#17 0x00007fff2025abbd in start ()

Thread 5 Queue : MTRGOperationQueue (QOS: UNSPECIFIED) (concurrent)
#0  0x00007fff2017528b in objc_msgSend ()
#1  0x00007fff249560c2 in -[_UIContentSizeCategoryPreferenceSystem _updateContentSizeCategoriesFromUserDefaultsPostingNotification:] ()
#2  0x00007fff24955d0a in -[_UIContentSizeCategoryPreferenceSystem _readAndObservePreferences] ()
#3  0x00007fff2495566a in +[UIContentSizeCategoryPreference system] ()
#4  0x00007fff2429c2e7 in -[UIScreen _defaultTraitCollectionForInterfaceOrientation:inBounds:] ()
#5  0x00007fff2429c0f0 in -[UIScreen _defaultTraitCollectionForInterfaceOrientation:] ()
#6  0x00007fff2429c7ee in -[UIScreen _updateTraits] ()
#7  0x00007fff2429b02f in -[UIScreen _connectScreen] ()
#8  0x00007fff24296c27 in +[UIScreen _FBSDisplayConfigurationConnected:forInitialDisplayContext:andNotify:forceMain:] ()
#9  0x00007fff2429515e in +[UIScreen initialize] ()
#10 0x00007fff20179e53 in CALLING_SOME_+initialize_METHOD ()
#11 0x00007fff2017ad13 in initializeNonMetaClass ()
#12 0x00007fff2017bd89 in initializeAndMaybeRelock(objc_class*, objc_object*, mutex_tt<false>&, bool) ()
#13 0x00007fff20187879 in lookUpImpOrForward ()
#14 0x00007fff20175d1b in _objc_msgSend_uncached ()
#15 0x00000001072f7524 in -[MTRGDeviceDataProvider init] ()
#16 0x0000000107272187 in -[MTRGFingerprintDataProvider init] ()
#17 0x00000001072720b7 in __39+[MTRGFingerprintDataProvider instance]_block_invoke ()
#18 0x0000000109bc974e in _dispatch_client_callout ()
#19 0x0000000109bcac9b in _dispatch_once_callout ()
#20 0x00000001072720a0 in +[MTRGFingerprintDataProvider instance] ()
#21 0x00000001072a6f0a in __22+[MTRGManager initSdk]_block_invoke_2 ()
#22 0x00007fff207fa0be in __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ ()
#23 0x00007fff207f9fb6 in -[NSBlockOperation main] ()
#24 0x00007fff207fcfd2 in __NSOPERATION_IS_INVOKING_MAIN__ ()
#25 0x00007fff207f9200 in -[NSOperation start] ()
#26 0x00007fff207fd947 in __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ ()
#27 0x00007fff207fd46a in __NSOQSchedule_f ()
#28 0x0000000109bd82c5 in _dispatch_block_async_invoke2 ()
#29 0x0000000109bc974e in _dispatch_client_callout ()
#30 0x0000000109bcc066 in _dispatch_continuation_pop ()
#31 0x0000000109bcb47b in _dispatch_async_redirect_invoke ()
#32 0x0000000109bdb1b0 in _dispatch_root_queue_drain ()
#33 0x0000000109bdbb0f in _dispatch_worker_thread2 ()
#34 0x00007fff60340417 in _pthread_wqthread ()
#35 0x00007fff6033f42f in start_wqthread ()
Thread 6#0  0x00007fff6030495e in __workq_kernreturn ()
#1  0x00007fff603404c1 in _pthread_wqthread ()
#2  0x00007fff6033f42f in start_wqthread ()
com.apple.uikit.eventfetch-thread (7)#0 0x00007fff603032ba in mach_msg_trap ()
#1  0x00007fff6030362c in mach_msg ()
#2  0x00007fff212e64d3 in io_hideventsystem_open ()
#3  0x00007fff212afd40 in __IOHIDEventSystemClientRefresh ()
#4  0x00007fff212b0c76 in IOHIDEventSystemClientCreateWithType ()
#5  0x00007fff278732ad in ___getHIDEventSystemClient_block_invoke ()
#6  0x0000000109bc974e in _dispatch_client_callout ()
#7  0x0000000109bcac9b in _dispatch_once_callout ()
#8  0x00007fff27873187 in BKSHIDEventRegisterEventCallbackOnRunLoop ()
#9  0x00007fff24779c7c in -[UIEventFetcher threadMain] ()
#10 0x00007fff2085c8a9 in __NSThread__start__ ()
#11 0x00007fff603438fc in _pthread_start ()
#12 0x00007fff6033f443 in thread_start ()
aserrr commented 3 years ago

Hi, Thank you for reporting this issue. Yes, we do initialize SDK in background by default and didn't expect a crash there. So, we'll go deeper for solution.

In the meantime, you can add following key-value pair into Info.plist file in order to disable autoinitialization: <key>MyTargetSDKAutoInitMode</key> <false/>

aserrr commented 3 years ago

An issue has been fixed in 5.11.2