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 (show other bugs)
Version: 6.0.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-09-24 05:05 UTC by Damir Davletov
Modified: 2015-05-25 09:00 UTC (History)
8 users (show)

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


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

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
				try
				{
				throw new Exception("ff");
				}
				catch(Exception){
				} 
			});

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
Hello, 

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 ***

Note You need to log in before you can comment on or make changes to this bug.