Bug 60932 - Threadpool maxing CPU
Summary: Threadpool maxing CPU
Alias: None
Product: iOS
Classification: Xamarin
Component: Mono runtime / AOT compiler ()
Version: XI 11.4 (d15-5)
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Zoltan Varga
Depends on:
Reported: 2017-11-30 19:12 UTC by James Clancey
Modified: 2018-01-15 11:05 UTC (History)
3 users (show)

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

Instruments trace (5.08 MB, application/zip)
2017-11-30 19:12 UTC, James Clancey

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 for Bug 60932 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description James Clancey 2017-11-30 19:12:03 UTC
Created attachment 25876 [details]
Instruments trace

While running my app for a little while the thread pool seems to go crazy.  I can't 100% reproduce it. But if I listen to music for about 10 min it seems to happen 90% of the time. You can tell it's happening due to the phone starting to get hot.

To reproduce: Clone gMusic: https://github.com/Clancey/gMusic/ Run it on a device.
If you don't have a google account, just search for a youtube playlist and listen to that.

I have attached an Instruments trace of it happening.
Comment 1 James Clancey 2017-11-30 19:14:07 UTC
=== Visual Studio Enterprise 2017 for Mac ===

Version 7.2.2 (build 11)
Installation UUID: bc6b1fbe-d3ff-45ec-a1ae-d8123578f97a
	Mono (2017-06/1f4613aa1ac) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 504010006

=== NuGet ===


=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
SDK: /usr/local/share/dotnet/sdk/2.0.2/Sdks
SDK Versions:
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.5.6
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 9.1 (13532)
Build 9B55

=== Xamarin.iOS ===

Version: (Visual Studio Enterprise)
Hash: 51128b8c
Branch: xcode9.1
Build date: 2017-10-31 22:42:13-0400

=== Xamarin.Android ===

Version: (Visual Studio Enterprise)
Android SDK: /Users/clancey/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		5.0   (API level 21)
		5.1   (API level 22)
		6.0   (API level 23)
		7.0   (API level 24)
		7.1   (API level 25)
		8.0   (API level 26)

SDK Tools Version: 26.0.2
SDK Platform Tools Version: 26.0.2
SDK Build Tools Version: 25.0.2

Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Android Designer EPL code available here:

=== Xamarin.Mac ===

Version: (Visual Studio Enterprise)

=== Xamarin Inspector ===

Version: 1.3.2
Hash: 461f09a
Branch: 1.3-release
Build date: Tue, 03 Oct 2017 18:26:57 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 702020011
Git revision: b604c37c5a4a2f0919b45ffbe2aaad9fe040af31
Build date: 2017-11-01 08:31:43-04
Xamarin addins: d57dc14cbd4eb166ee62bab585965ab78d3650bc
Build lane: monodevelop-lion-d15-4

=== Operating System ===

Mac OS X 10.13.1
Darwin 17.2.0 Darwin Kernel Version 17.2.0
    Fri Sep 29 18:27:05 PDT 2017
    root:xnu-4570.20.62~3/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

MicroFramework 1.0.1
Internet of Things (IoT) development (Preview) 7.1
Comment 2 Vincent Dondain [MSFT] 2017-11-30 19:49:59 UTC
Hi James,

Sorry but I'm not quite sure how to search an play a youtube playlist from your app. Also it detected my Apple Music library but I can't play any song (starts and pauses instantly)...

I'm tempted to confirm this bug since you gave us the Instruments trace and we can see the issue there but I'm not sure others can easily reproduce this.
Comment 3 James Clancey 2017-11-30 20:51:31 UTC
Go to the menu Tap search.  Search for some music you like, choose a playlist from youtube. tap on one of the songs in the playlist to start playing it.
Comment 6 Vincent Dondain [MSFT] 2017-12-01 21:13:22 UTC
Hi James,

I tried pretty hard to reproduce your issue (as you know from our Slack conversations) and couldn't get the same CPU usage as you (profiler trace linked above).

My phone (iPhone X) stays cold and the CPU usage (while there are sometimes spikes) stays around 10% most of the time. I tried streaming both youtube playlists and Google Music.

Since you can reproduce consistently would you mind adding the following environment variable so the runtime people have a bit more information about what the threadpool is  doing?


You'll need to give us the device logs (Console.app) when the phone is super warm and is at 100%+ CPU usage.

Comment 7 James Clancey 2017-12-04 21:59:12 UTC
I have tried looking into more patterns that may be causing this. Whenever I do a fresh debug session I can't duplicate it. 

It happens very regularly when I play music under normal circumstances. Like Play a few songs. Pause the app for an hour or so, come back and resume playing.  I wonder if we are having issues resuming after iOS pauses the app for an extended period of time.
Comment 8 James Clancey 2017-12-08 22:26:30 UTC
Not sure if this is the same thing, but I have another instance where mono is thrashing the CPU. I cannot see any part of my code in instruments.

Comment 9 Manuel de la Peña [MSFT] 2018-01-15 11:05:09 UTC
@Vargaz have you had the chance to look at this?