iOS 应用程序在 UICollectionView 代码中冻结,但我没有任何 UICollectionViews

问题描述 投票:0回答:1

每当有人尝试编辑记录时(即当我显示 EditRecordViewController 时),我的一个应用程序就会冻结。我尝试使用 Watchdog 检测挂起的主线程并导致崩溃,以便我可以获得 Firebase Crashlytics 报告,并追踪导致主线程锁定的位置。

可悲的是,当我收到 Watchdog 的 Firebase 崩溃报告时,实际上每个线程都在 Apple 代码中运行,而不是我的代码。我看不到任何会导致我的冻结/死锁的东西。

主线程似乎正在执行一些 UICollectionView 代码,但是 我的应用程序中甚至没有 UICollectionView 。我已经 fgrep 了我的整个代码库只是为了确保。

知道这可能在哪里或正在发生什么吗?

我的编辑屏幕由 UINavigationController 组成,该 UIViewController 作为其根视图控制器。该 UIViewController 嵌入了一个 UITableViewController。

这是它显示的内容:


com.apple.main-thread
0  libobjc.A.dylib                0xa6d0 objc_alloc_init + 36
1  UIKitCore                      0x14e7f8 +[UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:] + 24
2  UIKitCore                      0x14e0a0 -[_UICollectionCompositionalLayoutSolver _createAndCacheLayoutAttributesForItemAtIndexPath:frame:zIndex:] + 152
3  UIKitCore                      0x13a04 __85-[_UICollectionCompositionalLayoutSolver _layoutAttributesForElementsInRect:handler:]_block_invoke + 944
4  UIKitCore                      0x6b799c __85-[_UICollectionCompositionalLayoutSolver _layoutAttributesForElementsInRect:handler:]_block_invoke_2 + 40
5  UIKitCore                      0x484278 _UIRTreeContainerNode::enumerateIndexesIntersecting(CGRect const&, bool*, void (unsigned long, bool*) block_pointer) const + 160
6  UIKitCore                      0x4842b4 _UIRTreeContainerNode::enumerateIndexesIntersecting(CGRect const&, bool*, void (unsigned long, bool*) block_pointer) const + 220
7  UIKitCore                      0x40adb0 -[_UIRTree enumerateIndexesForFramesIntersectingFrame:withBlock:] + 52
8  UIKitCore                      0x11b14 -[_UICollectionCompositionalLayoutSolver _layoutAttributesForElementsInRect:handler:] + 1092
9  UIKitCore                      0x4483a4 -[_UICollectionCompositionalLayoutSolver layoutAttributesForElementsInRect:] + 172
10 UIKitCore                      0x1321c -[UICollectionViewCompositionalLayout layoutAttributesForElementsInRect:] + 112
11 UIKitCore                      0x12840 __45-[UICollectionViewData validateLayoutInRect:]_block_invoke + 136
12 UIKitCore                      0x43ce3c -[UICollectionViewData validateLayoutInRect:] + 1252
13 UIKitCore                      0x2878c -[UICollectionView layoutSubviews] + 220
14 UIKitCore                      0x4420 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1992
15 QuartzCore                     0x9f30 CA::Layer::layout_if_needed(CA::Transaction*) + 500
16 QuartzCore                     0x1d4ac CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 148
17 QuartzCore                     0x2e8d8 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 444
18 QuartzCore                     0x5de80 CA::Transaction::commit() + 648
19 UIKitCore                      0x4fd4f0 _UIApplicationFlushCATransaction + 84
20 UIKitCore                      0x64dd94 _UIUpdateSequenceRun + 84
21 UIKitCore                      0xcb2894 schedulerStepScheduledMainSection + 144
22 UIKitCore                      0xcb1df0 runloopSourceCallback + 92
23 CoreFoundation                 0xd3128 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
24 CoreFoundation                 0xdf7b4 __CFRunLoopDoSource0 + 176
25 CoreFoundation                 0x645e8 __CFRunLoopDoSources0 + 244
26 CoreFoundation                 0x7a0d4 __CFRunLoopRun + 828
27 CoreFoundation                 0x7f3ec CFRunLoopRunSpecific + 612
28 GraphicsServices               0x135c GSEventRunModal + 164
29 UIKitCore                      0x39cf58 -[UIApplication _run] + 888
30 UIKitCore                      0x39cbbc UIApplicationMain + 340
31 HerdBoss                       0xced0 main + 16 (main.m:16)
32 ???                            0x1dd1b0dec (Missing)

以下是其他主题,供参考:

Fatal error: 👮 Main thread was blocked for 2.00s 👮
Crashed: WatchDog
0  libswiftCore.dylib             0x373e4 _assertionFailure(_:_:file:line:flags:) + 264
1  Watchdog                       0x8328 $s8WatchdogAAC9threshold10strictModeABSd_SbtcfcyycfU_TA + 204
2  Watchdog                       0x8348 $sIeg_IeyB_TR + 28
3  Watchdog                       0x8c1c $s8Watchdog10PingThread33_F0B684E1C455B9DE2999D4562E567E94LLC4mainyyF + 816
4  Watchdog                       0x8c3c $s8Watchdog10PingThread33_F0B684E1C455B9DE2999D4562E567E94LLC4mainyyFTo + 28
5  Foundation                     0x5b524 __NSThread__start__ + 716
6  libsystem_pthread.dylib        0x16b8 _pthread_start + 148
7  libsystem_pthread.dylib        0xb88 thread_start + 8


com.apple.uikit.eventfetch-thread
0  libsystem_kernel.dylib         0xca4 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x13b74 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x13e4c mach_msg_overwrite + 540
3  libsystem_kernel.dylib         0x11e8 mach_msg + 24
4  CoreFoundation                 0x79024 __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x7a250 __CFRunLoopRun + 1208
6  CoreFoundation                 0x7f3ec CFRunLoopRunSpecific + 612
7  Foundation                     0x41fb4 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
8  Foundation                     0x41e9c -[NSRunLoop(NSRunLoop) runUntilDate:] + 64
9  UIKitCore                      0x4cfcc8 -[UIEventFetcher threadMain] + 416
10 Foundation                     0x5b524 __NSThread__start__ + 716
11 libsystem_pthread.dylib        0x16b8 _pthread_start + 148
12 libsystem_pthread.dylib        0xb88 thread_start + 8


com.google.firebase.crashlytics.MachExceptionServer
0  HerdBoss                       0x1f5b8c FIRCLSProcessRecordAllThreads + 393 (FIRCLSProcess.c:393)
1  HerdBoss                       0x1f5f6c FIRCLSProcessRecordAllThreads + 424 (FIRCLSProcess.c:424)
2  HerdBoss                       0x1ed440 FIRCLSHandler + 34 (FIRCLSHandler.m:34)
3  HerdBoss                       0x1efc18 FIRCLSMachExceptionServer + 521 (FIRCLSMachException.c:521)
4  libsystem_pthread.dylib        0x16b8 _pthread_start + 148
5  libsystem_pthread.dylib        0xb88 thread_start + 8


com.apple.NSURLConnectionLoader
0  libsystem_kernel.dylib         0xca4 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x13b74 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x13e4c mach_msg_overwrite + 540
3  libsystem_kernel.dylib         0x11e8 mach_msg + 24
4  CoreFoundation                 0x79024 __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x7a250 __CFRunLoopRun + 1208
6  CoreFoundation                 0x7f3ec CFRunLoopRunSpecific + 612
7  CFNetwork                      0x2586f0 _CFURLStorageSessionDisableCache + 60900
8  Foundation                     0x5b524 __NSThread__start__ + 716
9  libsystem_pthread.dylib        0x16b8 _pthread_start + 148
10 libsystem_pthread.dylib        0xb88 thread_start + 8


Thread #1
0  libsystem_kernel.dylib         0x11ac __workq_kernreturn + 8
1  libsystem_pthread.dylib        0xe28 _pthread_wqthread + 364
2  libsystem_pthread.dylib        0xb7c start_wqthread + 8


Thread #2
0  libsystem_kernel.dylib         0x11ac __workq_kernreturn + 8
1  libsystem_pthread.dylib        0xe28 _pthread_wqthread + 364
2  libsystem_pthread.dylib        0xb7c start_wqthread + 8


Thread #3
0  libsystem_kernel.dylib         0x11ac __workq_kernreturn + 8
1  libsystem_pthread.dylib        0xe28 _pthread_wqthread + 364
2  libsystem_pthread.dylib        0xb7c start_wqthread + 8

Thread #4
0  libsystem_kernel.dylib         0x11ac __workq_kernreturn + 8
1  libsystem_pthread.dylib        0xe28 _pthread_wqthread + 364
2  libsystem_pthread.dylib        0xb7c start_wqthread + 8

Thread #5
0  libsystem_kernel.dylib         0x11ac __workq_kernreturn + 8
1  libsystem_pthread.dylib        0xe28 _pthread_wqthread + 364
2  libsystem_pthread.dylib        0xb7c start_wqthread + 8

Thread #6
0  libsystem_kernel.dylib         0x11ac __workq_kernreturn + 8
1  libsystem_pthread.dylib        0xe28 _pthread_wqthread + 364
2  libsystem_pthread.dylib        0xb7c start_wqthread + 8



ios multithreading uicollectionview
1个回答
0
投票

当你在主线程上时,不要在串行队列中编写代码或以同步方式调用 api,这将导致阻塞所有应用程序活动,并可能导致大量崩溃。请始终以异步方式完成工作。每当您想要更新 UI 时,请将 Dispatch 队列与 main.async 一起使用,并且它不会阻止用户同时使用该应用程序。下面是如何在更新 UI 时使用调度队列的示例。

DispatchQueue.main.async {
   self.imageView.image = image
}
© www.soinside.com 2019 - 2024. All rights reserved.