iOS 应用程序从后台返回后冻结的原因是什么?
这是一个非常困难的问题,因为它并不是每次都会发生。
当应用程序刚启动时,从后台返回时,没有任何卡顿。 在后台运行一段时间后,当我重新激活它时,整个 UI 会冻结一段时间,甚至活动指示器也没有动画。随着时间的推移,这种冻结时间会越来越长,最终导致应用程序因未及时恢复而被 iOS 终止。
我想了解应用程序无响应的一般原因是什么,特别是如果应用程序支持后台运行功能并在后台运行一段时间后重新激活。
看来我错过了一些应该尊重的基本技术,以避免冻结问题。
更新:我怀疑将 UIImage
保存到 Core Data 对象中是否是主要原因。在启动时,它是不可见的,但是,随着时间的推移,在仍然引用 UIImage
的同时,会执行大量 saveManagedObjectContext
操作。 也许我应该听从不要在 Core Data 中保存任何图像的指示?
This is very difficult issue, since it doesn't occur every time.
When an app is just launched, returning from background, it is fine without any freezing.
After some time being in background, when I re-activate it, the whole UI is frozen for while, even the activity indicator is not animating. As time goes on, this freezing gets longer and finally causes the app to be terminated by iOS for not resuming in time.
I would like to learn what are the generic causes of an app to be unresponsive, especially if the app is supporting background running feature and re-activating after a period of being in background.
It looks like I have missed some fundamental techniques that should be respected to avoid freezing problems.
UPDATE: I am suspicious if saving UIImage
into Core Data object can be the main reason. At launch, it's not visible, however, as time passes, numerous saveManagedObjectContext
are performed while UIImage
is still referenced.
Maybe I should have listened to the instruction not to save any image in Core Data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查崩溃日志,如果您收到此
异常代码:0x8badf00d
,那么您的应用程序很可能在启动或在后台移动或终止时花费了很多时间,实际上应用程序在启动/关闭时花费了很多时间iOS暂停它和我们的应用程序冻结,文档中没有这样的时间定义,但根据我的经验,它不应超过 4-5 秒。检查您的应用程序委托 applicationDidFinishLaunch 或多任务委托是否有一些代码需要时间才能完成。有关更多信息,请访问这些
http://developer.apple.com/ Library/ios/#technotes/tn2151/_index.html
http://en.wikipedia.org /wiki/Hexspeak
check for your crash log if you are getting this
Exception Codes: 0x8badf00d
then its most probably your application is taking much time either in launch or while moving in background or terminate, actually app take much time in launch/shut iOS suspend it and our app freeze, there is no such time define in documents but as i experienced it should not be more then 4-5 seconds. check your app delegate applicationDidFinishLaunch or multitasking delegates there is some code which is taking time in completion. For more info lokk at these
http://developer.apple.com/library/ios/#technotes/tn2151/_index.html
http://en.wikipedia.org/wiki/Hexspeak