应用程序在iPhone 5c的主线程上冻结,但在iPhone 6s上不冻结 [英] App freezes on main thread on iPhone 5c but not on iPhone 6s

查看:81
本文介绍了应用程序在iPhone 5c的主线程上冻结,但在iPhone 6s上不冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有导航控制器的应用程序. Swift +目标C

I'm working on an app with a navigation controller. Swift + objective C

重要说明: 在iPhone 5c上进行测试时,这种冻结会100%发生,而在iPhone 6s上进行测试时则不会发生

Important note: This freeze happens 100% when testing on iPhone 5c and never happens when testing on iPhone 6s

场景是:

  1. 转到TableViewController A
  2. 触摸列表中的一项,以到达TableViewController B
  3. 按左上方的箭头返回TVController A
  4. 该应用显示了TableViewController A,但立即冻结了

UI被冻结,但应用程序仍在运行. 如果按暂停"按钮(调试模式),则可以看到线程1(主线程)堆栈为:

The UI is frozen but the app is still running. If I press the Pause button (debug mode), I can see that the Thread 1 (Main thread) stack is:

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.

有什么想法吗?

推荐答案

经过一天的研究, 我终于发现它已链接到MKMapView deinit.

After a day looking into it, I finally found out that it was linked to MKMapView deinit.

后来,我发现这篇帖子涉及一个非常相似的主题:

Later I found this post about a very similar topic:

警告:顶点输出片段着色器无法读取着色器"v_gradient"

根据-神-@mojuba,他发现冻结也与deinit阶段有关,因此提供了DEBUG模式的修复程序.因为这个问题似乎只发生在DEBUG ...

According to - the god - @mojuba , who found that the freeze was also related to the deinit phase offered a fix for the DEBUG mode. 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
  }

请注意,这会导致内存泄漏,因为mapView永远不会被释放并保存在VControllerB类的静态数组中.

NOTE that this produces a memory leak as mapView is never freed and kept within a static array of the VControllerB class.

注2:1月27日,我在使用Xcode 8.2.1时报告了Apple Bug Reporter中的错误.

NOTE 2: I reported the bug in Apple Bug Reporter while using Xcode 8.2.1 in Jan 27.

这篇关于应用程序在iPhone 5c的主线程上冻结,但在iPhone 6s上不冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆