- Home /
ExecutionEngineException: Attempting to JIT compile method.. (Unity 3, iPhone) with MessageList
I am having some problem with running the game on the iPhone. The game runs fine in the editor, and it ran fine on the iPhone when I was still using Unity 1.7. However since I upgraded to Unity 3, I have been seeing this error whenever I use MessageList from Unity Wiki (http://www.unifycommunity.com/wiki/index.php?title=MessageList).
Unloading 81 unused Assets to reduce memory usage. Loaded Objects now: 563. Unloading 3 Unused Serialized files (Serialized files now loaded: 0 / Dirty serialized files: 0) ExecutionEngineException: Attempting to JIT compile method '(wrapper dynamic-method) UnityEngine.Object:Object$op_Implicit (object,object[])' while running with --aot-only.
at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, Boolean throwOnBindFailure) [0x00000] in <filename unknown>:0 at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method, Boolean throwOnBindFailure) [0x00000] in <filename unknown>:0 at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method) [0x00000] in <filename unknown>:0 at System.Reflection.Emit.DynamicMethod.CreateDelegate (System.Type delegateType) [0x00000] in <filename unknown>:0 at Boo.Lang.Runtime.DynamicDispatching.Emitters.DispatcherEmitter.CreateMethodDispatcher () [0x00000] in <filename unknown>:0 at Boo.Lang.Runtime.DynamicDispatching.Emitters.DispatcherEmitter.Emit () [0x00000] in <filename unknown>:0 at Boo.Lang.Runtime.RuntimeServices.EmitImplicitConversionDispatcher (System.Reflection.MethodInfo method) [0x00000] in <filename unknown>:0 at Boo.Lang.Runtime.RuntimeServices.CreateBoolConverter (System.Type type) [0x00000] in <filename unknown>:0 at Boo.Lang.Runtime.RuntimeServices+<ToBool>c_AnonStorey1E.<>m_15 () [0x00000] in <filename unknown>:0 at Boo.Lang.Runtime.DynamicDispatching.DispatcherCache.Get (Boo.Lang.Runtime.DynamicDispatching.DispatcherKey key, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) [0x00000] in <filename unknown>:0 at Boo.Lang.Runtime.RuntimeServices.Dispatch (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, System.Object[] args, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) [0x00000] in <filename unknown>:0 at Boo.Lang.Runtime.RuntimeServices.ToBool (System.Object value) [0x00000] in <filename unknown>:0 at MessageList.AddMessage (System.String messageText) [0x00000] in <filename unknown>:0 at Dialog_cutscene_1_0+$DisplayMessages$1056+$.MoveNext () [0x00000] in <filename unknown>:0
(Filename: Line: -1)
And here's the code for MessageList:
// MessageList.js // From the Unity Wiki // Use with TimedFadeText.js // Attach to an emtpy Game Object
var messagePrefab : GUIText; // The prefab for our text object
var lineSize : float = 20.0; // The pixel spacing between text objects var startPos : Vector3 = Vector3 (20, 20, 0); // The position GUIText objects will be instantiated var layerTag : int = 0; var insertAbove : boolean = true;
private var messages = new Array(); // The array that holds all our text objects private var directionFactor : float = 1.0;
// Provide singleton support for this class. // The script must still be attached to a game object, but this will allow it to be called // from anywhere without specifically identifying that game object. static private var messageListInstance : MessageList; static var instance : MessageList;
static function Instance () { if (!instance) { instance = FindObjectOfType (MessageList); if (!instance) Debug.LogError ("There needs to be one active MessageList script on a GameObject in your scene."); } return instance; }
function Awake () { // First make sure that we have a prefab set. If not, then disable the script if (!messagePrefab) { enabled = false; Debug.Log("Must set the GUIText prefab for MessageList"); }
if (insertAbove) {
directionFactor = 1.0;
}
else {
directionFactor = -1.0;
}
}
// AddMessage() accepts a text value and adds it as a status message. // All other status messages will be moved along the y axis by a normalized distance of lineSize. // AddMessage() also handles automatic removing of any GUIText objects that automatically destroy // themselves. function AddMessage (messageText : String) { // Itterate through the messages, removing any that don't exist anymore, and moving the rest for (var i = 0; i < messages.length; i++) { // If this message is null, remove it, drop back the i count, and jump back to the begining // of the loop. if (!messages[i]) { messages.RemoveAt(i); i--; continue; }
// If this message object does exist, then move it along the y axis by lineSize.
// The y axis uses normalized coordinates, so we divide by the screen height to convert
// pixel coordinates into normalized screen coordinates.
(messages[i] as GUIText).transform.position.y += directionFactor * (lineSize/Screen.height);
}
// All the existing messages have been moved, making room for the new one.
// Instantiate a new message from the prefab, set it's text value, and add it to the
// array of messages.
var newMessage : GUIText = Instantiate(messagePrefab, Vector3(startPos.x/Screen.width, startPos.y/Screen.height, startPos.z), transform.rotation);
newMessage.text = messageText;
newMessage.gameObject.layer = layerTag;
messages.Add(newMessage);
}
And finally, this is my script that controls the scene:
//this is where dialogs are defined and the timing to display them are defined. //used in combination with MessageList.js http://www.unifycommunity.com/wiki/index.php?title=MessageList
var CameraInUse : GameObject; //define the camera being used in the scene var SceneSpeed : float = 1; //this adjusts the speed at which the dialogs and cutscene is played. Note: the GUITextMessageList prefab controls the fade out and live time speed of the text on screen. (multiply the live time and fade time by the same SceneSpeed number)
function Start () {
DisplayMessages();
}
function DisplayMessages(){
//find the sound effect manager to play sounds
var PlaySoundHere : SoundEffectManager = GameObject.FindWithTag("SoundEffects").GetComponent(SoundEffectManager);
iTween.moveBy(CameraInUse,{"x":2.5, "y":1.25, "z":0, "time":SceneSpeed*25, "delay":SceneSpeed*0, "transition": "linear"});
yield WaitForSeconds(SceneSpeed*1);
MessageList.Instance().AddMessage("One quiet evening in London,");
yield WaitForSeconds(SceneSpeed*3);
MessageList.Instance().AddMessage("Most people have just finished their day.");
yield WaitForSeconds(SceneSpeed*3);
MessageList.Instance().AddMessage("Some are on their way to the pub.");
yield WaitForSeconds(SceneSpeed*3);
MessageList.Instance().AddMessage("Some are about to have dinner with their sons and daughters.");
yield WaitForSeconds(SceneSpeed*3);
MessageList.Instance().AddMessage("And some are brushing their teeth, getting ready for an early night...");
yield WaitForSeconds(SceneSpeed*6);
MessageList.Instance().AddMessage("When all of a sudden...");
yield WaitForSeconds(SceneSpeed*1);
PlaySoundHere.PlayEarthquake(); // start playing earthquake sound loop
iTween.shake(CameraInUse,{"x":.5, "y":.1, "z":.5, "time":SceneSpeed*5, "delay":SceneSpeed*0});
yield WaitForSeconds(SceneSpeed*5);
PlaySoundHere.StopEarthquake(); // stop playing earthquake sound loop
iTween.moveBy(CameraInUse,{"x":-10, "y":2.5, "z":0, "time":SceneSpeed*25, "delay":SceneSpeed*0, "transition": "linear"});
iTween.rotateBy(CameraInUse,{"x":.015, "y":.02, "z":0, "time":SceneSpeed*25, "delay":SceneSpeed*0, "transition": "linear"});
MessageList.Instance().AddMessage("'An earthquake???!!'");
yield WaitForSeconds(SceneSpeed*3);
MessageList.Instance().AddMessage("'But we never have earthquakes in London!'");
yield WaitForSeconds(SceneSpeed*3);
MessageList.Instance().AddMessage("'What is it???'");
yield WaitForSeconds(SceneSpeed*6);
MessageList.Instance().AddMessage("Nobody knows the answer, but everyone soon forgets about it.");
yield WaitForSeconds(SceneSpeed*3);
MessageList.Instance().AddMessage("... well ...");
yield WaitForSeconds(SceneSpeed*3);
MessageList.Instance().AddMessage("ALMOST everyone ......");
yield WaitForSeconds(SceneSpeed*3);
MessageList.Instance().AddMessage("");
yield WaitForSeconds(SceneSpeed*3);
//disable click indicator from being created
var loadingMessageObject = GameObject.Find("Loading_Message");
var loadingMessageScript : loading_message = loadingMessageObject.GetComponent(loading_message);
loadingMessageScript.LoadNextLevel();
// Load the scene named "cutscene_1_1".
Application.LoadLevel ("cutscene_1_1");
}
I've tried .net2.0, .net2.0 subset, but it didn't make a difference. Any ideas?
Thanks!
Answer by Mantas-Puida · Mar 28, 2011 at 09:59 AM
This stack trace tells me that your problem lies inside of "AddMessage" function and "ToBool" tells me that something wrong goes when trying to convert something to bool.
at Boo.Lang.Runtime.RuntimeServices.ToBool (System.Object value) [0x00000] in <filename unknown>:0
at MessageList.AddMessage (System.String messageText) [0x00000] in <filename unknown>:0
I guess following code causes all the trouble, because it tries to convert message instance to bool:
if (!messages[i])
Try to rewrite it like this:
if (messages[i] != null)
P.S. Unity 3.3 handles such cases much better than Unity 3.0.
Thanks for the reply. I posted this a while ago and found out the problem was with variable typing with the messages array. Thanks!