Bug 7410 - UI thread freezes if there's a handled exception thrown from a timer callback
Summary: UI thread freezes if there's a handled exception thrown from a timer callback
Status: RESOLVED DUPLICATE of bug 29726
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 6.0.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-09-24 05:05 UTC by Damir Davletov
Modified: 2015-05-25 09:00 UTC (History)
8 users (show)

Is this bug a regression?: ---
Last known good build:

Sample project with bug (8.73 KB, application/zip)
2012-09-24 05:05 UTC, Damir Davletov

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Damir Davletov 2012-09-24 05:05:16 UTC
Created attachment 2607 [details]
Sample project with bug

If the code below is executed UI thread hangs on the run loop iteration after the callback. This issue is reproducible on device.

NSTimer.CreateScheduledTimer(new TimeSpan(1), delegate {

				//this code will hang the UI thread on the next run loop iteration
				throw new Exception("ff");

Please see attached sample project.

Device is iPhone4 with iOS6, the app is built with MonoTouch 6.0.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-09-24 05:35:28 UTC
I can not reproduce with iPad3/iOS5, I will try a bit later today with iPad2/iOS6.
Comment 2 Damir Davletov 2012-09-24 05:38:57 UTC
Yes, I can confirm this worked on iOS 5& MT 5.3.12 and not working on iOS 6 & MT 6.0. It is also not reproducible on simulator.
Comment 3 Rolf Bjarne Kvinge [MSFT] 2012-09-24 18:47:03 UTC
I can confirm that the button can't be clicked on iPad2/iOS6.

It looks like our exception handling is somehow corrupting something so that when the timer delegate returns, the app hangs.
Comment 4 Rolf Bjarne Kvinge [MSFT] 2012-09-25 08:14:02 UTC
This is quite strange, I have no idea what's going on. Native code (__CFRunLoopDoTimer) gets stuck in an infinite loop when the managed timer method returns, but I can't see what's causing it.

Rodrigo/Zoltan, can any of you two have a look?
Comment 6 Zoltan Varga 2012-10-11 07:13:39 UTC
I can't reproduce this with mt 6.0.4 on an ipad2/ios6.
Comment 7 Chris Hardy [MSFT] 2012-10-11 07:33:41 UTC
I couldn't reproduce this with mt 6.0.2 or 6.0.4 on an iPad 2 / iOS 6.
Comment 8 Rolf Bjarne Kvinge [MSFT] 2012-10-11 09:17:20 UTC
I can't reproduce anymore either, with neither 6.0.2 nor our ios6 branch.

I can reproduce with 6.0.0 though, so it looks like something was fixed between 6.0.0 and 6.0.2.

Damir, can you try again with the latest stable release (6.0.4) to see if it works for you now?
Comment 9 peter.schade 2012-10-11 09:43:19 UTC

I have installed the Monotouch release 6.0.4 and I still get the error if I call the NSTimer.CreateScheduledTimer.

Then the app freezes on iPad device (not on simulator).
Comment 10 Rolf Bjarne Kvinge [MSFT] 2012-10-11 09:46:03 UTC
Did you try the test case you provided or a different project?

If it still hangs, can you get a crash report as described here: http://rolfkvinge.blogspot.com.es/2012/05/monotouch-debugging-tips.html and attach it?
Comment 11 Zoltan Varga 2012-10-11 14:37:44 UTC
I could reproduce this with the mt 6.0.4 binaries, but not with a version built from source.
Comment 12 Rolf Bjarne Kvinge [MSFT] 2012-10-15 08:13:08 UTC
Now I can reproduce no matter what I do... definitively strange.

Zoltan: can you still reproduce if you get the latest 6.0 builds from wrench?
Comment 13 Zoltan Varga 2012-10-15 10:05:27 UTC
I can't reproduce it with those builds either.
Comment 14 Rolf Bjarne Kvinge [MSFT] 2012-10-16 19:49:31 UTC
Damir / Peter: I've found that if I switch the test app to be a Universal app (as opposed to iPhone/iPod), it works fine. Another thing that works is to 2x the app when running on the device - i.e. at startup the button doesn't respond, I hit 2x (only once to get it big, or again to make it return to the small size), and now the button suddenly works again.
Comment 15 Sebastien Pouliot 2012-11-27 15:54:06 UTC
The solution for the unresponsiveness is to turn off the status bar visibility
see: http://stackoverflow.com/a/12968156/220643
Comment 17 Rolf Bjarne Kvinge [MSFT] 2015-05-25 09:00:15 UTC

*** This bug has been marked as a duplicate of bug 29726 ***