summaryrefslogtreecommitdiffstats
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/api/api.cpp10
-rw-r--r--platform/android/api/java_class_wrapper.h13
-rw-r--r--platform/android/api/jni_singleton.h197
-rw-r--r--platform/android/export/export_plugin.cpp3
-rw-r--r--platform/android/java/app/build.gradle6
-rw-r--r--platform/android/java/app/config.gradle5
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/Godot.kt6
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/plugin/AndroidRuntimePlugin.kt63
-rw-r--r--platform/android/java_class_wrapper.cpp10
-rw-r--r--platform/android/java_godot_lib_jni.cpp4
-rw-r--r--platform/android/plugin/godot_plugin_jni.cpp25
-rw-r--r--platform/android/rendering_context_driver_vulkan_android.cpp6
-rw-r--r--platform/ios/display_server_ios.h6
-rw-r--r--platform/ios/os_ios.mm6
-rw-r--r--platform/linuxbsd/wayland/rendering_context_driver_vulkan_wayland.cpp6
-rw-r--r--platform/linuxbsd/x11/rendering_context_driver_vulkan_x11.cpp6
-rw-r--r--platform/macos/detect.py8
-rw-r--r--platform/web/export/export_plugin.cpp8
-rw-r--r--platform/web/js/libs/library_godot_audio.js38
-rw-r--r--platform/windows/rendering_context_driver_vulkan_windows.cpp6
20 files changed, 185 insertions, 247 deletions
diff --git a/platform/android/api/api.cpp b/platform/android/api/api.cpp
index 6920f801e5..078b9ab748 100644
--- a/platform/android/api/api.cpp
+++ b/platform/android/api/api.cpp
@@ -41,13 +41,11 @@ static JavaClassWrapper *java_class_wrapper = nullptr;
void register_android_api() {
#if !defined(ANDROID_ENABLED)
- // On Android platforms, the `java_class_wrapper` instantiation and the
- // `JNISingleton` registration occurs in
+ // On Android platforms, the `java_class_wrapper` instantiation occurs in
// `platform/android/java_godot_lib_jni.cpp#Java_org_godotengine_godot_GodotLib_setup`
- java_class_wrapper = memnew(JavaClassWrapper); // Dummy
- GDREGISTER_CLASS(JNISingleton);
+ java_class_wrapper = memnew(JavaClassWrapper);
#endif
-
+ GDREGISTER_CLASS(JNISingleton);
GDREGISTER_CLASS(JavaClass);
GDREGISTER_CLASS(JavaObject);
GDREGISTER_CLASS(JavaClassWrapper);
@@ -108,7 +106,7 @@ Ref<JavaClass> JavaObject::get_java_class() const {
JavaClassWrapper *JavaClassWrapper::singleton = nullptr;
-Ref<JavaClass> JavaClassWrapper::wrap(const String &) {
+Ref<JavaClass> JavaClassWrapper::_wrap(const String &, bool) {
return Ref<JavaClass>();
}
diff --git a/platform/android/api/java_class_wrapper.h b/platform/android/api/java_class_wrapper.h
index 71f9c32318..c74cef8dd0 100644
--- a/platform/android/api/java_class_wrapper.h
+++ b/platform/android/api/java_class_wrapper.h
@@ -262,6 +262,8 @@ class JavaClassWrapper : public Object {
bool _get_type_sig(JNIEnv *env, jobject obj, uint32_t &sig, String &strsig);
#endif
+ Ref<JavaClass> _wrap(const String &p_class, bool p_allow_private_methods_access);
+
static JavaClassWrapper *singleton;
protected:
@@ -270,15 +272,14 @@ protected:
public:
static JavaClassWrapper *get_singleton() { return singleton; }
- Ref<JavaClass> wrap(const String &p_class);
+ Ref<JavaClass> wrap(const String &p_class) {
+ return _wrap(p_class, false);
+ }
#ifdef ANDROID_ENABLED
- Ref<JavaClass> wrap_jclass(jclass p_class);
-
- JavaClassWrapper(jobject p_activity = nullptr);
-#else
- JavaClassWrapper();
+ Ref<JavaClass> wrap_jclass(jclass p_class, bool p_allow_private_methods_access = false);
#endif
+ JavaClassWrapper();
};
#endif // JAVA_CLASS_WRAPPER_H
diff --git a/platform/android/api/jni_singleton.h b/platform/android/api/jni_singleton.h
index 06afc4eb78..5e940819bc 100644
--- a/platform/android/api/jni_singleton.h
+++ b/platform/android/api/jni_singleton.h
@@ -31,193 +31,53 @@
#ifndef JNI_SINGLETON_H
#define JNI_SINGLETON_H
+#include "java_class_wrapper.h"
+
#include "core/config/engine.h"
#include "core/variant/variant.h"
-#ifdef ANDROID_ENABLED
-#include "jni_utils.h"
-#endif
-
class JNISingleton : public Object {
GDCLASS(JNISingleton, Object);
-#ifdef ANDROID_ENABLED
struct MethodData {
- jmethodID method;
Variant::Type ret_type;
Vector<Variant::Type> argtypes;
};
- jobject instance;
RBMap<StringName, MethodData> method_map;
-#endif
+ Ref<JavaObject> wrapped_object;
public:
virtual Variant callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) override {
-#ifdef ANDROID_ENABLED
- RBMap<StringName, MethodData>::Element *E = method_map.find(p_method);
-
- // Check the method we're looking for is in the JNISingleton map and that
- // the arguments match.
- bool call_error = !E || E->get().argtypes.size() != p_argcount;
- if (!call_error) {
- for (int i = 0; i < p_argcount; i++) {
- if (!Variant::can_convert(p_args[i]->get_type(), E->get().argtypes[i])) {
- call_error = true;
- break;
+ if (wrapped_object.is_valid()) {
+ RBMap<StringName, MethodData>::Element *E = method_map.find(p_method);
+
+ // Check the method we're looking for is in the JNISingleton map and that
+ // the arguments match.
+ bool call_error = !E || E->get().argtypes.size() != p_argcount;
+ if (!call_error) {
+ for (int i = 0; i < p_argcount; i++) {
+ if (!Variant::can_convert(p_args[i]->get_type(), E->get().argtypes[i])) {
+ call_error = true;
+ break;
+ }
}
}
- }
-
- if (call_error) {
- // The method is not in this map, defaulting to the regular instance calls.
- return Object::callp(p_method, p_args, p_argcount, r_error);
- }
-
- ERR_FAIL_NULL_V(instance, Variant());
-
- r_error.error = Callable::CallError::CALL_OK;
-
- jvalue *v = nullptr;
- if (p_argcount) {
- v = (jvalue *)alloca(sizeof(jvalue) * p_argcount);
- }
-
- JNIEnv *env = get_jni_env();
-
- int res = env->PushLocalFrame(16);
-
- ERR_FAIL_COND_V(res != 0, Variant());
-
- List<jobject> to_erase;
- for (int i = 0; i < p_argcount; i++) {
- jvalret vr = _variant_to_jvalue(env, E->get().argtypes[i], p_args[i]);
- v[i] = vr.val;
- if (vr.obj) {
- to_erase.push_back(vr.obj);
+ if (!call_error) {
+ return wrapped_object->callp(p_method, p_args, p_argcount, r_error);
}
}
- Variant ret;
-
- switch (E->get().ret_type) {
- case Variant::NIL: {
- env->CallVoidMethodA(instance, E->get().method, v);
- } break;
- case Variant::BOOL: {
- ret = env->CallBooleanMethodA(instance, E->get().method, v) == JNI_TRUE;
- } break;
- case Variant::INT: {
- ret = env->CallIntMethodA(instance, E->get().method, v);
- } break;
- case Variant::FLOAT: {
- ret = env->CallFloatMethodA(instance, E->get().method, v);
- } break;
- case Variant::STRING: {
- jobject o = env->CallObjectMethodA(instance, E->get().method, v);
- ret = jstring_to_string((jstring)o, env);
- env->DeleteLocalRef(o);
- } break;
- case Variant::PACKED_STRING_ARRAY: {
- jobjectArray arr = (jobjectArray)env->CallObjectMethodA(instance, E->get().method, v);
-
- ret = _jobject_to_variant(env, arr);
-
- env->DeleteLocalRef(arr);
- } break;
- case Variant::PACKED_INT32_ARRAY: {
- jintArray arr = (jintArray)env->CallObjectMethodA(instance, E->get().method, v);
-
- int fCount = env->GetArrayLength(arr);
- Vector<int> sarr;
- sarr.resize(fCount);
-
- int *w = sarr.ptrw();
- env->GetIntArrayRegion(arr, 0, fCount, w);
- ret = sarr;
- env->DeleteLocalRef(arr);
- } break;
- case Variant::PACKED_INT64_ARRAY: {
- jlongArray arr = (jlongArray)env->CallObjectMethodA(instance, E->get().method, v);
-
- int fCount = env->GetArrayLength(arr);
- Vector<int64_t> sarr;
- sarr.resize(fCount);
-
- int64_t *w = sarr.ptrw();
- env->GetLongArrayRegion(arr, 0, fCount, w);
- ret = sarr;
- env->DeleteLocalRef(arr);
- } break;
- case Variant::PACKED_FLOAT32_ARRAY: {
- jfloatArray arr = (jfloatArray)env->CallObjectMethodA(instance, E->get().method, v);
-
- int fCount = env->GetArrayLength(arr);
- Vector<float> sarr;
- sarr.resize(fCount);
-
- float *w = sarr.ptrw();
- env->GetFloatArrayRegion(arr, 0, fCount, w);
- ret = sarr;
- env->DeleteLocalRef(arr);
- } break;
- case Variant::PACKED_FLOAT64_ARRAY: {
- jdoubleArray arr = (jdoubleArray)env->CallObjectMethodA(instance, E->get().method, v);
-
- int fCount = env->GetArrayLength(arr);
- Vector<double> sarr;
- sarr.resize(fCount);
-
- double *w = sarr.ptrw();
- env->GetDoubleArrayRegion(arr, 0, fCount, w);
- ret = sarr;
- env->DeleteLocalRef(arr);
- } break;
- case Variant::DICTIONARY: {
- jobject obj = env->CallObjectMethodA(instance, E->get().method, v);
- ret = _jobject_to_variant(env, obj);
- env->DeleteLocalRef(obj);
-
- } break;
- case Variant::OBJECT: {
- jobject obj = env->CallObjectMethodA(instance, E->get().method, v);
- ret = _jobject_to_variant(env, obj);
- env->DeleteLocalRef(obj);
- } break;
- default: {
- env->PopLocalFrame(nullptr);
- ERR_FAIL_V(Variant());
- } break;
- }
-
- while (to_erase.size()) {
- env->DeleteLocalRef(to_erase.front()->get());
- to_erase.pop_front();
- }
-
- env->PopLocalFrame(nullptr);
-
- return ret;
-#else // ANDROID_ENABLED
-
- // Defaulting to the regular instance calls.
return Object::callp(p_method, p_args, p_argcount, r_error);
-#endif
}
-#ifdef ANDROID_ENABLED
- jobject get_instance() const {
- return instance;
+ Ref<JavaObject> get_wrapped_object() const {
+ return wrapped_object;
}
- void set_instance(jobject p_instance) {
- instance = p_instance;
- }
-
- void add_method(const StringName &p_name, jmethodID p_method, const Vector<Variant::Type> &p_args, Variant::Type p_ret_type) {
+ void add_method(const StringName &p_name, const Vector<Variant::Type> &p_args, Variant::Type p_ret_type) {
MethodData md;
- md.method = p_method;
md.argtypes = p_args;
md.ret_type = p_ret_type;
method_map[p_name] = md;
@@ -232,24 +92,15 @@ public:
ADD_SIGNAL(mi);
}
-#endif
+ JNISingleton() {}
- JNISingleton() {
-#ifdef ANDROID_ENABLED
- instance = nullptr;
-#endif
+ JNISingleton(const Ref<JavaObject> &p_wrapped_object) {
+ wrapped_object = p_wrapped_object;
}
~JNISingleton() {
-#ifdef ANDROID_ENABLED
method_map.clear();
- if (instance) {
- JNIEnv *env = get_jni_env();
- ERR_FAIL_NULL(env);
-
- env->DeleteGlobalRef(instance);
- }
-#endif
+ wrapped_object.unref();
}
};
diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp
index cfd258cddc..41f460ca8f 100644
--- a/platform/android/export/export_plugin.cpp
+++ b/platform/android/export/export_plugin.cpp
@@ -3263,8 +3263,11 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
cmdline.push_back(apk_build_command);
}
+ String addons_directory = ProjectSettings::get_singleton()->globalize_path("res://addons");
+
cmdline.push_back("-p"); // argument to specify the start directory.
cmdline.push_back(build_path); // start directory.
+ cmdline.push_back("-Paddons_directory=" + addons_directory); // path to the addon directory as it may contain jar or aar dependencies
cmdline.push_back("-Pexport_package_name=" + package_name); // argument to specify the package name.
cmdline.push_back("-Pexport_version_code=" + version_code); // argument to specify the version code.
cmdline.push_back("-Pexport_version_name=" + version_name); // argument to specify the version name.
diff --git a/platform/android/java/app/build.gradle b/platform/android/java/app/build.gradle
index fdc5753798..308f126d5d 100644
--- a/platform/android/java/app/build.gradle
+++ b/platform/android/java/app/build.gradle
@@ -63,6 +63,12 @@ dependencies {
implementation files(pluginsBinaries)
}
+ // Automatically pick up local dependencies in res://addons
+ String addonsDirectory = getAddonsDirectory()
+ if (addonsDirectory != null && !addonsDirectory.isBlank()) {
+ implementation fileTree(dir: "$addonsDirectory", include: ['*.jar', '*.aar'])
+ }
+
// .NET dependencies
String jar = '../../../../modules/mono/thirdparty/libSystem.Security.Cryptography.Native.Android.jar'
if (file(jar).exists()) {
diff --git a/platform/android/java/app/config.gradle b/platform/android/java/app/config.gradle
index 597a4d5c14..e8921e1bb1 100644
--- a/platform/android/java/app/config.gradle
+++ b/platform/android/java/app/config.gradle
@@ -408,3 +408,8 @@ ext.shouldUseLegacyPackaging = { ->
// Default behavior for minSdk >= 23
return false
}
+
+ext.getAddonsDirectory = { ->
+ String addonsDirectory = project.hasProperty("addons_directory") ? project.property("addons_directory") : ""
+ return addonsDirectory
+}
diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt
index 5b1d09e749..567b134234 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt
+++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt
@@ -58,6 +58,8 @@ import org.godotengine.godot.input.GodotEditText
import org.godotengine.godot.input.GodotInputHandler
import org.godotengine.godot.io.directory.DirectoryAccessHandler
import org.godotengine.godot.io.file.FileAccessHandler
+import org.godotengine.godot.plugin.AndroidRuntimePlugin
+import org.godotengine.godot.plugin.GodotPlugin
import org.godotengine.godot.plugin.GodotPluginRegistry
import org.godotengine.godot.tts.GodotTTS
import org.godotengine.godot.utils.CommandLineFileParser
@@ -228,7 +230,9 @@ class Godot(private val context: Context) {
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
Log.v(TAG, "Initializing Godot plugin registry")
- GodotPluginRegistry.initializePluginRegistry(this, primaryHost.getHostPlugins(this))
+ val runtimePlugins = mutableSetOf<GodotPlugin>(AndroidRuntimePlugin(this))
+ runtimePlugins.addAll(primaryHost.getHostPlugins(this))
+ GodotPluginRegistry.initializePluginRegistry(this, runtimePlugins)
if (io == null) {
io = GodotIO(activity)
}
diff --git a/platform/android/java/lib/src/org/godotengine/godot/plugin/AndroidRuntimePlugin.kt b/platform/android/java/lib/src/org/godotengine/godot/plugin/AndroidRuntimePlugin.kt
new file mode 100644
index 0000000000..edb4e7c357
--- /dev/null
+++ b/platform/android/java/lib/src/org/godotengine/godot/plugin/AndroidRuntimePlugin.kt
@@ -0,0 +1,63 @@
+/**************************************************************************/
+/* AndroidRuntimePlugin.kt */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+package org.godotengine.godot.plugin
+
+import org.godotengine.godot.Godot
+
+/**
+ * Provides access to the Android runtime capabilities.
+ *
+ * For example, from gdscript, developers can use [getApplicationContext] to access system services
+ * and check if the device supports vibration.
+ *
+ * var android_runtime = Engine.get_singleton("AndroidRuntime")
+ * if android_runtime:
+ * print("Checking if the device supports vibration")
+ * var vibrator_service = android_runtime.getApplicationContext().getSystemService("vibrator")
+ * if vibrator_service:
+ * if vibrator_service.hasVibrator():
+ * print("Vibration is supported on device!")
+ * else:
+ * printerr("Vibration is not supported on device")
+ * else:
+ * printerr("Unable to retrieve the vibrator service")
+ * else:
+ * printerr("Couldn't find AndroidRuntime singleton")
+ */
+class AndroidRuntimePlugin(godot: Godot) : GodotPlugin(godot) {
+ override fun getPluginName() = "AndroidRuntime"
+
+ @UsedByGodot
+ fun getApplicationContext() = activity?.applicationContext
+
+ @UsedByGodot
+ override fun getActivity() = super.getActivity()
+}
diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp
index c92717e922..6bedbfd157 100644
--- a/platform/android/java_class_wrapper.cpp
+++ b/platform/android/java_class_wrapper.cpp
@@ -1120,7 +1120,7 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
return false;
}
-Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
+Ref<JavaClass> JavaClassWrapper::_wrap(const String &p_class, bool p_allow_private_methods_access) {
String class_name_dots = p_class.replace("/", ".");
if (class_cache.has(class_name_dots)) {
return class_cache[class_name_dots];
@@ -1175,7 +1175,7 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
jint mods = env->CallIntMethod(obj, is_constructor ? Constructor_getModifiers : Method_getModifiers);
- if (!(mods & 0x0001)) {
+ if (!(mods & 0x0001) && (is_constructor || !p_allow_private_methods_access)) {
env->DeleteLocalRef(obj);
continue; //not public bye
}
@@ -1336,7 +1336,7 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
return java_class;
}
-Ref<JavaClass> JavaClassWrapper::wrap_jclass(jclass p_class) {
+Ref<JavaClass> JavaClassWrapper::wrap_jclass(jclass p_class, bool p_allow_private_methods_access) {
JNIEnv *env = get_jni_env();
ERR_FAIL_NULL_V(env, Ref<JavaClass>());
@@ -1344,12 +1344,12 @@ Ref<JavaClass> JavaClassWrapper::wrap_jclass(jclass p_class) {
String class_name_string = jstring_to_string(class_name, env);
env->DeleteLocalRef(class_name);
- return wrap(class_name_string);
+ return _wrap(class_name_string, p_allow_private_methods_access);
}
JavaClassWrapper *JavaClassWrapper::singleton = nullptr;
-JavaClassWrapper::JavaClassWrapper(jobject p_activity) {
+JavaClassWrapper::JavaClassWrapper() {
singleton = this;
JNIEnv *env = get_jni_env();
diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp
index 6086f67a1e..1a256959cd 100644
--- a/platform/android/java_godot_lib_jni.cpp
+++ b/platform/android/java_godot_lib_jni.cpp
@@ -32,7 +32,6 @@
#include "android_input_handler.h"
#include "api/java_class_wrapper.h"
-#include "api/jni_singleton.h"
#include "dir_access_jandroid.h"
#include "display_server_android.h"
#include "file_access_android.h"
@@ -209,8 +208,7 @@ JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env
TTS_Android::setup(p_godot_tts);
- java_class_wrapper = memnew(JavaClassWrapper(godot_java->get_activity()));
- GDREGISTER_CLASS(JNISingleton);
+ java_class_wrapper = memnew(JavaClassWrapper);
return true;
}
diff --git a/platform/android/plugin/godot_plugin_jni.cpp b/platform/android/plugin/godot_plugin_jni.cpp
index 75c8dd9528..acb18cc5c5 100644
--- a/platform/android/plugin/godot_plugin_jni.cpp
+++ b/platform/android/plugin/godot_plugin_jni.cpp
@@ -30,6 +30,7 @@
#include "godot_plugin_jni.h"
+#include "api/java_class_wrapper.h"
#include "api/jni_singleton.h"
#include "jni_utils.h"
#include "string_android.h"
@@ -57,11 +58,15 @@ JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeR
ERR_FAIL_COND_V(jni_singletons.has(singname), false);
- JNISingleton *s = (JNISingleton *)ClassDB::instantiate("JNISingleton");
- s->set_instance(env->NewGlobalRef(obj));
- jni_singletons[singname] = s;
+ jclass java_class = env->GetObjectClass(obj);
+ Ref<JavaClass> java_class_wrapped = JavaClassWrapper::get_singleton()->wrap_jclass(java_class, true);
+ env->DeleteLocalRef(java_class);
- Engine::get_singleton()->add_singleton(Engine::Singleton(singname, s));
+ Ref<JavaObject> plugin_object = memnew(JavaObject(java_class_wrapped, obj));
+ JNISingleton *plugin_singleton = memnew(JNISingleton(plugin_object));
+ jni_singletons[singname] = plugin_singleton;
+
+ Engine::get_singleton()->add_singleton(Engine::Singleton(singname, plugin_singleton));
return true;
}
@@ -75,7 +80,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeRegis
String mname = jstring_to_string(name, env);
String retval = jstring_to_string(ret, env);
Vector<Variant::Type> types;
- String cs = "(";
int stringCount = env->GetArrayLength(args);
@@ -83,18 +87,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeRegis
jstring string = (jstring)env->GetObjectArrayElement(args, i);
const String rawString = jstring_to_string(string, env);
types.push_back(get_jni_type(rawString));
- cs += get_jni_sig(rawString);
- }
-
- cs += ")";
- cs += get_jni_sig(retval);
- jclass cls = env->GetObjectClass(s->get_instance());
- jmethodID mid = env->GetMethodID(cls, mname.ascii().get_data(), cs.ascii().get_data());
- if (!mid) {
- print_line("Failed getting method ID " + mname);
}
- s->add_method(mname, mid, types, get_jni_type(retval));
+ s->add_method(mname, types, get_jni_type(retval));
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeRegisterSignal(JNIEnv *env, jclass clazz, jstring j_plugin_name, jstring j_signal_name, jobjectArray j_signal_param_types) {
diff --git a/platform/android/rendering_context_driver_vulkan_android.cpp b/platform/android/rendering_context_driver_vulkan_android.cpp
index a306a121f8..51fb1ca18f 100644
--- a/platform/android/rendering_context_driver_vulkan_android.cpp
+++ b/platform/android/rendering_context_driver_vulkan_android.cpp
@@ -32,11 +32,7 @@
#ifdef VULKAN_ENABLED
-#ifdef USE_VOLK
-#include <volk.h>
-#else
-#include <vulkan/vulkan.h>
-#endif
+#include "drivers/vulkan/godot_vulkan.h"
const char *RenderingContextDriverVulkanAndroid::_get_platform_surface_extension() const {
return VK_KHR_ANDROID_SURFACE_EXTENSION_NAME;
diff --git a/platform/ios/display_server_ios.h b/platform/ios/display_server_ios.h
index bbb758074d..0631b50f0a 100644
--- a/platform/ios/display_server_ios.h
+++ b/platform/ios/display_server_ios.h
@@ -41,11 +41,7 @@
#if defined(VULKAN_ENABLED)
#import "rendering_context_driver_vulkan_ios.h"
-#ifdef USE_VOLK
-#include <volk.h>
-#else
-#include <vulkan/vulkan.h>
-#endif
+#include "drivers/vulkan/godot_vulkan.h"
#endif // VULKAN_ENABLED
#if defined(METAL_ENABLED)
diff --git a/platform/ios/os_ios.mm b/platform/ios/os_ios.mm
index 35b87ea647..590238be77 100644
--- a/platform/ios/os_ios.mm
+++ b/platform/ios/os_ios.mm
@@ -56,11 +56,7 @@
#import <QuartzCore/CAMetalLayer.h>
#if defined(VULKAN_ENABLED)
-#ifdef USE_VOLK
-#include <volk.h>
-#else
-#include <vulkan/vulkan.h>
-#endif
+#include "drivers/vulkan/godot_vulkan.h"
#endif // VULKAN_ENABLED
#endif
diff --git a/platform/linuxbsd/wayland/rendering_context_driver_vulkan_wayland.cpp b/platform/linuxbsd/wayland/rendering_context_driver_vulkan_wayland.cpp
index 0417ba95eb..8abcc464ba 100644
--- a/platform/linuxbsd/wayland/rendering_context_driver_vulkan_wayland.cpp
+++ b/platform/linuxbsd/wayland/rendering_context_driver_vulkan_wayland.cpp
@@ -32,11 +32,7 @@
#include "rendering_context_driver_vulkan_wayland.h"
-#ifdef USE_VOLK
-#include <volk.h>
-#else
-#include <vulkan/vulkan.h>
-#endif
+#include "drivers/vulkan/godot_vulkan.h"
const char *RenderingContextDriverVulkanWayland::_get_platform_surface_extension() const {
return VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME;
diff --git a/platform/linuxbsd/x11/rendering_context_driver_vulkan_x11.cpp b/platform/linuxbsd/x11/rendering_context_driver_vulkan_x11.cpp
index 3f505d000c..cbcf07852b 100644
--- a/platform/linuxbsd/x11/rendering_context_driver_vulkan_x11.cpp
+++ b/platform/linuxbsd/x11/rendering_context_driver_vulkan_x11.cpp
@@ -32,11 +32,7 @@
#include "rendering_context_driver_vulkan_x11.h"
-#ifdef USE_VOLK
-#include <volk.h>
-#else
-#include <vulkan/vulkan.h>
-#endif
+#include "drivers/vulkan/godot_vulkan.h"
const char *RenderingContextDriverVulkanX11::_get_platform_surface_extension() const {
return VK_KHR_XLIB_SURFACE_EXTENSION_NAME;
diff --git a/platform/macos/detect.py b/platform/macos/detect.py
index e35423d41f..595a83ead3 100644
--- a/platform/macos/detect.py
+++ b/platform/macos/detect.py
@@ -8,6 +8,10 @@ from platform_methods import detect_arch, detect_mvk
if TYPE_CHECKING:
from SCons.Script.SConscript import SConsEnvironment
+# To match other platforms
+STACK_SIZE = 8388608
+STACK_SIZE_SANITIZERS = 30 * 1024 * 1024
+
def get_name():
return "macOS"
@@ -183,6 +187,10 @@ def configure(env: "SConsEnvironment"):
env.Append(CCFLAGS=["-fsanitize=thread"])
env.Append(LINKFLAGS=["-fsanitize=thread"])
+ env.Append(LINKFLAGS=["-Wl,-stack_size," + hex(STACK_SIZE_SANITIZERS)])
+ else:
+ env.Append(LINKFLAGS=["-Wl,-stack_size," + hex(STACK_SIZE)])
+
if env["use_coverage"]:
env.Append(CCFLAGS=["-ftest-coverage", "-fprofile-arcs"])
env.Append(LINKFLAGS=["-ftest-coverage", "-fprofile-arcs"])
diff --git a/platform/web/export/export_plugin.cpp b/platform/web/export/export_plugin.cpp
index 5faab74d7b..efe3c95496 100644
--- a/platform/web/export/export_plugin.cpp
+++ b/platform/web/export/export_plugin.cpp
@@ -214,6 +214,9 @@ Error EditorExportPlatformWeb::_add_manifest_icon(const String &p_path, const St
}
Error EditorExportPlatformWeb::_build_pwa(const Ref<EditorExportPreset> &p_preset, const String p_path, const Vector<SharedObject> &p_shared_objects) {
+ List<String> preset_features;
+ get_preset_features(p_preset, &preset_features);
+
String proj_name = GLOBAL_GET("application/config/name");
if (proj_name.is_empty()) {
proj_name = "Godot Game";
@@ -239,7 +242,10 @@ Error EditorExportPlatformWeb::_build_pwa(const Ref<EditorExportPreset> &p_prese
cache_files.push_back(name + ".icon.png");
cache_files.push_back(name + ".apple-touch-icon.png");
}
- cache_files.push_back(name + ".worker.js");
+
+ if (preset_features.find("threads")) {
+ cache_files.push_back(name + ".worker.js");
+ }
cache_files.push_back(name + ".audio.worklet.js");
cache_files.push_back(name + ".audio.position.worklet.js");
replaces["___GODOT_CACHE___"] = Variant(cache_files).to_json_string();
diff --git a/platform/web/js/libs/library_godot_audio.js b/platform/web/js/libs/library_godot_audio.js
index 40fb0c356c..aaf986b966 100644
--- a/platform/web/js/libs/library_godot_audio.js
+++ b/platform/web/js/libs/library_godot_audio.js
@@ -868,7 +868,10 @@ class Bus {
* @returns {void}
*/
static move(fromIndex, toIndex) {
- const movedBus = GodotAudio.Bus.getBus(fromIndex);
+ const movedBus = GodotAudio.Bus.getBusOrNull(fromIndex);
+ if (movedBus == null) {
+ return;
+ }
const buses = GodotAudio.buses.filter((_, i) => i !== fromIndex);
// Inserts at index.
buses.splice(toIndex - 1, 0, movedBus);
@@ -1424,7 +1427,10 @@ const _GodotAudio = {
* @returns {void}
*/
remove_sample_bus: function (index) {
- const bus = GodotAudio.Bus.getBus(index);
+ const bus = GodotAudio.Bus.getBusOrNull(index);
+ if (bus == null) {
+ return;
+ }
bus.clear();
},
@@ -1454,8 +1460,17 @@ const _GodotAudio = {
* @returns {void}
*/
set_sample_bus_send: function (busIndex, sendIndex) {
- const bus = GodotAudio.Bus.getBus(busIndex);
- bus.setSend(GodotAudio.Bus.getBus(sendIndex));
+ const bus = GodotAudio.Bus.getBusOrNull(busIndex);
+ if (bus == null) {
+ // Cannot send from an invalid bus.
+ return;
+ }
+ let targetBus = GodotAudio.Bus.getBusOrNull(sendIndex);
+ if (targetBus == null) {
+ // Send to master.
+ targetBus = GodotAudio.Bus.getBus(0);
+ }
+ bus.setSend(targetBus);
},
/**
@@ -1465,7 +1480,10 @@ const _GodotAudio = {
* @returns {void}
*/
set_sample_bus_volume_db: function (busIndex, volumeDb) {
- const bus = GodotAudio.Bus.getBus(busIndex);
+ const bus = GodotAudio.Bus.getBusOrNull(busIndex);
+ if (bus == null) {
+ return;
+ }
bus.setVolumeDb(volumeDb);
},
@@ -1476,7 +1494,10 @@ const _GodotAudio = {
* @returns {void}
*/
set_sample_bus_solo: function (busIndex, enable) {
- const bus = GodotAudio.Bus.getBus(busIndex);
+ const bus = GodotAudio.Bus.getBusOrNull(busIndex);
+ if (bus == null) {
+ return;
+ }
bus.solo(enable);
},
@@ -1487,7 +1508,10 @@ const _GodotAudio = {
* @returns {void}
*/
set_sample_bus_mute: function (busIndex, enable) {
- const bus = GodotAudio.Bus.getBus(busIndex);
+ const bus = GodotAudio.Bus.getBusOrNull(busIndex);
+ if (bus == null) {
+ return;
+ }
bus.mute(enable);
},
},
diff --git a/platform/windows/rendering_context_driver_vulkan_windows.cpp b/platform/windows/rendering_context_driver_vulkan_windows.cpp
index 445388af89..8ca677fe64 100644
--- a/platform/windows/rendering_context_driver_vulkan_windows.cpp
+++ b/platform/windows/rendering_context_driver_vulkan_windows.cpp
@@ -34,11 +34,7 @@
#include "rendering_context_driver_vulkan_windows.h"
-#ifdef USE_VOLK
-#include <volk.h>
-#else
-#include <vulkan/vulkan.h>
-#endif
+#include "drivers/vulkan/godot_vulkan.h"
const char *RenderingContextDriverVulkanWindows::_get_platform_surface_extension() const {
return VK_KHR_WIN32_SURFACE_EXTENSION_NAME;