Ported: Disable threads used to check on plugins to load

The functionality is unavailable on Android (requires export capability) and unnecessarily consumes resources
- m4gr3d
3ac6b6a596
This commit is contained in:
Relintai 2022-08-19 02:37:43 +02:00
parent 54c49a25a0
commit 6821dfb26e
3 changed files with 28 additions and 9 deletions

View File

@ -229,6 +229,7 @@ static const int DEFAULT_MIN_SDK_VERSION = 19; // Should match the value in 'pla
static const int DEFAULT_TARGET_SDK_VERSION = 32; // Should match the value in 'platform/android/java/app/config.gradle#targetSdk'
const String SDK_VERSION_RANGE = vformat("%s,%s,1", DEFAULT_MIN_SDK_VERSION, DEFAULT_TARGET_SDK_VERSION);
#ifndef ANDROID_ENABLED
void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) {
EditorExportPlatformAndroid *ea = (EditorExportPlatformAndroid *)ud;
@ -260,7 +261,6 @@ void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) {
}
}
#ifndef ANDROID_ENABLED
// Check for devices updates
String adb = get_adb_path();
if (FileAccess::exists(adb)) {
@ -374,7 +374,6 @@ void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) {
ea->device_lock.unlock();
}
#endif
uint64_t sleep = 300'000;
uint64_t wait = 3'000'000;
@ -387,7 +386,6 @@ void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) {
}
}
#ifndef ANDROID_ENABLED
if (EditorSettings::get_singleton()->get("export/android/shutdown_adb_on_exit")) {
String adb = get_adb_path();
if (!FileAccess::exists(adb)) {
@ -398,8 +396,8 @@ void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) {
args.push_back("kill-server");
OS::get_singleton()->execute(adb, args, true);
}
#endif
}
#endif
String EditorExportPlatformAndroid::get_project_name(const String &p_name) const {
String aname;
@ -3302,10 +3300,14 @@ EditorExportPlatformAndroid::EditorExportPlatformAndroid() {
devices_changed.set();
plugins_changed.set();
#ifndef ANDROID_ENABLED
check_for_changes_thread.start(_check_for_changes_poll_thread, this);
#endif
}
EditorExportPlatformAndroid::~EditorExportPlatformAndroid() {
#ifndef ANDROID_ENABLED
quit_request.set();
check_for_changes_thread.wait_to_finish();
#endif
}

View File

@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "core/config/project_settings.h"
#include "core/io/image_loader.h"
#include "core/io/json.h"
#include "core/io/marshalls.h"
@ -35,7 +36,6 @@
#include "core/os/dir_access.h"
#include "core/os/file_access.h"
#include "core/os/os.h"
#include "core/config/project_settings.h"
#include "core/os/safe_refcount.h"
#include "core/version.h"
#include "drivers/png/png_driver_common.h"
@ -95,10 +95,13 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
Vector<Device> devices;
SafeFlag devices_changed;
Mutex device_lock;
#ifndef ANDROID_ENABLED
Thread check_for_changes_thread;
SafeFlag quit_request;
static void _check_for_changes_poll_thread(void *ud);
#endif
String get_project_name(const String &p_name) const;

View File

@ -29,13 +29,13 @@
/*************************************************************************/
#include "export.h"
#include "core/config/project_settings.h"
#include "core/io/image_loader.h"
#include "core/io/marshalls.h"
#include "core/io/resource_saver.h"
#include "core/io/zip_io.h"
#include "core/os/file_access.h"
#include "core/os/os.h"
#include "core/config/project_settings.h"
#include "core/os/safe_refcount.h"
#include "core/version.h"
#include "editor/editor_export.h"
@ -57,8 +57,10 @@ class EditorExportPlatformIOS : public EditorExportPlatform {
// Plugins
SafeFlag plugins_changed;
#ifndef ANDROID_ENABLED
Thread check_for_changes_thread;
SafeFlag quit_request;
#endif
Mutex plugins_lock;
Vector<PluginConfigIOS> plugins;
@ -141,6 +143,7 @@ class EditorExportPlatformIOS : public EditorExportPlatform {
return true;
}
#ifndef ANDROID_ENABLED
static void _check_for_changes_poll_thread(void *ud) {
EditorExportPlatformIOS *ea = (EditorExportPlatformIOS *)ud;
@ -176,15 +179,22 @@ class EditorExportPlatformIOS : public EditorExportPlatform {
}
}
}
#endif
protected:
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features);
virtual void get_export_options(List<ExportOption> *r_options);
public:
virtual String get_name() const { return "iOS"; }
virtual String get_os_name() const { return "iOS"; }
virtual Ref<Texture> get_logo() const { return logo; }
virtual String get_name() const {
return "iOS";
}
virtual String get_os_name() const {
return "iOS";
}
virtual Ref<Texture> get_logo() const {
return logo;
}
virtual bool should_update_export_options() {
bool export_options_changed = plugins_changed.is_set();
@ -2126,12 +2136,16 @@ EditorExportPlatformIOS::EditorExportPlatformIOS() {
plugins_changed.set();
#ifndef ANDROID_ENABLED
check_for_changes_thread.start(_check_for_changes_poll_thread, this);
#endif
}
EditorExportPlatformIOS::~EditorExportPlatformIOS() {
#ifndef ANDROID_ENABLED
quit_request.set();
check_for_changes_thread.wait_to_finish();
#endif
}
void register_iphone_exporter() {