Bug 36568 - Android Task.Factory.StartNew is inlining tasks on the UI thread
Summary: Android Task.Factory.StartNew is inlining tasks on the UI thread
Status: RESOLVED NORESPONSE
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 6.0.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2015-12-03 23:30 UTC by Steve Scalpone
Modified: 2017-06-28 11:49 UTC (History)
7 users (show)

Tags: BZCU
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:
Status:
RESOLVED NORESPONSE

Description Steve Scalpone 2015-12-03 23:30:50 UTC
I recently upgraded to Version: 6.0.0.34 (Business Edition).

It appears that Task.Factory.StartNew is inlining tasks on the UI thread.  The net effect is that our UI locks up for the duration of the task.  Usually it's just bad, but occasionally a long running task gets the UI thread, which is fatal.  The task manager also appears to ignore TaskCreationOptions.LongRunning.

Here's the code I'm using to catch & log the situation.

            var task = Task.Factory.StartNew (delegate {
                if(Android.OS.Looper.MyLooper() == Android.OS.Looper.MainLooper) {
                    Console.WriteLine("StartNew running on main thread.");
                }

Is that a reasonable way to detect this condition on Android?

Any ideas how to keep new tasks off of the UI thread?

 - Steve

=== Xamarin Studio ===

Version 5.10 (build 871)
Installation UUID: be6a277c-fc53-4048-8758-5e62953d1105
Runtime:
Mono 4.2.1 (explicit/6dd2d0d)
GTK+ 2.24.23 (Raleigh theme)

Package version: 402010102

=== Xamarin.Profiler ===

Version: 0.0.0.0
Location: /Users/stevescalpone/bin/profiler-mac-0.9-0/XamarinProfiler.Mac.app/Contents/MacOS/XamarinProfiler.Mac

=== Apple Developer Tools ===

Xcode 7.1.1 (9081)
Build 7B1005

=== Xamarin.iOS ===

Version: 9.2.1.51 (Business Edition)
Hash: 3c0ec35
Branch: master
Build date: 2015-11-12 13:05:39-0500

=== Xamarin.Android ===

Version: 6.0.0.34 (Business Edition)
Android SDK: /Users/stevescalpone/Library/Developer/Xamarin/android-sdk-mac_x86
Supported Android versions:
2.3   (API level 10)
4.0.3 (API level 15)
4.1   (API level 16)
4.3   (API level 18)
4.4   (API level 19)
5.0   (API level 21)
5.1   (API level 22)
6.0   (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.0.1
SDK Build Tools Version: 23.0.1

Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.4.0.109 (Starter Edition)

=== Build Information ===

Release ID: 510000871
Git revision: 4e9c5abb5ffdae12ba02ac49da83f8b2011dbb88
Build date: 2015-11-12 06:02:54-05
Xamarin addins: 55007ed0e56436f385d8e26394a45be563abc7e8
Build lane: monodevelop-lion-cycle6

=== Operating System ===

Mac OS X 10.11.1
Darwin Steves-MacBook-Pro.local 15.0.0 Darwin Kernel Version 15.0.0
    Sat Sep 19 15:53:46 PDT 2015
    root:xnu-3247.10.11~1/RELEASE_X86_64 x86_64
Comment 1 Jonathan Pryor 2015-12-08 13:00:03 UTC
Please attach a repro that demonstrates the described behavior.
Comment 2 Adam Hartley [MSFT] 2017-06-28 11:49:56 UTC
Because we have not received a reply to our request for more information we are closing this issue. If you are still encountering this issue, please reopen the ticket with the requested information. Thanks!