Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by chenjiaxu11 · May 10, 2012 at 11:03 AM · iphoneexecutionexecutionengineexception

"ExecutionEngineException: Attempting to JIT compile method" when Marshal.PtrToStructure function operating on iphone

There was an error "ExecutionEngineException: Attempting to JIT compile method" when I operate Marshal.PtrToStructure function on iphone, how can I sovel it?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by rutter · May 10, 2012 at 06:37 PM

When running on iOS, JIT ("just in time") compilation is limited or impossible, and all of your code must be compiled AOT ("ahead of time"). Depending on the particular error, there are two common causes:

  • Your application makes use of some generic type that was missed during AOT compile.

  • Your application uses reflection or other dynamically generated code.

The first problem can usually be fixed by including a "dummy" class that references the missing types.

The second problem is a doozy, and I think is best avoided if possible. I'd guess that you're running into this one.

tl;dr If you're not sure what any of this means, you've probably imported a library that's not compatible with iOS.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DannyB · Jun 09, 2013 at 05:18 PM 0
Share

Good question and good answer. For me, the problem was having a generic method that forwarded its T to another generic method. The solution was to call that second method, with all the possible types of T in some dummy method inside the class.

avatar image ederfgd · Mar 15, 2014 at 06:42 PM 0
Share

But in the case of using dynamically generated codes, just like those genereted for a wsdl SOAP service?

avatar image Umai · Nov 27, 2014 at 02:32 AM 0
Share

Just ran into this problem. Turned out this code does not work on iOS, but works well in Unity: http://www.codeproject.com/$$anonymous$$B/tips/SerializedObjectCloner.aspx I used it to deep clone an object. Any solid way of serializing/cloning C# objects in Unity?

avatar image
3

Answer by mviuk · Jun 18, 2012 at 09:13 AM

I had this issue when attempting to use System.Net.WebClient, it was working for several weeks, then stopped working and I got the same error. Turns out I'd changed the API Compatibility Level to .NET 2.0 rather than .NET 2.0 Subset, changing it back to the subset resolved the issue. Kind of weird that the Subset works but .NET 2.0 (which I'd assume to be the superset) doesn't.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image whydoidoit · Jun 18, 2012 at 09:21 AM 0
Share

Yeah it has to do with the fact that Subset uses a different non-generic method of getting some properties and fields - so Subset is slower, but happens to work on IOS in this case because it doesn't need the generic types that get JIT compiled. There are work arounds you can use to make the full version work like this which work in some circumstances.

avatar image superdev · Jun 06, 2013 at 10:59 PM 0
Share

Holy crap this fixed a major issue I was having. Thanks! +1 if I could.

avatar image
1

Answer by demonpants · Jan 27, 2013 at 01:07 AM

I was not using any reflection or any other sneaky stuff, and I also was not using dynamic types anywhere. However, I was getting this issue as well. The problem came down to dynamic arrays, like this:

 int[,,] array3d;

It actually wouldn't freak out until I instantiated the array, then would refuse to JIT the function that was doing the instantiation. Like this:

 public void ThisWillBreakInAOT()
 {
     array3d = new int[ 10, 15, 20 ];
 }

So for those of you who aren't masters with C#'s inner workings and were thinking that you should always do multidimensional arrays with that syntax, now you know – don't do it if you want to run on iPhone. I ended up just flattening all my arrays into 1D arrays since that's faster to use anyway.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image andrewow · May 04, 2015 at 09:49 AM 0
Share

Can you please share what is the proper way to initialize the array?

avatar image demonpants · May 04, 2015 at 05:07 PM 0
Share

As I said, I flattened by arrays, and made a class to simplify access. So, like this:

int[] array3d = new int[ width * height * length ]; array3d[ i * width * height + j * height + k ] = value;

avatar image demonpants · May 04, 2015 at 06:04 PM 0
Share

Also, I think this sort of array works:

int[][][] array3d = new int[width][height][length];

But I recall that behaving weirdly in C# so I avoided using it.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Load from XML on iPhone 1 Answer

Drawing on Textures on the iPhone (larger than 200) 3 Answers

Unity Time and Timing-Different from Iphone Time and Timing?? 1 Answer

Determine iPhone Type (3G vs 3GS) 1 Answer

Optimal # of Faces for many mesh scene for mobile 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges