Bug 24381 - Spinning pinwheel after updating Mac OS X menu bar icon while mouse hovers menu
Summary: Spinning pinwheel after updating Mac OS X menu bar icon while mouse hovers menu
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: Master
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: 2.0.x
Assignee: Chris Hamons
Depends on:
Reported: 2014-11-10 03:27 UTC by Nicolas Raoul
Modified: 2014-12-18 09:54 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 Nicolas Raoul 2014-11-10 03:27:55 UTC
I have a Mac OS X application that lives as an icon menu in the Mac menu bar (a bit like Dropbox).
To indicate download activity, the app sometimes modifies:
- the text of the menu's first item
- the icon (to create a small animation with 5 frames)
Screenshot: https://cloud.githubusercontent.com/assets/99590/4972162/e61afe4c-68a6-11e4-9465-9ea6eba4d7ce.png

The app works fine otherwise, but it always crashes after these reproducible steps:
1. Open the app's menu in the Mac OS X top bar
2. Move the mouse around on any item of the menu
3. After moving for a few seconds or minutes of moving around, the stack trace below appears in the console
4. If executed from Xamarin, the UI shows a spinning spinwheel and the app continues to execute until it tries to modify the menu's icon or first item text. If executed from install package without Xamarin, the whole app crashes immediately.

Thread started: #10
Thread finished: #10
  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) MonoMac.AppKit.NSApplication.NSApplicationMain (int,string[]) <IL 0x0009d, 0xffffffff>
  at MonoMac.AppKit.NSApplication.Main (string[]) <IL 0x00041, 0x00103>
  at CmisSync.GUI.Run () [0x00007] in [Users/nico/src/CmisSyncMaster/CmisSync/Mac/GUI.cs:82
  at CmisSync.Program.Main (string[]) [0x001ca] in [Users/nico/src/CmisSyncMaster/CmisSync/Program.cs:128
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
Native stacktrace:
Debug info from gdb:

Mono 3.10.0
Xamarin Studio 5.5.3 build 6
Mac OS X 10.9.5 and Mac OS X 10.10
Comment 1 Chris Hamons 2014-11-18 19:05:42 UTC
In some cases, crashes like this can be caused by items going out of memory and then objective-c calling back into your code. You could find the item that you expect to be called on when clicked and force it to stay in memory by holding it in a static reference. 

Could you provide a reproduction case for me to look at? There isn't enough here to go by.
Comment 2 Nicolas Raoul 2014-11-20 22:23:42 UTC
Hello Chris,

The issue only happens if I modify the icon at a high frequency (every 200 milliseconds), like this:
myNSStatusItem.Image = <a small NSImage>;
myNSStatusItem.Image.Size = new SizeF(16, 16);

No freeze if I disable this.

All of my code is managed.
Comment 3 Chris Hamons 2014-12-05 11:49:21 UTC
Since you are frequently modifying the NSImage, maybe you are hitting a bug in your application where something in getting garbaged collected.

Did adding a GC.Collect (2) change the behavior? 

I'm going to need more information to help sort this out. Do you have an example that shows the behavior?
Comment 4 Chris Hamons 2014-12-18 09:54:23 UTC
It has almost been two weeks. I'm going to close this bug as I don't have enough information to reproduce. Please reply with more information.