Bug 22903 - NSColor.ColorWithAlphaComponent() method call fails when Mono runtime is in Application Bundle
Summary: NSColor.ColorWithAlphaComponent() method call fails when Mono runtime is in A...
Status: RESOLVED FIXED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: 1.10.0
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Chris Hamons
URL:
Depends on:
Blocks:
 
Reported: 2014-09-11 23:17 UTC by Jon Goldberger [MSFT]
Modified: 2014-12-05 14:14 UTC (History)
4 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 FIXED

Description Jon Goldberger [MSFT] 2014-09-11 23:17:10 UTC
Created attachment 8013 [details]
Test Project

Calling the ColorWithAlphaComponent() method on an NSColor object fails with the following stack trace if the Mono runtime is included in the Application bundle. 

## Stack Trace:

System.EntryPointNotFoundException: xamarin_float_objc_msgSend
  at at (wrapper managed-to-native) MonoMac.ObjCRuntime.Messaging.xamarin_float_objc_msgSend (intptr,intptr) <IL 0x00011, 0x000a3>
  at MonoMac.AppKit.NSColor.get_AlphaComponent () [0x0001d] in /Users/builder/data/lanes/xamcore-lion-1.10-branch/1bfb1eb7/source/xamcore/src/build/compat/AppKit/NSColor.g.cs:778
  at Syncode.Mac.Controls.SyncodeProgressHUD/ProgressActivityIndicator.set_Colour (MonoMac.AppKit.NSColor) [0x00028] in /Users/apple/Downloads/TestAlphaComponent/SyncodeProgressHUD.cs:222
  at Syncode.Mac.Controls.SyncodeProgressHUD.UpdateLayout () [0x00219] in /Users/apple/Downloads/TestAlphaComponent/SyncodeProgressHUD.cs:587
  at Syncode.Mac.Controls.SyncodeProgressHUD.BeginShowView () [0x00002] in /Users/apple/Downloads/TestAlphaComponent/SyncodeProgressHUD.cs:678
  at Syncode.Mac.Controls.SyncodeProgressHUD.ShowViewAnimated () [0x00008] in /Users/apple/Downloads/TestAlphaComponent/SyncodeProgressHUD.cs:721
  at Syncode.Mac.Controls.SyncodeProgressHUD.ShowProgress (single,string,MonoMac.AppKit.NSView) [0x00092] in /Users/apple/Downloads/TestAlphaComponent/SyncodeProgressHUD.cs:639
  at TestAlphaComponent.MainWindowController.ClickShowHUD (MonoMac.Foundation.NSObject) [0x0001b] in /Users/apple/Downloads/TestAlphaComponent/MainWindowController.cs:58
  at at (wrapper dynamic-method) object.[TestAlphaComponent.MainWindowController.Void ClickShowHUD(MonoMac.Foundation.NSObject)] (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector,MonoMac.Foundation.NSObject) <IL 0x00011, 0x0005f>
  at at (wrapper native-to-managed) object.[TestAlphaComponent.MainWindowController.Void ClickShowHUD(MonoMac.Foundation.NSObject)] (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector,MonoMac.Foundation.NSObject) <IL 0x00050, 0x00127>
  at at (wrapper managed-to-native) MonoMac.AppKit.NSApplication.NSApplicationMain (int,string[]) <0x00012>
  at MonoMac.AppKit.NSApplication.Main (string[]) [0x00041] in /Users/builder/data/lanes/xamcore-lion-1.10-branch/1bfb1eb7/source/xamcore/src/AppKit/NSApplication.cs:105
  at TestAlphaComponent.MainClass.Main (string[]) [0x00007] in /Users/apple/Downloads/TestAlphaComponent/Main.cs:14



## To reproduce:

1. Open the attached test project.
2. Choose the Test Configuration. 
3. Run the project and click the Show HUD button.

## Expected Result: a box will appear with a loading graphic.

## Actual Result: App crashes with above stack trace.

4. Stop the app.
5. Open the Project Options->Build->Mac Build page and remove the checkmark for "Include the Mono runtime in the application bundle."
6. Run the project and click the Show HUD button.

## Expected Result: a box will appear with a loading graphic.

## Actual Result: As expected. 


------------------------------------
version info:
=== Xamarin Studio ===

Version 5.3 (build 441)
Installation UUID: 2dc9022f-f9a8-424f-8284-bf224cbbfde0
Runtime:
	Mono 3.8.0 ((no/45d0ba1)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 308000009

=== Xamarin.Android ===

Version: 4.16.0 (Business Edition)
Android SDK: /Users/apple/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.2   (API level 8)
		2.3   (API level 10)
		3.0   (API level 11)
		3.1   (API level 12)
		3.2   (API level 13)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

=== Apple Developer Tools ===

Xcode 5.1.1 (5085)
Build 5B1008

=== Xamarin.Mac ===

Version: 1.10.0.10 (Business Edition)

=== Xamarin.iOS ===

Version: 7.4.0.108 (Business Edition)
Hash: 77efa3f
Branch: 
Build date: 2014-08-26 07:59:55-0400

=== Build Information ===

Release ID: 503000441
Git revision: befb6aa1176d37a5f678f4274f340a0159091b7a
Build date: 2014-09-08 17:57:02-04
Xamarin addins: 6dc7c388e31fdfc8014689839d37de0d4622435c

=== Operating System ===

Mac OS X 10.9.4
Darwin Jonathans-MacBook-Pro.local 13.3.0 Darwin Kernel Version 13.3.0
    Tue Jun  3 21:27:35 PDT 2014
    root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
Comment 3 Ram Chandra 2014-09-12 05:51:48 UTC
I have checked this issue with attached project and I am able to reproduce this issue.

When I enable the "Include the Mono runtime in the application bundle" option. I observed that, I am getting the "System.EntryPointNotFoundException". 

Note: When I disable the "Include the Mono runtime in the application bundle" I am not getting any error/ exception.

Screencast: http://www.screencast.com/t/B8DJQ62pi
Exception details: https://gist.github.com/saurabh360/5fc2e2e80d9431743459

Environment Info: 

=== Xamarin Studio ===

Version 5.5 (build 170)
Installation UUID: 6ea47b0d-1852-4aaf-808d-373ff0a5002b
Runtime:
	Mono 3.8.0 ((no/45d0ba1)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 308000009

=== Apple Developer Tools ===

Xcode 6.0 (6256.20)
Build 6A280n

=== Xamarin.Mac ===

Version: 1.10.0.12 (Enterprise Edition)

=== Xamarin.iOS ===

Version: 7.9.5.24 (Enterprise Edition)
Hash: 4c90cd0
Branch: 
Build date: 2014-09-09 20:52:38-0400

=== Build Information ===

Release ID: 505000170
Git revision: 76c5f6544e8279be90f8e489862a28a2388b5581
Build date: 2014-09-11 19:28:24-04
Xamarin addins: 909f05e2e2cdf623d7b417d1509bf2ea47dbdd90

=== Operating System ===

Mac OS X 10.9.3
Darwin Jatin66s-iMac.local 13.2.0 Darwin Kernel Version 13.2.0
    Thu Apr 17 23:03:13 PDT 2014
    root:xnu-2422.100.13~1/RELEASE_X86_64 x86_64
Comment 4 Bart King 2014-09-12 06:28:57 UTC
I reported this to Support originally (thanks Jon), and I just wanted to update that this also occurs under the Xamarin.Mac Unified API, too.

System.EntryPointNotFoundException: xamarin_nfloat_objc_msgSend
  at at (wrapper managed-to-native) ObjCRuntime.Messaging.xamarin_nfloat_objc_msgSend (intptr,intptr) <IL 0x00011, 0x000fe>
  at AppKit.NSColor.get_AlphaComponent () [0x0001d] in /Users/builder/data/lanes/xamcore-lion-1.10-branch/1bfb1eb7/source/xamcore/src/build/mobile-64/AppKit/NSColor.g.cs:802
  at Syncode.Mac.Controls.SyncodeProgressHUD/ProgressActivityIndicator.set_Colour (AppKit.NSColor) [0x00028] in /Users/[redacted]/SyncodeProgressHUD.cs:219
[...]

In this case, I was using a normal debug build and NOT packaging the Mono bundle.

Looks like this is a universal problem!
Comment 6 Jon Goldberger [MSFT] 2014-09-12 16:28:12 UTC
I did some more experimentation and it seems even just accessing the AlphaComponent property on an NSColor.FromDeviceWhite() object. IOW,

_colourForeground.AlphaComponent

throws the same exception. 

Also noted it happens when accessing other color components, like if switching to Srgb color space, accessing the NSColor.RedComponent causes the same exception.

I was able to workaround this issue by using a separate List<float> _finAlpha to hold the alpha values for the  List<NSColor>_finColour
Comment 7 Radu 2014-10-09 18:46:17 UTC
I am experiencing this bug and I would like to add that it actually happens when accessing any rgb component like "RedComponent". I managed to get around it by using the GetRgba method instead
Comment 8 Chris Hamons 2014-10-09 18:54:48 UTC
What version of xam.mac are you using? Try moving from alpha to beta and see if that fixes it, alpha will be updated next week hopefully.
Comment 9 Radu 2014-10-09 18:58:35 UTC
I'm using the latest version of XamMac, stable channel. I am on a temporary business license.
Comment 10 Chris Hamons 2014-10-09 19:00:52 UTC
Hmm, can you post your xamarin studio, about,details and a sample showing the issue? I thought we fixed this already.
Comment 11 Radu 2014-10-09 19:08:47 UTC
this line crashes with the xamarin_float_objc_msgSend error when mono is bundled:

string cacheKey = bundle + "_" + ((int)(color.RedComponent * 0xFF)).ToString () + ((int)(color.GreenComponent * 0xFF)).ToString () + ((int)(color.BlueComponent * 0xFF)).ToString ();

I don't actually know which of the three calls throws the error. I assumed it is the first one and that the component being retrieved doesn't matter

=== Xamarin Studio ===

Version 5.4 (build 240)
Installation UUID: 1c0da644-ba48-44a6-b3fc-c3f058a39852
Runtime:
	Mono 3.8.0 ((no/db71bc1)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 308000013

=== Apple Developer Tools ===

Xcode 5.1.1 (5085)
Build 5B1008

=== Xamarin.Mac ===

Version: 1.10.0.13 (Business Edition)

=== Xamarin.Android ===

Not Installed

=== Xamarin.iOS ===

Version: 8.0.0.63 (Business Edition)
Hash: 58b46df
Branch: 
Build date: 2014-09-18 22:32:07-0400

=== Build Information ===

Release ID: 504000240
Git revision: 01786bc67c7024ec33d327ed27e4416d7a846f4e
Build date: 2014-09-17 10:58:48-04
Xamarin addins: 7cd7dfcd6b7b7b53281508954ec080f1cd153ad3

=== Operating System ===

Mac OS X 10.8.5
Darwin localhost 12.5.0 Darwin Kernel Version 12.5.0
    Sun Sep 29 13:33:47 PDT 2013
    root:xnu-2050.48.12~1/RELEASE_X86_64 x86_64
Comment 12 Chris Hamons 2014-12-05 14:14:22 UTC
So, I'm still seeing this fixed in the latest Alpha and beta/stable. Can you try either one and reopen if it is still an issue. Stable is on .18 not .13