Search Unity

  1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice

'new' running fine in Mac/Windows player but crashes in iPhone player

Discussion in 'iOS and tvOS' started by AnmolThakur, Nov 8, 2011.

  1. AnmolThakur

    AnmolThakur

    Joined:
    Jun 16, 2011
    Posts:
    4
    A simple 'new' statement is crashing on iPad2 with iOS-5, but the same code works fine on Mac/Windows player builds.

    Xcode 4.2 on MacOSX 10.6, gdb outputs: "compute_class_bitmap: Invalid type 13 for field GraphNode`1[T]:data"

    Below is the details of the object i am creating.

    Code (csharp):
    1. //A generic base class for graph node
    2. //
    3. public class GraphNode<T> {
    4.   //ctor
    5.     public GraphNode(string nodeId, T data) {
    6.         this.Id = nodeId;
    7.         this.data = data;
    8.     }
    9.  
    10.   ...
    11.  
    12.   //fields
    13.     string Id;
    14.     T data;
    15.     List< GraphNode<T> > neighbors = new List< GraphNode<T> >();
    16.     ...
    17. }
    18.  
    19. public class Puzzle {
    20.     public class Checkpoint {
    21.       ...
    22.     }
    23.  
    24.     //A graph of some checkpoints
    25.     //
    26.     public class CheckpointsGraphNode : GraphNode<Checkpoint> {
    27.       //ctor
    28.         public CheckpointsGraphNode(string chkptId, Checkpoint chkpt) : base(chkptId, chkpt) {
    29.             ...
    30.         }
    31.  
    32.         ...
    33.     }
    34.  
    35.     ...
    36. }
    37.  
    38. ...
    39.  
    40. ...
    41.  
    42. Puzzle.CheckpointsGraphNode node = new Puzzle.CheckpointsGraphNode(nodeId, chkpt);
    43.                                       //
    44.                                       //The program crashes here on iPad
    45.                                       // at runtime with error "compute_class_bitmap: Invalid type 13 for field GraphNode`1[T]:d"
    46. ...
    Can anybody please help me out? I believe this is some trivial problem, but im unable to solve it. This is my first project with unity and also C#. I come from C/C++ background.

    I am using .NET subset Api compatibility level and Unity iOS.
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,596
    AOT does not allow such 'generic of generic' datastructures in a general form if I recall right so the solution is not to do use generic of generic but make the nested one one with an effective class instead of the generic T

    anything but iOS, X360 and PS3 use JIT, not AOT, thats why its no problem on win - osx.
     
  3. AnmolThakur

    AnmolThakur

    Joined:
    Jun 16, 2011
    Posts:
    4
    Ouch. Thanks a lot. It worked! :)
     
  4. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,327
    Where can we learn more about these rules?
     
  5. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,596
    The only reference that mentions anything on AOT limitations in general are on the MonoTouch page (unity does not use nor support it, but AOT has generally the same limitation) at least to my knowledge. You can find it on http://docs.xamarin.com/ios/about/limitations

    Generally AOT is not the 'standard' in .NET even less in Mono, its the exception for obvious reasons (only embedded and limited platforms can use it without sacrificing lots of performance from JIT optimizations)

    I know about it due to the preorder beta on Unity 3 where it was first talked about it.
     
    Last edited: Nov 8, 2011
  6. Smooth-P

    Smooth-P

    Joined:
    Sep 15, 2012
    Posts:
    214
    I've just started running into this and wow does it castrate the power of generics.

    ...and of course I notice that it isn't listed as an issue for the current version of Mono.
     
    Last edited: Apr 27, 2014