Search Unity

Device Exception:Two Diamentional Arrays

Discussion in 'iOS and tvOS' started by murali.vvn, Oct 16, 2010.

  1. murali.vvn

    murali.vvn

    Joined:
    Jun 28, 2010
    Posts:
    53
    Code (csharp):
    1.  
    2. private var field: Array;
    3.  
    4. function Start(){
    5.        field=new Array([1,5,9,13], [2,6,10,15], [3,7,11,14], [4,8,12,0]);
    6.        Debug.Log(field[1][1]);
    7. }
    8.  
    9. [/code/
    10.  
    11. Above code working in fine in pc, if I installed in ipad at run time getting below exception, Plz any one help me to solve this problem, its very urgent for me...
    12.  
    13. ExecutionEngineException: Attempting to JIT compile method '(wrapper dynamic-method) Boo.Lang.Runtime.RuntimeServices:RuntimeServices$op_Addition$System.String$System.Int32 (object,object[])' while running with --aot-only.
    14.  
    15.  at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, Boolean throwOnBindFailure) [0x00000] in <filename unknown>:0
    16.  at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method, Boolean throwOnBindFailure) [0x00000] in <filename unknown>:0
    17.  at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method) [0x00000] in <filename unknown>:0
    18.  at System.Reflection.Emit.DynamicMethod.CreateDelegate (System.Type delegateType) [0x00000] in <filename unknown>:0
    19.  at Boo.Lang.Runtime.DynamicDispatching.Emitters.DispatcherEmitter.CreateMethodDispatcher () [0x00000] in <filename unknown>:0
    20.  at Boo.Lang.Runtime.DynamicDispatching.Emitters.DispatcherEmitter.Emit () [0x00000] in <filename unknown>:0
    21.  at Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.EmitMethodDispatcher (Boo.Lang.Runtime.CandidateMethod found, System.Type[] argumentTypes) [0x00000] in <filename unknown>:0
    22.  at Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.Create () [0x00000] in <filename unknown>:0
    23.  at Boo.Lang.Runtime.RuntimeServices.DoCreateMethodDispatcher (System.Object target, System.Type targetType, System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
    24.  at Boo.Lang.Runtime.RuntimeServices.CreateMethodDispatcher (System.Object target, System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
    25.  at Boo.Lang.Runtime.RuntimeServices+<Invoke>c__AnonStorey13.<>m__7 () [0x00000] in <filename unknown>:0
    26.  at Boo.Lang.Runtime.DynamicDispatching.DispatcherCache.Get (Boo.Lang.Runtime.DynamicDispatching.DispatcherKey key, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) [0x00000] in <filename unknown>:0
    27.  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
    28.  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
    29.  at Boo.Lang.Runtime.RuntimeServices.Invoke (System.Object target, System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
    30.  at Boo.Lang.Runtime.RuntimeServices.InvokeRuntimeServicesOperator (System.String operatorName, System.Object[] args) [0x00000] in <filename unknown>:0
    31.  at Boo.Lang.Runtime.RuntimeServices.InvokeBinaryOperator (System.String operatorName, System.Object lhs, System.Object rhs) [0x00000] in <filename unknown>:0
    32.  at Swipe.Start () [0x00000] in <filename unknown>:0
     
  2. marjan

    marjan

    Joined:
    Jun 6, 2009
    Posts:
    563
    Try writing this with New Array() instead of []. If that doesn't work explicitly Write New Array() and then use push to add that to the Main Array.
     
  3. murali.vvn

    murali.vvn

    Joined:
    Jun 28, 2010
    Posts:
    53
    Thanks for the reply marjan.

    I tried so many ways those are all working in pc but getting same exception on the device. but if I use single dimensional array its working fine in device also.I need to do more operations on the array so I can't use push method every time.

    Is there any support for two dimensional arrays in mobile device??
     
  4. murali.vvn

    murali.vvn

    Joined:
    Jun 28, 2010
    Posts:
    53
    Any one plz give me sample code of two-dimensional arrays that should work in iPhone device (should not get any run time exception).
     
  5. pelizondo

    pelizondo

    Joined:
    Oct 18, 2010
    Posts:
    6
    I've got the same exact exception. Why does it say "Boo.Lang.RunTime" if this is javascript?

    ExecutionEngineException: Attempting to JIT compile method '(wrapper dynamic-method) UnityScript.Lang.Array:Array$get_Item$System.Int32 (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.DynamicDispatching.SliceDispatcherFactory.EmitMethodDispatcher (IEnumerable`1 candidates) [0x00000] in <filename unknown>:0
    at Boo.Lang.Runtime.DynamicDispatching.SliceDispatcherFactory.EmitMethodDispatcher (System.Reflection.MethodInfo candidate) [0x00000] in <filename unknown>:0
    at Boo.Lang.Runtime.DynamicDispatching.SliceDispatcherFactory.CreateGetter (System.Reflection.MemberInfo member) [0x00000] in <filename unknown>:0
    at Boo.Lang.Runtime.DynamicDispatching.SliceDispatcherFactory.CreateGetter () [0x00000] in <filename unknown>:0
    at Boo.Lang.Runtime.RuntimeServices.CreateGetSliceDispatcher (System.Object target, System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
    at Boo.Lang.Runtime.RuntimeServices+<GetSlice>c__AnonStorey1A.<>m__11 () [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.Dispatch (System.Object target, System.String cacheKeyName, System.Object[] args, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) [0x00000] in <filename unknown>:0
    at Boo.Lang.Runtime.RuntimeServices.GetSlice (System.Object target, System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
    at BabyBoomer.Update () [0x00000] in <filename unknown>:0


    Here's my code that I use to make the Two dimensional array. :confused:

    //Level 1
    var arrLevel1 = new Array();
    arrLevel1.Push(2);

    //Level 2
    var arrLevel2 = new Array();
    arrLevel2.Push(6);
    arrLevel2.Push(3);

    //Level 3
    var arrLevel3 = new Array();
    arrLevel3.Push(1);
    arrLevel3.Push(3);
    arrLevel3.Push(5);
    arrLevel3.Push(7);

    var arrAllLevels = new Array ();
    arrAllLevels.Push(arrLevel1);
    arrAllLevels.Push(arrLevel2);
    arrAllLevels.Push(arrLevel3);

    Looks good to me, any thoughts?
     
  6. murali.vvn

    murali.vvn

    Joined:
    Jun 28, 2010
    Posts:
    53
    Finally I got it.....

    The error is "Debug.Log".

    Debug.Log("******************"+field[1][1]);//Getting Exception at run time

    Debug.Log(field[1][1]); //Not getting any run time Exception.

    String concatenation is giving the run time exception..
     
  7. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Just as a double check, can you try access field[1][1] outside of a Debug.Log() call?
     
  8. zannghast

    zannghast

    Joined:
    Aug 17, 2010
    Posts:
    80
    String concatenation in Debug.Log should generally work. Why didn't it in your statement with the asterisks? I'm not implying something, I'm just really curious to know if there's something about that particular statement (maybe something we could avoid ourselves when concatenating such values).
     
  9. murali.vvn

    murali.vvn

    Joined:
    Jun 28, 2010
    Posts:
    53
    Just as a double check, can you try access field[1][1] outside of a Debug.Log() call?

    Yes I can access field[1][1] any where in the script its working, but If I want to print its value I should Debug.Log(field[1][1]) only, if I am using like Debug.Log("******************"+field[1][1]) (any string concatenation) Its not running in the device. And one more thing I would like to say is if you are building your game for iPhone you should properly declare the variable type. below I gave one example

    Code (csharp):
    1.  
    2. var tile1: GameObject;
    3. var tile2: GameObject;
    4. var tile3: GameObject;
    5. var tile4: GameObject;
    6.  
    7. private var tile: Array;
    8.  
    9. function Start(){
    10.      tile= new Array(tile1,tile2,tile3,tile4);
    11.  
    12.      tile[0].transform.position.x=1.0;
    13.      // above statement gives Device exception. I am thinking that Boo compiler is not considering dynamic type casting so its giving exception.
    14.  
    15.     var tempTile: GameObect= tile[0];
    16.     tempTile.transform.positon.x=1.0;
    17.    //above statement will executes perfectly in the device. Here we are specifying the type of tile[0].
    18. }
    19.  
    20.