Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

iPhone build error: Attempting to JIT compile method in AOT only

Discussion in 'Editor & General Support' started by spinaljack, Nov 12, 2010.

  1. spinaljack

    spinaljack

    Joined:
    Mar 18, 2010
    Posts:
    893
    Code (csharp):
    1. ExecutionEngineException: Attempting to JIT compile method '(wrapper dynamic-method) UnityEngine.GameObject:GameObject$get_renderer$ (object,object[])' while running with --aot-only.
    2.  
    3.   at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, Boolean throwOnBindFailure) [0x00000] in <filename unknown>:0
    4.   at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method, Boolean throwOnBindFailure) [0x00000] in <filename unknown>:0
    5.   at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method) [0x00000] in <filename unknown>:0
    6.   at System.Reflection.Emit.DynamicMethod.CreateDelegate (System.Type delegateType) [0x00000] in <filename unknown>:0
    7.   at Boo.Lang.Runtime.DynamicDispatching.Emitters.DispatcherEmitter.CreateMethodDispatcher () [0x00000] in <filename unknown>:0
    8.   at Boo.Lang.Runtime.DynamicDispatching.Emitters.DispatcherEmitter.Emit () [0x00000] in <filename unknown>:0
    9.   at Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.EmitPropertyDispatcher (System.Reflection.PropertyInfo property, SetOrGet gos) [0x00000] in <filename unknown>:0
    10.   at Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.EmitDispatcherFor (System.Reflection.MemberInfo info, SetOrGet gos) [0x00000] in <filename unknown>:0
    11.   at Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.Create (SetOrGet gos) [0x00000] in <filename unknown>:0
    12.   at Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.CreateGetter () [0x00000] in <filename unknown>:0
    13.   at Boo.Lang.Runtime.RuntimeServices.DoCreatePropGetDispatcher (System.Object target, System.Type type, System.String name) [0x00000] in <filename unknown>:0
    14.   at Boo.Lang.Runtime.RuntimeServices.CreatePropGetDispatcher (System.Object target, System.String name) [0x00000] in <filename unknown>:0
    15.   at Boo.Lang.Runtime.RuntimeServices+<GetProperty>c__AnonStorey15.<>m__A () [0x00000] in <filename unknown>:0
    16.   at Boo.Lang.Runtime.DynamicDispatching.DispatcherCache.Get (Boo.Lang.Runtime.DynamicDispatching.DispatcherKey key, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) [0x00000] in <filename unknown>:0
    17.   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
    18.   at Boo.Lang.Runtime.RuntimeServices.Dispatch (System.Object target, System.String cacheKeyName, System.Object[] args, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) [0x00000] in <filename unknown>:0
    19.   at Boo.Lang.Runtime.RuntimeServices.GetProperty (System.Object target, System.String name) [0x00000] in <filename unknown>:0
    20.   at UnityScript.Lang.UnityRuntimeServices.GetProperty (System.Object target, System.String name) [0x00000] in <filename unknown>:0
    21.   at GameController+$UpdateSequence$92+$.MoveNext () [0x00000] in <filename unknown>:0
    22. UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator)
    23. $:MoveNext()
    24. UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator)
    25. $:MoveNext()
    26.  
    27. (Filename:  Line: -1)
    Anyone know how to fix this error?
     
    Last edited: Nov 12, 2010
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,602
    Do you have code that lead to this?
    We could do a lot of blind guessing that wouldn't get you anywhere I fear.
     
  3. spinaljack

    spinaljack

    Joined:
    Mar 18, 2010
    Posts:
    893
    It happens as soon as you exit the menu into the game scene. I can post the whole game script but it's pretty long
     
  4. spinaljack

    spinaljack

    Joined:
    Mar 18, 2010
    Posts:
    893
    Code (csharp):
    1. enum State {Initialise,Sequence,Play,Pause,Win,Lose,GameOver,LevelComplete};
    2.  
    3. var rootObject      : GameObject;
    4. var animationRoot   : GameObject;
    5. var corona              : GameObject;
    6. var outerRing           : GameObject;
    7. var innerRing           : GameObject;
    8. ////////////////////////
    9. //  Buttons info:
    10. //  0 - Blue
    11. //  1 - Green
    12. //  2 - Red
    13. //  3 - Yellow
    14. ////////////////////////
    15. var outerButtons        : GameObject[];
    16. var innerButtons        : GameObject[];
    17.  
    18. // GUI
    19. var guiColour                   : Color;
    20. var guiSkin                     : GUISkin;
    21. var gameOverTexture         : Texture2D;
    22. var levelCompleteTexture    : Texture2D;
    23. var heartIcon                   : Texture2D;
    24.  
    25. // sounds
    26. var pingSound   : AudioClip;
    27. var buzzerSound : AudioClip;
    28. var klaxonSound : AudioClip;
    29.  
    30.  
    31. // level stats
    32. var currentLevel        : int       = 1;
    33. var difficultyLevel : int       = 1;
    34. var score               : int       = 0;
    35. var pointsPerHit        : int       = 1;
    36. var TimeBonus       : int       = 10;
    37. var maxTime         : float     = 20;
    38. var lives               : int       = 3;
    39.  
    40. // disc rotation
    41. var outerSpinSpeed  : float     = 2;
    42. var innerSpinSpeed  : float     = 0;
    43. var maxSpinSpeed    : float     = 60;
    44.  
    45. // button timings
    46. var flashTime           : float     = 1.5;
    47. var minFlashTime        : float     = 0.2;
    48.  
    49. // counters, arrays, etc
    50. var timeCounter             : float = 60;
    51. var gameState           : State     = State.Sequence;
    52. private var buttonSequence  :  Array = new Array();
    53. private var sequenceIndex       : int = 0;
    54.  
    55. function Start(){
    56.     //buttonSequence = new Array();
    57.    
    58.     yield WaitForSeconds(4); // wait for animtaion
    59.    
    60.     rootObject.transform.position = Vector3.zero;
    61.     NewGame();
    62. }
    63.  
    64. function Update () {
    65.     if(gameState == State.Play){
    66.         UpdateTime();
    67.         UpdateTouchInput();
    68.     }
    69.     UpdateCorona();
    70. }
    71.  
    72. function OnGUI(){
    73.     GUI.skin = guiSkin;
    74.     GUI.color = guiColour;
    75.    
    76.     if(gameState == State.Initialise){
    77.        
    78.     }else if(gameState == State.GameOver){
    79.         GUI.DrawTexture(Rect(0,Screen.height/2-(Screen.width*0.1),Screen.width,Screen.width*0.2),gameOverTexture);
    80.         GUI.Label(Rect(0,50,Screen.width,40),"SCORE: "+score,"Centered");
    81.         if(GUI.Button(Rect(Screen.width/2-190,Screen.height/2+(Screen.width/11)+20,180,40),"","Restart")){
    82.             Application.LoadLevel(Application.loadedLevel);
    83.         }
    84.         if(GUI.Button(Rect(Screen.width/2+10,Screen.height/2+(Screen.width/11)+20,180,40),"","Menu")){
    85.             // go to menu
    86.             Application.LoadLevel("TTT_MainMenu");
    87.         }
    88.     }else if(gameState == State.LevelComplete){
    89.         GUI.Label(Rect(Screen.width*0.04,15,Screen.width,40),"LEVEL - "+currentLevel.ToString());
    90.         GUI.Label(Rect(Screen.width*0.04,27,Screen.width,40),"SCORE - "+score.ToString());
    91.         GUI.DrawTexture(Rect(0,Screen.height/2-(Screen.width*0.05),Screen.width,Screen.width*0.1),levelCompleteTexture);
    92.         GUI.Label(Rect(0,Screen.height-100,Screen.width,40),"Level Bonus: "+(currentLevel*difficultyLevel*20),"Centered");
    93.         for(i=0;i<lives;i++){
    94.             GUI.DrawTexture(Rect(Screen.width-32*i-42,Screen.height-35,32,30),heartIcon);
    95.         }
    96.     }else if(gameState == State.Win){
    97.         GUI.Label(Rect(Screen.width*0.04,15,Screen.width,40),"LEVEL - "+currentLevel.ToString());
    98.         GUI.Label(Rect(Screen.width*0.04,27,Screen.width,40),"SCORE - "+score.ToString());
    99.         GUI.Label(Rect(0,Screen.height/2-6,Screen.width,40),Mathf.Ceil(timeCounter).ToString(),"Centered");
    100.         GUI.Label(Rect(0,Screen.height-100,Screen.width,40),"Time Bonus: "+(Mathf.Ceil(timeCounter)*difficultyLevel),"Centered");
    101.         for(i=0;i<lives;i++){
    102.             GUI.DrawTexture(Rect(Screen.width-32*i-42,Screen.height-35,32,30),heartIcon);
    103.         }
    104.     }else if(gameState == State.Pause){
    105.         // Pause Buttons
    106.         if(Screen.width<500){
    107.             if(GUI.Button(Rect(Screen.width*.85,Screen.height*.05625,48,43),"","Pause")){
    108.                 gameState = State.Play;
    109.             }      
    110.         }else{
    111.             if(GUI.Button(Rect(846,34,97,84),"","Pause")){
    112.                 gameState = State.Play;
    113.             }
    114.         }
    115.         if(GUI.Button(Rect(Screen.width/2-90,Screen.height/2-40,180,40),"","Continue")){
    116.             gameState = State.Play;
    117.         }
    118.         if(GUI.Button(Rect(Screen.width/2-90,Screen.height/2+5,180,40),"","Restart")){
    119.             Application.LoadLevel(Application.loadedLevel);
    120.         }
    121.         if(GUI.Button(Rect(Screen.width/2-90,Screen.height/2+50,180,40),"","Menu")){
    122.             // load menu
    123.             Application.LoadLevel("TTT_MainMenu");
    124.         }
    125.         GUI.Label(Rect(Screen.width*0.04,15,Screen.width,40),"LEVEL - "+currentLevel.ToString());
    126.         GUI.Label(Rect(Screen.width*0.04,27,Screen.width,40),"SCORE - "+score.ToString());
    127.         for(i=0;i<lives;i++){
    128.             GUI.DrawTexture(Rect(Screen.width-32*i-42,Screen.height-35,32,30),heartIcon);
    129.         }
    130.     }else if(gameState == State.Play){
    131.         // Pause Buttons
    132.         if(Screen.width<500){
    133.             if(GUI.Button(Rect(Screen.width*.85,Screen.height*.05625,48,43),"","Pause")){
    134.                 gameState = State.Pause;
    135.             }      
    136.         }else{
    137.             if(GUI.Button(Rect(846,34,97,84),"","Pause")){
    138.                 gameState = State.Pause;
    139.             }
    140.         }
    141.         GUI.Label(Rect(Screen.width*0.04,15,Screen.width,40),"LEVEL - "+currentLevel.ToString());
    142.         GUI.Label(Rect(Screen.width*0.04,27,Screen.width,40),"SCORE - "+score.ToString());
    143.         GUI.Label(Rect(0,Screen.height/2-6,Screen.width,40),Mathf.Ceil(timeCounter).ToString(),"Centered");
    144.         for(i=0;i<lives;i++){
    145.             GUI.DrawTexture(Rect(Screen.width-32*i-42,Screen.height-35,32,30),heartIcon);
    146.         }
    147.     }else{
    148.         GUI.Label(Rect(Screen.width*0.04,15,Screen.width,40),"LEVEL - "+currentLevel.ToString());
    149.         GUI.Label(Rect(Screen.width*0.04,27,Screen.width,40),"SCORE - "+score.ToString());
    150.         GUI.Label(Rect(0,Screen.height/2-6,Screen.width,40),Mathf.Ceil(timeCounter).ToString(),"Centered");
    151.         for(i=0;i<lives;i++){
    152.             GUI.DrawTexture(Rect(Screen.width-32*i-42,Screen.height-35,32,30),heartIcon);
    153.         }
    154.     }
    155. }
    156.  
    157. function UpdateTime(){
    158.     timeCounter -= Time.deltaTime;
    159.     if(timeCounter <= 0){
    160.         LoseLife();
    161.     }
    162. }
    163.  
    164. function UpdateTouchInput(){
    165.     // spin the disc
    166.     if(currentLevel >= 1){
    167.         outerRing.transform.Rotate(Vector3.forward*outerSpinSpeed*Time.deltaTime);
    168.     }
    169.     if(currentLevel >= 20){
    170.         innerRing.transform.Rotate(-Vector3.forward*innerSpinSpeed*Time.deltaTime);
    171.     }
    172.    
    173.     if(Application.isEditor){
    174.         // stuff
    175.     }else{
    176.         if(Input.touchCount == 1  Input.GetTouch(0).phase == TouchPhase.Began){
    177.            
    178.             // Construct a ray from the current mouse coordinates
    179.             ray = Camera.main.ScreenPointToRay (Input.GetTouch(0).position);
    180.        
    181.             if (Physics.Raycast (ray,hit)) {
    182.                 for(i=0;i<4;i++){
    183.                     if(hit.collider.gameObject == outerButtons[i]){
    184.                         TouchButton(outerButtons[i]);
    185.                         outerButtons[i].renderer.material.color = Color.white;
    186.                         if(!PlayerPrefs.HasKey("Mute")){
    187.                             audio.pitch = 1-i*0.1;
    188.                             audio.Play();
    189.                             }
    190.                     }else if(hit.collider.gameObject == innerButtons[i]){
    191.                         TouchButton(innerButtons[i]);
    192.                         innerButtons[i].renderer.material.color = Color.white;
    193.                         if(!PlayerPrefs.HasKey("Mute")){
    194.                             audio.pitch = 1-i*0.1;
    195.                             audio.Play();
    196.                         }
    197.                     }
    198.                 }
    199.             }
    200.         }
    201.    
    202.         if(Input.GetTouch(0).phase == TouchPhase.Ended || Input.GetTouch(0).phase == TouchPhase.Canceled || Input.touchCount < 1){
    203.             // make all materials grey
    204.             for(i=0;i<4;i++){
    205.                 innerButtons[i].renderer.material.color = Color.grey;
    206.                 outerButtons[i].renderer.material.color = Color.grey;
    207.             }
    208.         }      
    209.     }
    210. }
    211.  
    212. function TouchButton(go : GameObject){
    213.     if(go == buttonSequence[sequenceIndex]){
    214.         sequenceIndex++;
    215.         score += sequenceIndex;
    216.         if(buttonSequence.length == sequenceIndex){
    217.             Win();
    218.         }
    219.     }else{
    220.         LoseLife();
    221.     }
    222. }
    223.  
    224. function Win(){
    225.     //stuff
    226. }
    227.  
    228. function LoseLife(){
    229.     // stuff
    230. }
    231.  
    232. function NewGame(){
    233.    
    234.     flashTime *= 0.9;
    235.     flashTime = Mathf.Clamp(flashTime,0.2,1);
    236.    
    237.     if(buttonSequence.length >= difficultyLevel*5){
    238.         gameState = State.LevelComplete;
    239.         score += currentLevel*difficultyLevel*20; // level bonus
    240.        
    241.         animationRoot.animation.Play("fly out and in");
    242.         yield WaitForSeconds(4.5); // display the level complete screen for 3.5 seconds
    243.        
    244.         rootObject.transform.position = Vector3.zero;
    245.        
    246.         currentLevel++;
    247.        
    248.         // Clear the array
    249.         buttonSequence.Clear();
    250.         sequenceLength = 0;
    251.        
    252.         //lives = 3;
    253.         flashTime = 1-currentLevel*0.01;
    254.         outerSpinSpeed += 6;
    255.         outerSpinSpeed = Mathf.Clamp(outerSpinSpeed,0,maxSpinSpeed);
    256.         if(currentLevel>5){
    257.             innerSpinSpeed += 6;
    258.             innerSpinSpeed = Mathf.Clamp(innerSpinSpeed,0,maxSpinSpeed);
    259.         }
    260.     }
    261.    
    262.     timeCounter = maxTime-difficultyLevel*5;
    263.  
    264.     UpdateSequence();
    265. }
    266.  
    267. function LoseRepeat(){
    268.     // stuff
    269. }
    270.  
    271. function UpdateSequence(){
    272.     gameState = State.Sequence;
    273.    
    274.     // set up the audio
    275.     audio.clip = pingSound;
    276.    
    277.     // make all materials grey
    278.     for(i=0;i<4;i++){
    279.         innerButtons[i].renderer.material.color = Color.grey;
    280.         outerButtons[i].renderer.material.color = Color.grey;
    281.     }
    282.    
    283.     // Step 1: Select a random button
    284.     var buttonIndex = Random.Range(0,4);
    285.     var buttonGO : GameObject;
    286.     if(currentLevel < 5){ // inner ring only activates beyond level 20
    287.         buttonGO = outerButtons[buttonIndex];
    288.     }else{
    289.         if(Random.value>0.5){ // outer ring
    290.             buttonGO = outerButtons[buttonIndex];
    291.         }else{  // inner ring
    292.             buttonGO = innerButtons[buttonIndex];
    293.         }
    294.     }
    295.     // Step 2: Record the button
    296.     buttonSequence.Push(buttonGO);
    297.    
    298.     // Step 3: Flash the whole sequence button on for a second
    299.     for(i=0;i<buttonSequence.length;i++){
    300.         buttonSequence[i].renderer.material.color = Color.white;
    301.        
    302.         // pitch change audio
    303.         for(j=0;j<4;j++){
    304.             if(buttonSequence[i] == outerButtons[j]){
    305.                 if(!PlayerPrefs.HasKey("Mute")){
    306.                     audio.pitch = 1-j*0.1;
    307.                     audio.Play();
    308.                     break;
    309.                 }
    310.             }else if(buttonSequence[i] == innerButtons[j]){
    311.                 if(!PlayerPrefs.HasKey("Mute")){
    312.                     audio.pitch = 1-j*0.1;
    313.                     audio.Play();
    314.                     break;
    315.                 }
    316.             }
    317.         }
    318.            
    319.         yield WaitForSeconds(flashTime);
    320.            
    321.         buttonSequence[i].renderer.material.color = Color.grey;
    322.         audio.Stop();
    323.            
    324.         yield WaitForSeconds(flashTime/2);
    325.     }
    326.    
    327.    
    328.     gameState = State.Play;
    329. }
    330.  
    331. function UpdateCorona(){
    332.     // stuff
    333. }
    334.  
    335. function PlayFlyOut(){
    336.      // stuff
    337. }
    338.  
    339. function GameOver(){
    340.     // stuff
    341. }
     
  5. spinaljack

    spinaljack

    Joined:
    Mar 18, 2010
    Posts:
    893
    had to chop out some bits to fit it in but I don't know which bit in it is causing the error. It happens the moment the scene is loaded and there's no other scripts in the scene.

    From the error it sounds like GetRenderer is the problem but I don't know where in my code that appears

    EDIT:

    so changing all the gameObject.renderer

    into

    var temp : Renderer = gameObject.GetComponent(Renderer)

    Causes the same error but with "renderer" replaced by "GetComponent" in the error message

    Could it be because I'm using Array()?
    Lets give that a try...

    EDIT2:

    YEA!
    Thanks unity community, solved it. It was indeed the use of javascript arrays and the lack of dynamic type setting in iphone. It didn't get flagged up in the editor so I missed it.

    Assigning the contents of the Array to a game object variable let me perform the required tasks on the objects in the array without the game crashing
     
    Last edited: Nov 12, 2010
  6. aerende

    aerende

    Joined:
    Apr 27, 2009
    Posts:
    316
    @spinaljack -

    I have the same problem. Can you post what piece of code you changed?
     
unityunity