Bug 32823 - NSObject InvokeOnMainThread very slow on OS X 10.11
Summary: NSObject InvokeOnMainThread very slow on OS X 10.11
Status: RESOLVED NORESPONSE
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: Master
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Chris Hamons
URL:
Depends on:
Blocks:
 
Reported: 2015-08-06 08:56 UTC by thanos.siopoudis
Modified: 2017-02-15 00:00 UTC (History)
2 users (show)

Tags:
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 thanos.siopoudis 2015-08-06 08:56:40 UTC
Using InvokeOnMainThread from a separate thread to update the UI on the main thread, has become very slow on OS X 10.11 (DP1 through DP6, nothing has changed).
Comparing the exact same code in OS X 10.10 and OS X 10.11
I am using a delegate, which is, in turn, using InvokeOnMainThread. See example below:

// Delegate Function:
#region Events
public delegate void StatusUpdatedDelegate (string currentStatus, int currentValue, int maxValue);
public event StatusUpdatedDelegate StatusUpdated;

internal void RaiseStatusUpdated(string currentStatus, int currentValue, int maxValue) {
    this.StatusUpdated (currentStatus, currentValue, maxValue);
}
#endregion

// Main Class Delegate assignment
fmCore.StatusUpdated += new FMCore.StatusUpdatedDelegate (FMCoreStatusUpdated);

public void FMCoreStatusUpdated(string currentStatus, int currentValue, int maxValue) {
    InvokeOnMainThread (delegate {
        if (currentStatus.Length > 0) {
   	    currentStatusText.StringValue = currentStatus;
	}
    });
}

Deleting the calls in the InvokeOnMainThread, makes the app as fast as it is on OS X 10.10

Thanks, and sorry if the report is
Comment 1 thanos.siopoudis 2015-08-06 08:58:04 UTC
*Clicked submit too soon.
Sorry if the report is in the wrong place.
Comment 2 Chris Hamons 2015-09-29 15:11:16 UTC
All our invoke on main thread wrapper does is call:

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/#//apple_ref/occ/instm/NSObject/performSelectorOnMainThread:withObject:waitUntilDone:

with a little internal class that exposes a selector that is called.

I don't see anything in our code that could possibly change between 10.10 and 10.11.

As a serious side note, why are you InvokeOnMainThread instead of BeginInvokeOnMainThread? BeginInvoke is async, and doesn't hang your secondary thread waiting for the ui thread to get around to responding. In most cases, it's what you want.

I'll need more information to act on this bug.
Comment 3 Timothy Risi 2017-02-15 00:00:23 UTC
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and re-open the bug report. Thanks!