Bug 8909 - Xamarin.Mac - GKLocalPlayer.LocalPlayer bombs out
Summary: Xamarin.Mac - GKLocalPlayer.LocalPlayer bombs out
Status: RESOLVED FIXED
Alias: None
Product: MonoMac
Classification: Desktop
Component: Bindings ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-12-12 14:30 UTC by Jonathan Peppers
Modified: 2015-02-12 21:11 UTC (History)
4 users (show)

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


Attachments
Info about my iMac (1.66 KB, text/plain)
2012-12-18 15:02 UTC, Jonathan Peppers
Details
Crash log from Console.app (70.83 KB, application/octet-stream)
2012-12-19 08:57 UTC, Jonathan Peppers
Details


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 Jonathan Peppers 2012-12-12 14:30:16 UTC
Drop this code in FinishedLaunching:

var player = GKLocalPlayer.LocalPlayer;

Console.WriteLine ("We never got here, sir.");

The Xamarin.Mac app will crash with "Segmentation fault: 11", no C# stacktrace supplied.

Here is GKLocalPlayer.h:

@interface GKLocalPlayer (GKAdditions)
// Obtain the GKLocalPlayer object.
// The player is only available for offline play until logged in.
// A temporary player is created if no account is set up.
+ (GKLocalPlayer *)localPlayer;

I was having the same issue when I attempted to add GameKit myself for MonoMac.
Comment 1 Miguel de Icaza [MSFT] 2012-12-12 16:25:13 UTC
We now have a fix, preparing.
Comment 2 Miguel de Icaza [MSFT] 2012-12-12 19:18:52 UTC
Quick workaround while we publish an update:

MonoTouch.ObjCRuntime.Dlfcn.dlopen (Constants.GameKitLibrary, 0);
Comment 3 Miguel de Icaza [MSFT] 2012-12-12 19:19:06 UTC
I forgot to mention: put taht code in your Main method.
Comment 4 Jonathan Peppers 2012-12-12 19:59:18 UTC
Workaround is working, thanks, I'm getting the Game Center popup now.

I'll be watching for an update, thanks!
Comment 5 Jonathan Peppers 2012-12-18 15:01:23 UTC
I updated to Xamarin.Mac 1.0.11 and was able to remove the workaround and see this fixed on my Macbook Air.

However, it doesn't work on my brand new iMac--even the workaround doesn't work. I get the exact same error as before.

I'm thinking it might be due to something with my new system. I'm adding an attachment of info about my iMac.
Comment 6 Jonathan Peppers 2012-12-18 15:02:58 UTC
Created attachment 3105 [details]
Info about my iMac
Comment 7 Sebastien Pouliot 2012-12-19 08:40:52 UTC
a. What does

Console.WriteLine (File.Exists (Constants.GameKitLibrary));

returns ?


b. if true, what does 

Console.WriteLine (MonoTouch.ObjCRuntime.Dlfcn.dlopen (Constants.GameKitLibrary, 0));

returns ?


c. finally, from a terminal window, what does returns ?

file /System/Library/Frameworks/GameKit.framework/GameKit
Comment 8 Jonathan Peppers 2012-12-19 08:53:15 UTC
a. True
b. 0
c. /System/Library/Frameworks/GameKit.framework/GameKit: Mach-O 64-bit dynamically linked shared library x86_64

Does that help?
Comment 9 Sebastien Pouliot 2012-12-19 08:57:26 UTC
yes. 'c' tells us the framework is 64 bits only on that machine, when it's 32/64 bits on everything else I've seen so far (including my own, not new, iMac running ML 10.8.2).
Comment 10 Jonathan Peppers 2012-12-19 08:57:58 UTC
Created attachment 3109 [details]
Crash log from Console.app
Comment 11 Jonathan Peppers 2012-12-19 08:59:11 UTC
Ok, so new iMacs are x64 only for certain Frameworks?

Weird, I wonder how many other issues will popup from this.
Comment 12 Sebastien Pouliot 2012-12-19 09:09:19 UTC
AFAIK it's the first (public) framework to drop* 32bits support. And it's hard to see why ? since that will break any existing 32bits application using such framework(s).

* unless that missing 32bits support is an Apple bug
Comment 13 Jonathan Peppers 2012-12-19 09:10:36 UTC
Can I change my app to AnyCPU? or is that generally not a good idea yet?
Comment 15 Jonathan Peppers 2012-12-19 09:21:22 UTC
I threw this out there: http://stackoverflow.com/questions/13954333/imac-missing-x86-version-of-gamekit
Comment 16 Jonathan Peppers 2012-12-19 09:23:19 UTC
Here is the other frameworks:

Jonathans-iMac:src jonathanpeppers$ file /System/Library/Frameworks/IOBluetooth.framework/Versions/A/Frameworks/CoreBluetooth.framework/CoreBluetooth
/System/Library/Frameworks/IOBluetooth.framework/Versions/A/Frameworks/CoreBluetooth.framework/CoreBluetooth: Mach-O universal binary with 2 architectures
/System/Library/Frameworks/IOBluetooth.framework/Versions/A/Frameworks/CoreBluetooth.framework/CoreBluetooth (for architecture i386):	Mach-O dynamically linked shared library i386
/System/Library/Frameworks/IOBluetooth.framework/Versions/A/Frameworks/CoreBluetooth.framework/CoreBluetooth (for architecture x86_64)	Mach-O 64-bit dynamically linked shared library x86_64
Jonathans-iMac:src jonathanpeppers$ file /System/Library/Frameworks/SceneKit.framework/SceneKit
/System/Library/Frameworks/SceneKit.framework/SceneKit: Mach-O universal binary with 2 architectures
/System/Library/Frameworks/SceneKit.framework/SceneKit (for architecture i386):	Mach-O dynamically linked shared library i386
/System/Library/Frameworks/SceneKit.framework/SceneKit (for architecture x86_64):	Mach-O 64-bit dynamically linked shared library x86_64
Jonathans-iMac:src jonathanpeppers$ file /System/Library/Frameworks/StoreKit.framework/StoreKit
/System/Library/Frameworks/StoreKit.framework/StoreKit: Mach-O universal binary with 2 architectures
/System/Library/Frameworks/StoreKit.framework/StoreKit (for architecture i386):	Mach-O dynamically linked shared library i386
/System/Library/Frameworks/StoreKit.framework/StoreKit (for architecture x86_64):	Mach-O 64-bit dynamically linked shared library x86_64
Jonathans-iMac:src jonathanpeppers$ file /System/Library/Frameworks/Accounts.framework/Accounts
/System/Library/Frameworks/Accounts.framework/Accounts: Mach-O 64-bit dynamically linked shared library x86_64
Jonathans-iMac:src jonathanpeppers$ file /System/Library/Frameworks/EventKit.framework/EventKit
/System/Library/Frameworks/EventKit.framework/EventKit: Mach-O 64-bit dynamically linked shared library x86_64
Jonathans-iMac:src jonathanpeppers$ file /System/Library/Frameworks/Social.framework/Social
/System/Library/Frameworks/Social.framework/Social: Mach-O 64-bit dynamically linked shared library x86_64
Comment 23 Sebastien Pouliot 2013-01-08 07:55:32 UTC
Jonathan, I asked someone else who just got a new iMac to run the same test and the 32bits version of GameKit is available to him [1].

Could you have installed other software on your iMac that could have changed your system ? We recently found out that MacKeeper can remove "unused" architectures from some libraries.

[1] http://pastebin.com/HReaQu05
Comment 24 Jonathan Peppers 2013-01-08 08:11:38 UTC
No, my iMac has very little on it:

Xcode & command line tools
Xamarin stuff - Mono for Android, MonoTouch, Xamarin.Mac
iTerm2
Versions
Google Chrome
GitHub for Mac
Cisco Anyconnect VPN client
Sublime Text 2
Some kind of driver/sync software for Motorola Android devices

So, I'm not sure what would have removed it. I don't have Parallels or homebrew on this machine yet.
Comment 25 Miguel de Icaza [MSFT] 2013-01-23 11:24:29 UTC
The binary in the combo update now comes with both architectures, so it should fix this issue.
Comment 26 Timothy Risi 2015-02-12 21:11:52 UTC
I tested GKPlayer.LocalPlayer on the current stable branch of Xamarin.Mac and was able to call it and move on successfully with no crash.