godot icon indicating copy to clipboard operation
godot copied to clipboard

ProjectSetting.save_custom("user:://override.cfg") with android plugin will cause USER ERROR: Cannot get class 'JNISingleton'.

Open AllenDang opened this issue 1 year ago • 3 comments
trafficstars

Tested versions

4.3 stable

System information

Android

Issue description

I'm trying to set game resolution at runtime, save it via ProjectSetting.save_custom and read it back. And I find no matter how I change the ProjectSetting, when I get the resolution, the value remains as initial.

So I tried to print the content of override.cfg, the new resolution is set, but accidentally, I noticed there is an error popup which might break the loading of override.cfg.

Here is the steps I did.

Add an android plugin to project, set Application/Config/ProjectSettingsOverride to "user://override.cfg", and invoke ProjectSetting.save_custom("user://override.cfg"). Following setction will be added to the top of override.cfg

config_version=5
AndroidPlugin=Object(JNISingleton,"script":null)

And error occurred states

USER ERROR: Cannot get class 'JNISingleton'.
    at: _instantiate_internal (core/object/class_db.cpp:515)
USER ERROR: Error parsing user://override.cfg at line 10: Can't instantiate Object() of type: JNISingleton File might be corrupted.
    at: _load_settings_text (core/config/project_settings.cpp:777)

Steps to reproduce

  1. open the MRP project
  2. install android build template.
  3. plug android phone
  4. one click deploy the game to android
  5. click Set High Res button
  6. quit and kill game
  7. restart the game
  8. see the log from logcat

Minimal reproduction project (MRP)

repo97546.zip

AllenDang avatar Sep 27 '24 15:09 AllenDang

Any response to this issue? or do I have to provide more info or something? This issue blocks our game to use custom project setting to adjust resolution and render quality stuff.

AllenDang avatar Oct 11 '24 08:10 AllenDang

@AllenDang I cannot reproduce this issue, i have tried with both v1 and v2 plugin.

syntaxerror247 avatar Oct 12 '24 04:10 syntaxerror247

@syntaxerror247 I've managed to create a MRP to repo this issue, see attached.

repo97546.zip

Steps to repo:

  1. open the project
  2. install android build template.
  3. plug android phone
  4. one click deploy the game to andoird
  5. click Set High Res
  6. quit and kill game
  7. restart the game
  8. see the log from logcat

The error message will popup says

USER ERROR: Cannot get class 'JNISingleton'.
 at: _instantiate_internal (core/object/class_db.cpp:515)
USER ERROR: Error parsing user://override.cfg at line 10: Can't instantiate Object() of type: JNISingleton File might be 
 at: _load_settings_text (core/config/project_settings.cpp:777)

AllenDang avatar Oct 21 '24 13:10 AllenDang

any update on this?

AllenDang avatar Oct 23 '24 06:10 AllenDang

I can now reproduce this in version 4.3, but it doesn't occur in the master branch. There were some recent updates related to JNISingleton, and it seems the issue has already been fixed. You can check 4.4 dev3 release. CC @m4gr3d @dsnopek

syntaxerror247 avatar Oct 23 '24 07:10 syntaxerror247

@AllenDang @syntaxerror247 This issue should have been resolved via https://github.com/godotengine/godot/pull/96624/files#diff-cad096f9d4cb422b6efe335ccb4384e14f7892e414e6517d939a61e0b698d980.

We may be able to backport the specific changes to godot_plugin_jni to the 4.3 release. Unless @AllenDang you're okay with waiting for the next 4.4 release (scheduled for early next year).

m4gr3d avatar Oct 24 '24 16:10 m4gr3d

@m4gr3d I can wait for the next 4.4 release, thanks :)

AllenDang avatar Oct 25 '24 02:10 AllenDang

Sounds good! In that case, I'll close this task as completed.

Please also give a try to the 4.4 dev releases to ensure your issue is fully resolved.

m4gr3d avatar Oct 25 '24 14:10 m4gr3d