I've got an app which is hanging, I turned on Hang Detection and got an .ips file and the top of the hang stack has this:
Dispatch queue: com.apple.main-thread (0)
0 __ulock_wait2
7 NSLog
8 _MMKVLogWithLevel
<snip>
MMKV is a 3rd party library being used in the app. But this looks like MMKV is calling NSLog and then that is hanging? Is that correct, if so then how and why is NSLog hanging and how to solve this issue?
Here's an image of the full stack from XCode when the .ips file is imported:
And here is the heaviest stack info when the .ips is opened as a text file:
Heaviest stack for the main thread of the target process:
411 start + 2240 (dyld + 23940) [0x1bcacad84]
411 main + 96 (MyApp + 108384) [0x10232e760]
411 UIApplicationMain + 340 (UIKitCore + 2270528) [0x19ad20540]
411 -[UIApplication _run] + 888 (UIKitCore + 2273028) [0x19ad20f04]
411 GSEventRunModal + 164 (GraphicsServices + 13536) [0x1dd8554e0]
411 CFRunLoopRunSpecific + 608 (CoreFoundation + 211304) [0x1988a6968]
397 __CFRunLoopRun + 1996 (CoreFoundation + 213528) [0x1988a7218]
397 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 (CoreFoundation + 226588) [0x1988aa51c]
397 _dispatch_main_queue_callback_4CF + 44 (libdispatch.dylib + 74168) [0x1a07831b8]
396 _dispatch_main_queue_drain + 1060 (libdispatch.dylib + 75244) [0x1a07835ec]
396 _dispatch_client_callout + 20 (libdispatch.dylib + 15828) [0x1a0774dd4]
396 _dispatch_call_block_and_release + 32 (libdispatch.dylib + 8508) [0x1a077313c]
396 __49-[RCTCxxBridge _prepareModulesWithDispatchGroup:]_block_invoke + 156 (MyApp + 11155392) [0x102db77c0]
396 -[RCTModuleData instance] + 816 (MyApp + 11498212) [0x102e0b2e4]
396 RCTUnsafeExecuteOnMainQueueSync + 52 (MyApp + 11906956) [0x102e6ef8c]
396 __25-[RCTModuleData instance]_block_invoke + 44 (MyApp + 11499132) [0x102e0b67c]
392 -[RCTModuleData setUpInstanceAndBridge:] + 1324 (MyApp + 11490784) [0x102e095e0]
392 __115-[RCTModuleData initWithModuleClass:bridge:moduleRegistry:viewRegistry_DEPRECATED:bundleManager:callableJSModules:]_block_invoke + 36 (MyApp + 11488056) [0x102e08b38]
392 -[MMKVNative init] + 100 (MyApp + 20934364) [0x10370aedc]
392 RCTExecuteOnMainQueue + 52 (MyApp + 11906684) [0x102e6ee7c]
392 __18-[MMKVNative init]_block_invoke + 232 (MyApp + 20934688) [0x10370b020]
392 +[MMKV initializeMMKV:] + 48 (MyApp + 9265708) [0x102bea22c]
392 +[MMKV initializeMMKV:logLevel:] + 80 (MyApp + 9265800) [0x102bea288]
392 _MMKVLogWithLevel(mmkv::MMKVLogLevel, char const*, char const*, int, char const*, ...) + 348 (MyApp + 9518596) [0x102c27e04]
392 NSLog + 56 (Foundation + 602868) [0x1977b42f4]
392 _NSLogv + 164 (Foundation + 603072) [0x1977b43c0]
392 _CFLogvEx3 + 252 (CoreFoundation + 652276) [0x1989123f4]
392 _CFLogvEx2Predicate + 352 (CoreFoundation + 652792) [0x1989125f8]
392 __CFLogCString + 84 (CoreFoundation + 652948) [0x198912694]
392 _logToStderr + 144 (CoreFoundation + 653980) [0x198912a9c]
392 __ulock_wait2 + 8 (libsystem_kernel.dylib + 59708) [0x1e1a7193c]
*392 ??? (<7ABFF6F3-9E55-3D7B-8DB8-8CF19FB41EFE> + 5068548) [0xfffffff008229704]