使用 Instruments,我如何知道是什么导致我的 iPhone 应用程序冻结?
当我的 iPhone 应用程序从后台进入活动状态时,UI 往往会“冻结”。如何使用 Instruments 找出冻结原因?我应该使用什么仪器?我需要在“仪器”面板中查看哪些关键列?
My iPhone app tends to 'freeze up' the UI when comes into the active state from the background. How can I use Instruments to find out the cause of the freeze? What instrument should I use? What are the key columns I need to look at in the Instruments panel?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当应用程序进入后台时,系统会截取当前 UI 的屏幕截图。只要 AppDelegate 的方法 (applicationDidBecomeActive...) 执行,当应用程序变为活动状态时,就会显示该屏幕截图。
如果在醒来时您想要运行一些长时间运行的操作,请考虑在后台线程中运行它。不要执行同步网络连接。如果您的 UI 依赖于此处理,请考虑显示模式视图控制器以及一些“请稍候...”类型的消息。
您不需要仪器来进行此分析,只需在调试器中运行应用程序,并在“冻结”时暂停调试。检查堆栈跟踪。
As app goes into background, system makes a screenshot of current UI. That screenshot is displayed when the app becomes active, for as long as the AppDelegate's methods (applicationDidBecomeActive...) executes.
If, on waking up, you want to run some long-running action, consider running it in a background thread. Do not execute synchronous network connections. If your UI depends on this processing, consider showing modal view-controller with some "Please wait..." kind of message.
You do not need Instruments for this analysis, simply run the app in debuger, and pause debugging while it's "frozen". Examine stack traces.