Bug 3394 - Attempting to JIT compile when running Monogame project on the device
Summary: Attempting to JIT compile when running Monogame project on the device
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 5.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-02-10 16:30 UTC by René Ruppert
Modified: 2012-02-13 09:37 UTC (History)
3 users (show)

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

Monogame sample (6.59 MB, application/zip)
2012-02-10 16:39 UTC, René Ruppert

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 René Ruppert 2012-02-10 16:30:53 UTC
Monotouch 5.2.3

I'm getting a JIT compile exception when running the attached project on my iPhone 4S in debug mode.

> $exception

{System.ExecutionEngineException: Attempting to JIT compile method '(wrapper managed-to-managed) Microsoft.Xna.Framework.Input.Keys[]:System.Collections.Generic.ICollection`1.Contains (Microsoft.Xna.Framework.Input.Keys)' while running with --aot-only.

  at System.Linq.Enumerable.Contains[Keys] (IEnumerable`1 source, Keys value) [0x0000d] in /Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/Enumerable.cs:609 
  at Microsoft.Xna.Framework.Input.KeyboardState.IsKeyDown (Keys key) [0x0000b] in /Users/Krumelur/Documents/Develop/XNA/MonoGame/MonoGame.Framework/Input/KeyboardState.cs:81 
  at Shooter.Game1.UpdatePlayer (Microsoft.Xna.Framework.GameTime gameTime) [0x000be] in /Users/Krumelur/Documents/Develop/XNA/ShooterTouch/ShooterTouch/Game1.cs:261 
  at Shooter.Game1.Update (Microsoft.Xna.Framework.GameTime gameTime) [0x00051] in /Users/Krumelur/Documents/Develop/XNA/ShooterTouch/ShooterTouch/Game1.cs:222 
  at Microsoft.Xna.Framework.Game.DoUpdate (Microsoft.Xna.Framework.GameTime aGameTime) [0x0000b] in /Users/Krumelur/Documents/Develop/XNA/MonoGame/MonoGame.Framework/iOS/Game.cs:312 
  at Microsoft.Xna.Framework.GameWindow.OnUpdateFrame (OpenTK.FrameEventArgs e) [0x00044] in /Users/Krumelur/Documents/Develop/XNA/MonoGame/MonoGame.Framework/iOS/IOSGameWindow.cs:440 
  at OpenTK.Platform.iPhoneOS.iPhoneOSGameView.RunIteration () [0x00049] in /Developer/MonoTouch/Source/monotouch/src/OpenGLES/OpenTK_1.0/Platform/iPhoneOS/iPhoneOSGameView.cs:746 
  at MonoTouch.Foundation.NSActionDispatcher.Apply () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/shared/Foundation/NSAction.cs:45 
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29 
  at Microsoft.Xna.Samples.Draw2D.Program.Main (System.String[] args) [0x00000] in /Users/Krumelur/Documents/Develop/XNA/ShooterTouch/ShooterTouch/AppDelegate.cs:24 }
Comment 1 René Ruppert 2012-02-10 16:39:21 UTC
Created attachment 1346 [details]
Monogame sample
Comment 2 Sebastien Pouliot 2012-02-13 09:37:44 UTC
This is an issue inside MonoGame. It is using extensions methods that (invisibly, source-wise) brings generics methods to be used with an enum (value-type) [1].

The simplest solution is to avoid the generics (since it's not really used/needed and will simplify code generation) and use more basic code like:

		public bool IsKeyDown (Keys key)
			if (_keys != null) {
				return (Array.BinarySearch (_keys, key) >= 0);
			return false;

With that change the games start on devices (just like on the simulator).

[1] http://docs.xamarin.com/ios/about/limitations#Limited_Generics_Support