显示键盘时转动设备时 iPhone 应用程序崩溃
我有一个带有 webview 的 iPhone 应用程序,该应用程序会在某个时候重定向到论坛。
我注意到执行以下步骤时应用程序会崩溃:
1) 浏览论坛 (vBulletin)
2) 打开一个线程并尝试发布消息
3)点击文本区域,键盘就会显示出来 4) 然后快速打字和/或转动设备
现在我的 iPhone 应用程序崩溃了。注意:崩溃只出现在很长的线程中,所以一定是内存或CPU的问题?
不管怎样,我不知道在哪里搜索问题,因为 XCode 4 没有显示任何崩溃日志!其次,当通过 Xcode(在设备上)运行应用程序时,它会崩溃,但不会显示任何错误...崩溃无法通过模拟器重现(当然)。
遇到这样的问题怎么解决呢?
安慰:
May 10 00:23:36 unknown SpringBoard[29] <Warning>: Received memory warning. Level=1
May 10 00:23:36 unknown MobilePhone[582] <Warning>: Received memory warning. Level=1
May 10 00:23:37 unknown configd[25] <Notice>: jetsam: kernel memory event (91), free: 1198, active: 7537, inactive: 3482, purgeable: 0, wired: 17615
May 10 00:23:37 unknown SpringBoard[29] <Warning>: Received memory warning. Level=2
May 10 00:23:37 unknown MobilePhone[582] <Warning>: Received memory warning. Level=2
May 10 00:23:38 unknown configd[25] <Notice>: jetsam: kernel termination snapshot being created
May 10 00:23:38 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.apple.mobilephone[0xa185]) Exited: Killed: 9
May 10 00:23:38 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.skype.skype[0xf18]) Exited: Killed: 9
May 10 00:23:38 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.myCompanygmbh.myTestApp[0x9c47]) Bug: launchd_core_logic.c:3795 (24506):0
May 10 00:23:39 unknown com.apple.debugserver-50[598] <Warning>: 1 [0256/1503]: error: ::read ( 4, 0x2ffb19f0, 1024 ) => -1 err = Bad file descriptor (0x00000009)
May 10 00:23:39 unknown SpringBoard[29] <Warning>: Application 'Phone' exited abnormally with signal 9: Killed: 9
May 10 00:23:39 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.myCompanygmbh.myTestApp[0x9c47]) Bug: launchd_core_logic.c:3794 (24506):3
May 10 00:23:39 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.myCompanygmbh.myTestApp[0x9c47]) Bug: launchd_core_logic.c:3202 (24506):10
May 10 00:23:39 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.myCompanygmbh.myTestApp[0x9c47]) Working around 5020256. Assuming the job crashed.
May 10 00:23:39 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:com.myCompanygmbh.myTestApp[0x9c47]) Job appears to have crashed: Segmentation fault: 11
May 10 00:23:39 unknown SpringBoard[29] <Warning>: Application 'Skype' exited abnormally with signal 9: Killed: 9
May 10 00:23:39 unknown SpringBoard[29] <Warning>: Application 'myTestApp' exited abnormally with signal 11: Segmentation fault: 11
May 10 00:23:40 unknown kernel[0] <Debug>: launchd[606] Builtin profile: container (sandbox)
May 10 00:23:40 unknown kernel[0] <Debug>: launchd[606] Container: /private/var/mobile/Applications/1D182D9C-6475-4B81-B409-E6245C60FE84 [69] (sandbox)
May 10 00:23:40 unknown ReportCrash[604] <Error>: Saved crashreport to /Library/Logs/CrashReporter/LowMemory-2011-05-10-002340.plist using uid: 0 gid: 0, synthetic_euid: 0 egid: 0
May 10 00:23:41 unknown Skype[606] <Warning>: ===== Starting HellKit (10021/3.0.0.250/IPHONE) =====
May 10 00:23:41 unknown Skype[606] <Warning>: Running on iOS device model iPhone3,1 (sysctlbyname('hw.machine'))
May 10 00:23:41 unknown Skype[606] <Warning>: Video capture constraints: 12 FPS, complexity mode 8
May 10 00:23:42 unknown MobilePhone[605] <Warning>: UI Mode is Phone
May 10 00:23:43 unknown SpringBoard[29] <Debug>: spd:___libspd_initialize_notify_block_invoke_1:214 spd woke up!
May 10 00:23:43 unknown SpringBoard[29] <Debug>: spd:_libspd_initialize_protocol:142 Registered notification port with spd [PID=609]
May 10 00:23:43 unknown SpringBoard[29] <Debug>: spd:spd_notification_socket_activity:279 Calling session client's callback on their queue for client [PID=606]
May 10 00:23:44 unknown sandboxd[610] <Notice>: Skype(606) deny file-write-create /Applications/.dat025e.000
May 10 00:23:44 unknown mediaserverd[19] <Warning>: 00:23:44.479 <SystemSoundServer> WARNING translating CMSession error: -12985
May 10 00:23:44 unknown mediaserverd[19] <Warning>: 00:23:44.530 <SystemSoundServer> WARNING translating CMSession error: -12985
May 10 00:23:44 unknown spd[609] <Error>: spd:spd_vet_socket:658 getpeername failure for client socket [FD=5]: Socket is not connected
May 10 00:23:44 unknown spd[609] <Error>: spd:spd_checkin_socket:954 Unable to check-in unsupported socket for client [PID=606]
May 10 00:23:44 unknown mediaserverd[19] <Error>: 00:23:44.585 <AudioQueueServer> AudioQueue: Error -12985 from AudioSessionSetClientPlayState(606)
May 10 00:23:45 unknown spd[609] <Error>: spd:spd_vet_socket:658 getpeername failure for client socket [FD=6]: Socket is not connected
May 10 00:23:45 unknown spd[609] <Error>: spd:spd_checkin_socket:954 Unable to check-in unsupported socket for client [PID=606]
I have an iPhone app with a webview that redirects to a forum at some point.
I noticed that the app will crash when I do these steps:
1) Browse through the forum (vBulletin)
2) Open a thread and try to post a message
3) Click into the textarea so the keyboard shows up
4) Then type and/or turn the device quickly
Now my iPhone app crashes. Notice: the crash only appears in very long threads, so it must be some problem of memory or CPU?
Anyway, I can't figure out where to search for the problem, because XCode 4 isn't showing any logs for the crash! Secondly, when running the app via Xcode (on the device) it crashes without showing any error... The crash isn't reproducible via Simulator (of course).
How to solve such a problem?
CONSOLE:
May 10 00:23:36 unknown SpringBoard[29] <Warning>: Received memory warning. Level=1
May 10 00:23:36 unknown MobilePhone[582] <Warning>: Received memory warning. Level=1
May 10 00:23:37 unknown configd[25] <Notice>: jetsam: kernel memory event (91), free: 1198, active: 7537, inactive: 3482, purgeable: 0, wired: 17615
May 10 00:23:37 unknown SpringBoard[29] <Warning>: Received memory warning. Level=2
May 10 00:23:37 unknown MobilePhone[582] <Warning>: Received memory warning. Level=2
May 10 00:23:38 unknown configd[25] <Notice>: jetsam: kernel termination snapshot being created
May 10 00:23:38 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.apple.mobilephone[0xa185]) Exited: Killed: 9
May 10 00:23:38 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.skype.skype[0xf18]) Exited: Killed: 9
May 10 00:23:38 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.myCompanygmbh.myTestApp[0x9c47]) Bug: launchd_core_logic.c:3795 (24506):0
May 10 00:23:39 unknown com.apple.debugserver-50[598] <Warning>: 1 [0256/1503]: error: ::read ( 4, 0x2ffb19f0, 1024 ) => -1 err = Bad file descriptor (0x00000009)
May 10 00:23:39 unknown SpringBoard[29] <Warning>: Application 'Phone' exited abnormally with signal 9: Killed: 9
May 10 00:23:39 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.myCompanygmbh.myTestApp[0x9c47]) Bug: launchd_core_logic.c:3794 (24506):3
May 10 00:23:39 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.myCompanygmbh.myTestApp[0x9c47]) Bug: launchd_core_logic.c:3202 (24506):10
May 10 00:23:39 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.myCompanygmbh.myTestApp[0x9c47]) Working around 5020256. Assuming the job crashed.
May 10 00:23:39 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:com.myCompanygmbh.myTestApp[0x9c47]) Job appears to have crashed: Segmentation fault: 11
May 10 00:23:39 unknown SpringBoard[29] <Warning>: Application 'Skype' exited abnormally with signal 9: Killed: 9
May 10 00:23:39 unknown SpringBoard[29] <Warning>: Application 'myTestApp' exited abnormally with signal 11: Segmentation fault: 11
May 10 00:23:40 unknown kernel[0] <Debug>: launchd[606] Builtin profile: container (sandbox)
May 10 00:23:40 unknown kernel[0] <Debug>: launchd[606] Container: /private/var/mobile/Applications/1D182D9C-6475-4B81-B409-E6245C60FE84 [69] (sandbox)
May 10 00:23:40 unknown ReportCrash[604] <Error>: Saved crashreport to /Library/Logs/CrashReporter/LowMemory-2011-05-10-002340.plist using uid: 0 gid: 0, synthetic_euid: 0 egid: 0
May 10 00:23:41 unknown Skype[606] <Warning>: ===== Starting HellKit (10021/3.0.0.250/IPHONE) =====
May 10 00:23:41 unknown Skype[606] <Warning>: Running on iOS device model iPhone3,1 (sysctlbyname('hw.machine'))
May 10 00:23:41 unknown Skype[606] <Warning>: Video capture constraints: 12 FPS, complexity mode 8
May 10 00:23:42 unknown MobilePhone[605] <Warning>: UI Mode is Phone
May 10 00:23:43 unknown SpringBoard[29] <Debug>: spd:___libspd_initialize_notify_block_invoke_1:214 spd woke up!
May 10 00:23:43 unknown SpringBoard[29] <Debug>: spd:_libspd_initialize_protocol:142 Registered notification port with spd [PID=609]
May 10 00:23:43 unknown SpringBoard[29] <Debug>: spd:spd_notification_socket_activity:279 Calling session client's callback on their queue for client [PID=606]
May 10 00:23:44 unknown sandboxd[610] <Notice>: Skype(606) deny file-write-create /Applications/.dat025e.000
May 10 00:23:44 unknown mediaserverd[19] <Warning>: 00:23:44.479 <SystemSoundServer> WARNING translating CMSession error: -12985
May 10 00:23:44 unknown mediaserverd[19] <Warning>: 00:23:44.530 <SystemSoundServer> WARNING translating CMSession error: -12985
May 10 00:23:44 unknown spd[609] <Error>: spd:spd_vet_socket:658 getpeername failure for client socket [FD=5]: Socket is not connected
May 10 00:23:44 unknown spd[609] <Error>: spd:spd_checkin_socket:954 Unable to check-in unsupported socket for client [PID=606]
May 10 00:23:44 unknown mediaserverd[19] <Error>: 00:23:44.585 <AudioQueueServer> AudioQueue: Error -12985 from AudioSessionSetClientPlayState(606)
May 10 00:23:45 unknown spd[609] <Error>: spd:spd_vet_socket:658 getpeername failure for client socket [FD=6]: Socket is not connected
May 10 00:23:45 unknown spd[609] <Error>: spd:spd_checkin_socket:954 Unable to check-in unsupported socket for client [PID=606]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我曾经遇到过类似的问题,这里有一个可能的解决方案...
首先,这很可能是内存问题,而不是 CPU 使用率问题,因此请确保实现
- (void)applicationDidReceiveMemoryWarning:( UIApplication *)application
应用程序委托上的委托方法...在此处放置一条日志行。其次,模拟低内存警告(模拟器在硬件菜单中有该选项)
现在观察您的应用程序在从一个线程转到另一个线程时是否崩溃(我怀疑它会崩溃)。
如果它确实崩溃了,那么在调试器中检查它崩溃的 ivars(特别是那些对应于 UI 组件并从 xib 加载的组件)。确保它们引用了它们应该引用的内容:当您的应用程序收到低内存警告时,iOS 将自动卸载隐藏视图的 xib 资源,如果您在代码中的某处保留/依赖其中任何一个,则很可能如果这些 ivars 不是您的代码所期望的,应用程序将会崩溃。
最后的建议:下次发生崩溃时,请确保包含堆栈跟踪。如果您没有在调试模式下运行应用程序,您仍然可以使用“iPhone 配置实用程序”来获取堆栈跟踪,该实用程序可以读取设备的控制台输出
I've had a similar issue once and here's a possible solution...
First things first, it's very likely to be a memory issue and not the CPU usage, so make sure you implement the
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
delegate method on your app delegate... put a log line there.Secondly, emulate the low memory warning (simulator has that option in the hardware menu)
Now observe if your app crashes while going from thread to thread (I suspect it will).
If it does crash, then in debugger go through your ivars where it crashes (especially those that correspond to UI components and are loaded from the xib). Make sure they reference what they are supposed to reference: when your app receives a low memory warning, iOS will automatically unload xib resources of hidden views, and if you hold on/depend on any of them somewhere in your code, it's likely that the app will crash if those ivars are not what your code expects.
And the final recommendation: next time you get a crash make sure to include the stack trace. If you don't have the app running in debug mode, you still can get the stack trace by using the "iPhone Configuration Utility" which can read the console output of your device