[MonoTouch] App is crashing at random - the app completely freezes indefinitely
Rolf Bjarne Kvinge
rolf at xamarin.com
Thu Mar 1 23:51:23 UTC 2012
Hi,
<inline>
On Fri, Mar 2, 2012 at 12:11 AM, MilkyJoe <leigh.bowers at curvenet.co.uk>wrote:
> I've got big problem. My app, that is due to go live tomorrow, is crashing
> at
> random. It crashes in different views, and at different points. It doesn't
> actually crash the app - the app just sits there, not responding. It
> literally just sat there for 24 minutes, until I allowed the screen to go
> off (I kept tapping the screen to keep it awake). Then, when re-starting
> the
> app, it closed itself within 30 seconds. The next time I run the app,
> everything is fine.
>
> There doesn't appear to be any pattern to it, although I'm starting to
> think
> it could be something to do with the UIWebView, or me not dealing with low
> memory correctly (but I can't think of anything else to do).
>
> I've spent days googling and trying various things, including:
>
> Promoting key private variables to class variables (to prevent premature
> GC)
> Turning off phone number detection (I found an article that suggested it
> might be bugged)
> Making sure all objects are disposed of cleanly
> (needlessly) Completely rewriting sections of code (at one point, it looked
> like a LINQ query was the problem, so I rewrote it to not employ LINQ at
> all)
> Etc etc etc.
>
> From the iPad's console, I see this (client name and app name removed):
>
> Mar 1 22:21:01 unknown <removed>[760] <Warning>: Received memory warning.
> Mar 1 22:21:11 unknown <removed>[760] <Warning>: void
> SendDelegateMessage(NSInvocation*): delegate
> (webView:resource:didFinishLoadingFromDataSource:) failed to return after
> waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode
> Mar 1 22:21:21 unknown <removed>[760] <Warning>: void
> SendDelegateMessage(NSInvocation*): delegate
> (webView:resource:didFinishLoadingFromDataSource:) failed to return after
> waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode
> .... EVERY TEN SECONDS UNTIL ...
>
Didn't you figure this out here:
http://lists.ximian.com/pipermail/monotouch/2012-February/008190.html? Or
is it another case?
> Mar 1 22:45:56 unknown <removed>[760] <Warning>: void
> SendDelegateMessage(NSInvocation*): delegate
> (webView:resource:didFinishLoadingFromDataSource:) failed to return after
> waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode
> Mar 1 22:46:06 unknown <removed>[760] <Warning>: void
> SendDelegateMessage(NSInvocation*): delegate
> (webView:resource:didFinishLoadingFromDataSource:) failed to return after
> waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode
> Mar 1 22:46:32 unknown SpringBoard[15] <Warning>: com.<removed>.<removed>
> failed to resume in time
> Mar 1 22:46:32 unknown SpringBoard[15] <Warning>: Forcing crash report of
> <removed>[760]...
> Mar 1 22:46:33 unknown Music~ipad[315] <Warning>: Received memory warning.
> Mar 1 22:46:33 unknown SpringBoard[15] <Warning>: Finished crash
> reporting.
> Mar 1 22:46:33 unknown com.apple.launchd[1] <Notice>:
> (UIKitApplication:com.<removed>.<removed>[0x4666]) Exited: Killed: 9
> Mar 1 22:46:33 unknown SpringBoard[15] <Warning>: Application '<removed>'
> exited abnormally with signal 9: Killed: 9
>
> I don't even get a crash report at the time it locks up (which makes sense,
> as the app hasn't crashed out). I get a crash report if I let the screen go
> off, and the unlock the device (that I can post if it would help).
>
Yes please, that might help us help you.
>
> Can anyone suggest what might be the problem? I know it's a big ask but,
> after two days of trying to fix the problem without success, I'm fast
> running out of time.
>
Does it happen while debugging? Maybe you can break when it hangs in the
debugger, and see what the main thread is trying to do.
>From the device log it looks like it's related to the memory warning (since
that's what happens first). There is a method you can override in your
classes (ReceiveMemoryWarning), to handle this warning appropriately (you
should clean up/null out as much as you possibly can when you get this
warning). Unfortunately your problem isn't directly related to keeping too
much memory alive after the warning.
You might want to make the GC more aggressive while debugging, to see if it
makes a difference (maybe the problem goes away, maybe it's easier to
reproduce: in either case it's valuable debugging information). You can do
this by starting up a new thread and periodically request a GC:
new Thread ((v) => { while (true) { Thread.Sleep (5000); GC.Collect
(GC.MaxGeneration); } }).Start ();
I hope this helps,
Rolf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/monotouch/attachments/20120302/bb6cfa96/attachment-0001.html>
More information about the MonoTouch
mailing list