[英]App freezes on main thread on iPhone 5c but not on iPhone 6s
I'm working on an app with a navigation controller.我正在开发带有导航控制器的应用程序。 Swift + objective C Swift + 目标 C
Important note: This freeze happens 100% when testing on iPhone 5c and never happens when testing on iPhone 6s重要提示:在 iPhone 5c 上测试时会 100% 发生这种冻结,而在 iPhone 6s 上测试时从未发生过
The scenario is:场景是:
The UI is frozen but the app is still running. UI 被冻结,但应用程序仍在运行。 If I press the Pause button (debug mode), I can see that the Thread 1 (Main thread) stack is:如果我按下暂停按钮(调试模式),我可以看到线程 1(主线程)堆栈是:
0 semaphore_wait_trap
45 UIApplicationMain
46 main
47 start
I don't know where to start investigating so that I can find where the problem is.我不知道从哪里开始调查,以便我可以找到问题所在。
Any ideas?有任何想法吗?
After a day looking into it, I finally found out that it was linked to MKMapView deinit.经过一天的研究,我终于发现它与 MKMapView deinit 相关联。
Later I found this post about a very similar topic:后来我发现了这篇关于一个非常相似主题的帖子:
WARNING: Output of vertex shader 'v_gradient' not read by fragment shader 警告:片段着色器未读取顶点着色器“v_gradient”的输出
According to - the god - @mojuba , who found that the freeze was also related to the deinit phase offered a fix for the DEBUG mode.根据 - 上帝 - @mojuba 的说法,他发现冻结也与 deinit 阶段有关,为 DEBUG 模式提供了修复。 Because this issue seems to happen only in DEBUG...因为这个问题似乎只发生在调试...
I successfully applied his fix to my code as followed:我成功地将他的修复应用到我的代码中,如下所示:
deinit {
#if DEBUG
// Xcode8/iOS10 MKMapView bug workaround
if let mV = locationPickerView.mapView {
VControllerB.unusedObjects.append(mV) // addObject:_mapView];
}
#endif
}
NOTE that this produces a memory leak as mapView is never freed and kept within a static array of the VControllerB class.请注意,这会导致内存泄漏,因为 mapView 永远不会被释放并保存在 VControllerB 类的静态数组中。
NOTE 2: I reported the bug in Apple Bug Reporter while using Xcode 8.2.1 in Jan 27.注意 2:我在 1 月 27 日使用 Xcode 8.2.1 时报告了 Apple Bug Reporter 中的错误。
This is a deadlock.这是一个僵局。 Looks like you use dispatch_sync on main thread.看起来您在主线程上使用 dispatch_sync 。 To fix problem - check other threads.解决问题 - 检查其他线程。 In some thread you will find the code that is waiting when dispatched block ends ...在某些线程中,您会发现分派块结束时正在等待的代码......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.