Memory cleanup and optimizations

- Returns an empty list when there's not registered plugins, thus preventing the creation of spurious iterator objects

- Inline `Godot#getRotatedValues(...)` given it only had a single caller. This allows to remove the allocation of a float array on each call and replace it with float variables

- Disable sensor events by default. Sensor events can fired at 10-100s Hz taking cpu and memory resources. Now the use of sensor data is behind a project setting allowing projects that have use of it to enable it, while other projects don't pay the cost for a feature they don't use

- Create a pool of specialized input `Runnable` objects to prevent spurious, unbounded `Runnable` allocations

- Disable showing the boot logo for Android XR projects

- Delete locale references of jni strings
This commit is contained in:
Fredia Huya-Kouadio 2024-07-10 10:52:42 -07:00
parent 2f2d1a7e68
commit a57a99f5bc
14 changed files with 626 additions and 188 deletions

View file

@ -213,25 +213,27 @@ bool GodotJavaWrapper::has_get_clipboard() {
}
String GodotJavaWrapper::get_clipboard() {
String clipboard;
if (_get_clipboard) {
JNIEnv *env = get_jni_env();
ERR_FAIL_NULL_V(env, String());
jstring s = (jstring)env->CallObjectMethod(godot_instance, _get_clipboard);
return jstring_to_string(s, env);
} else {
return String();
clipboard = jstring_to_string(s, env);
env->DeleteLocalRef(s);
}
return clipboard;
}
String GodotJavaWrapper::get_input_fallback_mapping() {
String input_fallback_mapping;
if (_get_input_fallback_mapping) {
JNIEnv *env = get_jni_env();
ERR_FAIL_NULL_V(env, String());
jstring fallback_mapping = (jstring)env->CallObjectMethod(godot_instance, _get_input_fallback_mapping);
return jstring_to_string(fallback_mapping, env);
} else {
return String();
input_fallback_mapping = jstring_to_string(fallback_mapping, env);
env->DeleteLocalRef(fallback_mapping);
}
return input_fallback_mapping;
}
bool GodotJavaWrapper::has_set_clipboard() {
@ -324,14 +326,15 @@ Vector<String> GodotJavaWrapper::get_gdextension_list_config_file() const {
}
String GodotJavaWrapper::get_ca_certificates() const {
String ca_certificates;
if (_get_ca_certificates) {
JNIEnv *env = get_jni_env();
ERR_FAIL_NULL_V(env, String());
jstring s = (jstring)env->CallObjectMethod(godot_instance, _get_ca_certificates);
return jstring_to_string(s, env);
} else {
return String();
ca_certificates = jstring_to_string(s, env);
env->DeleteLocalRef(s);
}
return ca_certificates;
}
void GodotJavaWrapper::init_input_devices() {