Bug 6045 - NativeRelease ERROR on simple BeginInvokeOnMainThread
Summary: NativeRelease ERROR on simple BeginInvokeOnMainThread
Alias: None
Product: MonoMac
Classification: Desktop
Component: Bindings ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2012-07-09 11:29 UTC by Chris Hamons
Modified: 2012-07-20 15:33 UTC (History)
3 users (show)

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

Example (2.51 MB, application/x-download)
2012-07-19 08:46 UTC, Chris Hamons

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 Chris Hamons 2012-07-09 11:29:26 UTC
Whenever we call

NSApplication.SharedApplication.BeginInvokeOnMainThread() we get:

"[NativeRelease ERROR]: type NSAsyncActionDispatcher ..."

It appears to be coming from here:


See attached simple example.
Comment 1 Miguel de Icaza [MSFT] 2012-07-18 17:14:40 UTC
There was not attached simple example
Comment 2 Chris Hamons 2012-07-19 08:46:18 UTC
Created attachment 2229 [details]

Apologies (Bugzilla sometimes seems to forget about my attachment on the initial post).
Comment 3 Martin Baulig 2012-07-20 15:04:01 UTC
I'm having the same problem, so I did some investigation.

This seems to be related to:

What happens is this:
* You use NET 4.5 async await in your app.  The callback goes through AppKitSynchronizationContext.Post() which calls NSRunLoop.Main.BeginInvokeOnMainThread().

* This creates a managed NSAsyncActionDispatcher, and Apply() disposes it when done.

* Some time later, native code uses that NSAsyncActionDispater(IntPtr) ctor to create a new instance - and when we call Dispose() on that one, we get the warning.

Unfortunately, I have no idea how to fix this, but I can help reproduce the issue if necessary.
Comment 4 Miguel de Icaza [MSFT] 2012-07-20 15:14:13 UTC

Do you have a way to reproduce this problem?   I am curious to find out who is calling into the NSActionDispatcher to reinstantiate the object, it should have been fully destroyed and used at that point.
Comment 5 Miguel de Icaza [MSFT] 2012-07-20 15:33:43 UTC
I looked at Chris' sample and it was a harmless error.

Since the error reporting itself is useful to keep, instead I decided to change NSAsyncActionDispatcher to not commit suicide behind our runtime's back and not call Dispose.

The Dispose will be called later.

See Maccore #c5e5c5328d5d048bc329c2e74d9325a7cd059a63