Bug 4425 - Background Execution sample throws UIKitThreadAccessException when multitasking on simulator
Summary: Background Execution sample throws UIKitThreadAccessException when multitaski...
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 5.3.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-04-13 12:32 UTC by PJ
Modified: 2012-04-16 10:35 UTC (History)
2 users (show)

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

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 PJ 2012-04-13 12:32:58 UTC
Steps to reproduce:
1. Run the BackgroundExecution Sample on simulator
2. Press [Start Long Running Task]
3. Press the home button
4. Open another app (eg Safari)

Stacktrace: https://gist.github.com/2377539

I'm only seeing this behavior on simulator, but 360logica got the same result on Release / iPad2.

Found on:
Mono 2.10.9
MT 5.3.3 5ee2421f4f7722353285c61220c5e97090b17fe1
Comment 1 Sebastien Pouliot 2012-04-13 14:45:10 UTC
Release builds do not contain the UI thread checks (unless some extra command line options were included). Sure it's not a Debug build (or at debug is enabled) ?
Comment 2 PJ 2012-04-13 14:48:00 UTC
Yeah I couldn't reproduce that result either.

I'll check again to see if they had a false negative when they're back on Sunday night.
Comment 3 Sebastien Pouliot 2012-04-13 16:33:55 UTC
the UI check comes from BackgroundTimeRemaining

It's not marked as thread safe but, sadly, Apple docs are rarely clear about thread-safety.

In this case the API is meant to be called (at least useful) on a background thread (since main thread is suspended). Googling shows code that use it inside background thread (including sample the "IOS 5 Programming Cookbook" book).

Fixed in 662319ab2cffed8d12c3b48ca034ce1af2d4f981

but please try this again, without the fix, since it should not happen on release builds.
Comment 4 PJ 2012-04-16 09:58:49 UTC

I verified that this error occurs on the same build I found the initial issue on using Release | iPhoneSimulator


Have not yet tested the fix.
Comment 5 Sebastien Pouliot 2012-04-16 10:07:07 UTC
Please check (to be 100% sure) but "Release | iPhoneSimulator" does not use the linker (by default) so the UI checks won't be removed. That's perfectly normal.

OTOH the default, for devices, is to use the linker and *if* not on debug the UI checks should not be enabled (unless some other command lines options are added). If this can be duplicated on Release|iPhone (like the original description said) then there's an issue.
Comment 6 PJ 2012-04-16 10:35:08 UTC
I have not yet been able to reproduce on device, and I can't again now. Think we're good!

That Release | iPad result was from 360 and it was just a false negative upon re-test.