-
Notifications
You must be signed in to change notification settings - Fork 393
The library does not compile when used with IL2CPP in Unity3D #1009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Huh, interesting! 😅 To be honest, I don't think UnitsNet is a good fit for Unity3D. I'm sure we could figure out the IL2CPP problem, but you are bringing in about 2MB of binary just for some help with conversions. Also, performance is not a priority in this library, which I would typically think is a concern in games and live rendering. I don't personally have the time to look into this, but if you want to take a look and try to debug it and maybe come up with a pull request, then I'd be happy to assist and help get it merged. |
Well, since it's only for the build, I guess adding more RAM would theoretically be fine... 😅 Apart from that though, I found it a pretty good fit for my needs. It did not get in the way performance-wise, neither when I tried it on desktop in Unity or in Blazor(!) in another project using the same assembly. The 2MB is definitely something I would have liked to change, however, as I am only using a tiny part of the library. I'm afraid the time schedule is pretty tight in the current project, so my current solution was to simply yank it out, but if I have more time at a later point I might have another look. |
@joshpeterson I don’t suppose you could offer any insight? |
Hey @tmilnthorp! 👋 Yes, I might be able to help a bit.
IL2CPP will split the generated code across multiple translation units (.cpp files), even within one managed assembly. Still, it is possible that something is too large for the C++ compiler for Android. We see a number of issues like this with the Android NDK tools specifically. In Unity 2022.1 and later we have an IL2CPP Code Generation option available in the Player Settings that will allow you to tell IL2CPP to favor smaller executable code size. That might help - it really varies per project though. Sorry that I can't provide a more definitive answer. |
Thanks a lot for chiming in @joshpeterson , I guess the Unity option is something to try then @terjew . |
Hey @joshpeterson! 👋 Thanks for the info. @terjew I wonder if #1018 would magically fix this issue also? 🤞 |
@terjew Nuget should be out shortly, would you mind giving it a try and report back? |
@angularsen @tmilnthorp I'll try to find time to test it tomorrow, will report back. |
@angularsen @tmilnthorp I just finished testing now. With the version I originally used (4.110.0) I still get the out of memory error from clang. When updating to the latest nuget version (4.116.0) the compilation finishes without errors. It seems the latest fixes solved this issue 👍 |
Great news! I had a nagging feeling that method size was related. Glad it works. @joshpeterson FYI fixed with #1018 |
Great! 🎉 |
Describe the bug
When using the library in Unity3D and compiling the Unity3D project for android 64-bit using IL2CPP, the clang compiler exits with an out of memory error, after consuming around 30GB virtual memory.
To Reproduce
Steps to reproduce the behavior (just an example):
Expected behavior
The unity project should build without errors.
Additional context
I believe the sheer amount of types and methods in the project might be causing the problem, especially if IL2CPP places everything in a single compile unit. Maybe an effort to split up the library by categories, measurement systems or similar as discussed in #372 could help.
The text was updated successfully, but these errors were encountered: