Search Unity

Strange crash when copying an Array

Discussion in 'Scripting' started by Finthis, Jun 16, 2012.

  1. Finthis

    Finthis

    Joined:
    Apr 1, 2011
    Posts:
    27
    Hello,

    I'm experiencing a persistent and strange crash when testing my Unity app on the iPad. Inside the Unity editor on both mac and PC I have no problems, but when I run the app on the iPad for testing, I get frequent crashes which freeze Xcode and cause me to force quit. This is the last thing I see:

    Code (csharp):
    1.  
    2. System.String doesn't implement interface System.Collections.IEnumerator
    3. * Assertion: should not be reached at mini-trampolines.c:183

    There is another post
    with the exact same error, but from the posts it's unclear to me what the error is and why it was stopped.

    For me, it seems to stem from doing this:

    Code (csharp):
    1. var arrayA:Array = new Array(arrayB); // copy arrayB into arrayA
    But if I do

    Code (csharp):
    1. var arrayA:Array = new Array();
    2. for ( var i:int = 0; i < arrayB.length; ++i )
    3.      arrayA.Push( arrayB[i] );
    everything seems to work just fine. I've used the initial way of copying an Array in other apps I've created and put on the app store with Unity and don't remember ever running into a problem like this. I dislike solutions like this because it doesn't it doesn't make any sense to me. :(

    I'm using Unity 3.5.2 and deploying to an iPad running 5.1, and this is all in javascript.

    Anyone know what may be happening? :confused:

    - Joe
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It would be a really good idea to never use Array at all. Use built-in arrays if the size is fixed (in which case you can use System.Array.Copy to duplicate an array), or List otherwise.

    --Eric
     
  3. Finthis

    Finthis

    Joined:
    Apr 1, 2011
    Posts:
    27
    That seems like a really unfortunate solution - is Array just plain unstable? I like the flexibility of using an Array so I don't have to have a fixed size. I've been using them in projects pretty liberally for over a year now and don't remember running into a problem like this before.

    But it looks like the generic lists really supply the same functionality, so I can try using them. It just seems pretty unfortunate that something so basic causes problems on iOS.
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's very slow, and untyped.

    Use a List; they are faster, have more functionality, and are easier to use since you don't have to cast when retrieving. Using List instead of Array should be default regardless of whether you're using iOS or another platform; really UT should just remove Array at this point.

    --Eric
     
  5. grimmy

    grimmy

    Joined:
    Feb 2, 2009
    Posts:
    409
    I have exactly the same crash. Although I can't as yet track down the issue I am not copying any arrays in my code. The game works fine in the editor.

    I never used to get this crash but since I started working on an update to our game(and having since updated Unity) I get this all the time.

    I have tried a few things to no avail:
    Updating my Xcode (and OS to Lion)
    Removing a load of print commands (I read somewhere this could affect some things ?!?- although I'm doubtful)
    ..among other minor changes to the code...

    If anyone has any more clues on this I'd love to know. Any errors that appear outside Unity are very hard for me to track.

    Cheers
     
  6. grimmy

    grimmy

    Joined:
    Feb 2, 2009
    Posts:
    409
    ..I should also add that I am only using built in arrays anywhere near the point of code that this crashes. Could this be some kind of Unity bug?
     
  7. masha

    masha

    Joined:
    Aug 20, 2012
    Posts:
    8
  8. iiley

    iiley

    Joined:
    Sep 4, 2012
    Posts:
    14
    We have encounter this issue too today:
    System.String doesn't implement interface com.burstyx.core.IAnimParameters
    * Assertion: should not be reached at mini-trampolines.c:183


    We do have some call on String.Split, or String.Replace, but that is the old code, it runs well before so i think these are ok. But these days, after we added many other code, runs well on Mac Unity editor, but crash on iPad with that output, any idea?

    Thanks very much in advance!
     
  9. FeatureCreep

    FeatureCreep

    Joined:
    Oct 5, 2012
    Posts:
    6