如何从辅助线程中查找对UIKit实例的调用? [英] How can I find calls to UIKit instances from a secondary thread?

查看:757
本文介绍了如何从辅助线程中查找对UIKit实例的调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程式在iOS 5中崩溃,因为我有一些代码从辅助线程调用UIKit实例。你知道你有这个问题,当你看到以下错误:

My app is crashing in iOS 5 because I have some code that is calling UIKit instances from a secondary thread. You know you have this problem when you see the following error:

bool _WebTryThreadLock(bool),0x811bf20:多个锁在网络线程不允许!请提交错误。现在崩溃...

所以我的问题是什么是一些方法,我可以找到从辅助线程调用UIKit实例的代码?

So my question is what are some ways that I can find the code that is calling the UIKit instances from a secondary thread?

这里有一些我已经尝试过的东西:

Here are some things I’ve tried already:


  1. 注释掉可能是违反规则

  2. 在可能正在处理次要主题的地方新增 assert([NSThread isMainThread]) $ b
  3. _WebTryThreadLock 添加了符号断点

  1. Commented out blocks that could be violating the rule
  2. Added assert([NSThread isMainThread]) in places that might be processing in secondary thread
  3. Added a symbolic breakpoint for _WebTryThreadLock

帮助我找到问题领域。然而,在我的最后崩溃中, _WebTryThreadLock 断点在任何其他线程中没有堆栈跟踪。

These things have helped me to find problem areas. However, in my final crash the _WebTryThreadLock breakpoint has no stack trace in any of the other threads. So, how I can find the code that causing the problem without a stack trace?

感谢您的时间!

推荐答案

您的 assert()可能是最有价值的工具。我已经知道在我的Controller类中的每个方法的开头放一个类似的断言。如果没有找到它,我添加断言到我的View类。如果没有找到它,我将它添加到任何我认为是主线程的模型类。

Your assert() is probably the most valuable tool in this. I've been known to put a similar assertion at the beginning of every method in my Controller classes. If that doesn't find it, I add the assertion to my View classes. If that doesn't find it, I add it to any Model classes that I think are main-thread only.

To @ craig的注释,它声称是一个内部错误可能是准确的。但我认为你是在正确的道路上仔细检查你自己的代码。

To @craig's comment, the fact that it claims to be an internal bug might be accurate. But I think you're on the right path to closely examine your own code first.

这篇关于如何从辅助线程中查找对UIKit实例的调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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