|
Post by unitybuild on Jun 15, 2021 4:37:08 GMT
Hello. Does SimpleSQL work on Android when the following Player settings are used: - IL2CPP - .NET 4.x - ARM64 - ManagedStrippingLevel: Medium
My app works fine when ManagedStrippingLevel: Low, but if I switch to Medium, logcat shows errors like "table X doesn't have column Y".
|
|
|
Post by echo17 on Jun 15, 2021 18:37:10 GMT
I was able to reproduce what you are seeing. It doesn't appear to work with a Medium ManagedStrippingLevel. I'm not really familiar with Unity's Android stripping settings, but it looks like it is removing some component that is critical to communicating with the database file.
|
|
|
Post by unitybuild on Jun 16, 2021 15:58:12 GMT
Thank you for confirming that. Are you planning to fix it? Not a deal breaker for me, but it would be nice if Medium ManagedStrippingLevel worked. If not, maybe add a warning?
|
|
|
Post by echo17 on Jun 17, 2021 13:33:12 GMT
The stripping level is a Unity function, which I don't have control over. I'm not affiliated with the Unity development team, but they might be able to answer any questions you have.
|
|
|
Post by quietpixel on Apr 25, 2022 23:17:44 GMT
I found that Stripping Level was causing me problems in Windows x64 builds also. Switching the stripping level to LOW, MINIMAL or DISABLED fixed the problem.
I set up a simple class with all the variables I need to save in a database table. Using the Object Relational Mapping (ORM) feature of SimpleSQL, I used SimpleSQLManager to create a matching table and tried to insert rows into it. This worked fine in Unity Editor. But when built as an x64 EXE file, when trying to insert a record, the following error was thrown:
Get method not found for 'player_strength'
Running in development mode, and attaching Visual Studio to the running process, showed the error was occurring somewhere in SQLite.Insert (object obj, string extra, Type objType, out long rowID). The crash bubbled up from .Net's Reflection mechanism when it tried to find the variables in the class. Most likely in the GetMapping () function.
The variable it would complain about changed depending on the order of variables in the class, the attribute annotations attached to variables previous to it (such as MaxLength or AutoIncrement), and on how many lines of code were included in member functions in the class (NOTE: removing all constructors and member functions did not help). It almost seems like a byte alignment error, where .Net gets confused enumerating the class variables.
Looking at the SQL that SimpleSQL generates for the table create step, showed it was also skipping some variables and not putting columns for them in the table. For example, the auto-incrementing ID field was not being included. So, even if I got lucky moving variables around or changing the code length so that I avoided the "Get method" crash, the table was still not built correctly.
It seems Unity is stripping something important from SimpleSQL_Runtime.dll or from user classes in MEDIUM or higher modes. The DLL is 2,809 K bytes before stripping. At MEDIUM it drops to 2,803 K. It must be stripping something that .Net's Reflection mechanism needs to correctly enumerate variables in your class.
The moral of the story is, at least for Windows x64 builds, turn stripping down to LOW or less.
(Using Unity 2021.3.0f1 and current version of SimpleSQL)
|
|
|
Post by unitybuild on Apr 27, 2022 20:11:31 GMT
Is the stripping level accessible from C#? If so, it might be helpful if SimpleSQL could throw an exception with a relevant message. Something like "SimpleSQL requires the stripping level to be LOW or DISABLED".
|
|
|
Post by quietpixel on Apr 27, 2022 20:50:37 GMT
That might be possible. In the Editor there is a PlayerSettings class that let's you get the stripping level via:
PlayerSettings.GetManagedStrippingLevel (targetGroup);
The package could come with a post-processing script that would check this and issue a warning.
Another suggestion would be to call this out in the documentation somewhere.
|
|
|
Post by unitybuild on Apr 28, 2022 18:50:42 GMT
Yes, having spent hours to debug this, I'm surprised this limitation is still not reflected in the documentation.
|
|
|
Post by echo17 on Apr 29, 2022 13:17:06 GMT
Thanks for the info guys. I've added a FAQ here: linkI decided since this is a universal Unity setting that affects any plugin that relies on .NET functionality it is more fitting location than internal documentation or SimpleSQL specific docs.
|
|