So I’ve been noticing that IL2CPP has been showing up more and more and Mono showing up less and less. And from research that I’m doing, it seems that IL2CPP seems to be better but compile times are slow. So, is it better to use IL2CPP over Mono, and why? Also, why is IL2CPP becoming so pronounced over Mono? Another thing, don’t know where to put these questions so I’m putting them here.
There are a number of trade-offs in both directions. The two scripting backends are different - your choice depends on your use case. Here is a far-to-brief overview:
Ahead-of-time (IL2CPP) vs. JIT (Mono) compilation:
Compile times for AOT are longer, but the binary is completely specified when you ship a game. JIT compilation is faster, but compilation to machine code occurs on the end user’s device (many platforms are AOT-only, so you may not have a choice). JIT is more flexible - you can use more of .NET, where AOT is faster for some cases (e.g. IL2CPP is better at floating point math than Mono).
Can we expand on this difference?
IL2CPP has been in works for several years.
What about libraries?
I use several external libraries how are these .NET libraries effected?
In the meantime, your colleagues have also added this document:
https://unity3d.com/learn/tutorials/topics/best-practices/il2cpp-mono
IL2CPP should work fine with any library that works with an AOT platform. If if the library uses dynamic code generation (via System.Reflection.Emit), it won’t work with IL2CPP.
In general, IL2CPP correctly converts and runs any .NET code from C# (we don’t support F#, for example) - modulo bugs, of course (but we try to fix those pretty fast).
I’ve tried IL2CPP a couple of times but always run into unimplemented functions. For example,
IL2CPP does not support FileSystemWatcher for some reason.
IL2CPP does not support marshaling delegates that point to instance methods to native code, so Facepunch.Steamworks doesn’t work with it.
So while YMMV, I measured it more in yards than miles.
I am programmer in learning :), so not too experienced with what goes on in the back end…
In simple terms, as of 2018.2.x can I set my project (building for windows 10) .Net 4.6 and IL2CPP and move on? In other words is there a reason NOT to use 4.6/IL2CPP?
Thanks!
There is no reason to avoid using IL2CPP unless you’re doing some weird runtime wizard nonsense (reflection) or you need to have faster build testing cycles and your code changes a lot
Further details:
The reason is that IL2CPP does not support marshaling delegates that point to instance methods to native code, so Facepunch.Steamworks doesn’t work with it.
So if you have a fix for this please let us know.
i’m publishing my game to android platform , which one should I go for ? I’ve tried both and didn’t see any difference
IL2CPP is always faster, so it will likely assist on slower devices. For further performance I would recommend gpu optimisations.
IL2CPP seems to extend the time it takes to build by… a lot. I don’t think it can be understated just how much slower IL2CPP is than Mono. Which makes sense - cpp is a lot slower to compile than C#, and you also have the whole conversion step in there.
My experience has been that it’s not viable to use IL2CPP to produce builds for testing without a build server. It’s also deeply problematic for profiling - you should profile builds, but when builds takes 30 minutes to and hour (or longer), checking if a single change makes a difference for runtime speed becomes a several hour project.
The manual says:
“Tip: You should use IL2CPP to both develop and ship your Project. If iteration times end up being too slow using IL2CPP, switch temporarily to the Mono Scripting Backend during development to improve iteration speed.”
I think that “if” could safely be changed to “when”.
The elephant in this room seems to be build size. I went up 12.7 MB! I’m still looking into this, if some engine stripping works I can possibly drop that to an expansion of 7.9 MB. That’s still sizable. This is a typical free-to-play mobile game with puzzle and meta game.
The trade-off is supposed to be that it loads and runs faster. But my iOS experience (which has been il2cpp for years) is, eh, not so much.
So I can’t complain because Unity is a great tool. But it’s hard to polish the cost here. Hopefully it pays off somehow.
every platform(armebi-v7a/arm64/x86) will generate a libil2cpp.so, have any suggestion to handle it?
IL2CPP does not support C# processes! If you are designing a server for Linux you cannot use IL2CPP.
I am shocked they have fixed this yet.
In theory I would choose IL2CPP as its performance should be better. I am just at a show-stopper now that I can’t spawn a new process with C#
My big question is - how much overhead is it to develop (just a single project) using Mono, then switch the project to IL2CPP? The usual obvious answer being, ‘It depends on what you are up to’… but does anyone else have any experience here?
I do not have (doubt anyone would, but feel free to test yourself) one to one comparison since there is no reason to have two identical projects with mono and il2cpp.
That being said, I do have a project (around 80 gb project and around 3gb built) and I did not notice any slowness that is worth mentioning or made me wonder while developing. I think where you pay little bit of time is when you build. Mono little faster. However you would only notice (from my experience) when you do your initial build. You probably won’t notice much difference for incremental builds, unless your project is large, like over 10-15 gb after build. Honestly, you should have a separate build machine. Just let it do its thing while you work.
I personally would not base my decision on development overhead though, I would gladly pay that price for runtime performance.
Ultimately test it out with your prototype on your target device. For the most part (assuming you do not use any assets with limitations or your target platform) you can switch between the two.
Be aware of other nuances though, things like modding (make is difficult with il2cpp)
is modding easier with mono?
We were developing a game and with Mono backend performance was more than acceptable, however no ARM64 support is available… when we switch to IL2CPP we discover horrirized that the performance was clunky and slow… WHEN RUNNING (compile time were also 4x o 8x longer). We tried with the latest Unity and same history… how is this possible? Please add ARM64 mono backend support!!!
Either you’re building in debug configuration (check your player settings) or you hit some pathological case (in which case a bug report might be needed).