收到内存不足警告后 GPS 跟踪无法工作?
有人注意到这种奇怪的行为吗?我无法 100% 重现这种情况,但这种情况经常发生。我什至不确定这是否与内存不足警告有关。
如何(有时)重现:(在装有 iOS 4.3.3 的 iPhone 4 上,所有应用程序都有 UIBackgroundModes = location
,因此多任务处理已完全启用)
- 启动第一个 GPS 跟踪应用程序(应用程序 A)。开始跟踪
- 启动第二个 GPS 跟踪应用程序(应用程序 B)。开始跟踪
- 启动第三个 GPS 跟踪应用程序(应用程序 C)。开始跟踪
- 走 100 米远
- 站立不动
- 启动另一个占用更多内存和 CPU 的 GPS 应用程序
- 转身并往回走 100 m
- 停止所有 GPS 跟踪应用程序并查看跟踪的跟踪结果
结果:
应用程序 B 和C 两人均成功跑完 200 米。但应用程序 A(我启动的第一个应用程序)仅跟踪 100 m(到我启动第四个 GPS 应用程序的点 5)。
应用程序 A 没有崩溃。当我切换回来时它仍在运行(没有低内存崩溃日志或正常崩溃日志,什么也没有)。在我重新启动应用程序之前,它不再接收位置更新。
然后我用相同的设置再次尝试。但这次应用程序 A、B 和 C 都跟踪了 200 米。
所以我唯一的解释是应用程序 A 在内存不足警告(可能 level=2 ?)之后不再接收任何位置更新。
对于这种奇怪的行为还有其他解释吗?如何修复我的应用程序(应用程序 A),使其在停止后仍能接收位置更新? (重启位置管理器的计时器没有帮助)
Has someone noticed this odd behaviour? I can't reproduce this for 100% but it happens a lot. I'm not even sure if this is related to low memory warnings at all.
How to (sometimes) reproduce: (on an iPhone 4 with iOS 4.3.3, all Apps have UIBackgroundModes = location
so Multitasking is fully enabled)
- Start 1st GPS tracking app (App A). start tracking
- Start 2nd GPS tracking app (App B). start tracking
- Start 3rd GPS tracking app (App C). start tracking
- Walk 100 meters away
- Stand still
- Start another GPS app which is a bit more memory and cpu intensive
- Turn around and walk 100 m back
- Stop all GPS tracking app and see tracked trace result
Result:
App B and C both tracked the full 200 m successfully. But App A (first App I started) only tracked 100 m (to the point 5. where I started the 4th GPS app).
App A did not crash. It was still running when I switched back (there was no low memory crash log or normal crash log, nothing). And it didn't receive location updates anymore until I restarted the app.
Then I did another try with same setup. But this time App A, B and C all tracked 200 meters.
So my only explanation is that App A is not receiving any location updates anymore after a low memory warning (maybe level=2 ?).
Is there an other explanation to this odd behaviour? How can I fix my app (App A) to still receiving location updates after it has been stopped? (a timer to restart location manager doesn't help)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,如果您收到 2 级内存不足警告,操作系统会很快杀死有问题的应用程序。 GPS 报告可能会被阻止,但我对此表示怀疑。
它是否始终是第一个不跟踪的应用程序(示例中的应用程序 A)?
From what I've seen, if you are getting level 2 low memory warnings, the OS is very quick to kill the offending app. There may be a level in between where the GPS reporting is blocked, but I doubt it.
Is it always the first app (app A in your example) that doesn't track?