From bf5d16e5f67389772590874765ac2e84ce723d7b Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sun, 2 Aug 2020 22:14:22 +0200 Subject: [PATCH] Always disable low-processor usage mode on mobile platforms This partially addresses https://github.com/godotengine/godot/issues/19304. --- doc/classes/ProjectSettings.xml | 3 ++- platform/android/os_android.cpp | 10 ++++++++++ platform/android/os_android.h | 2 ++ platform/iphone/os_iphone.h | 2 ++ platform/iphone/os_iphone.mm | 10 ++++++++++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index f13dbbae76d2..a4e464dbe026 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -227,7 +227,8 @@ Forces a delay between frames in the main loop (in milliseconds). This may be useful if you plan to disable vertical synchronization. - If [code]true[/code], enables low-processor usage mode. This setting only works on desktop platforms. The screen is not redrawn if nothing changes visually. This is meant for writing applications and editors, but is pretty useless (and can hurt performance) in most games. + If [code]true[/code], enables low-processor usage mode. The screen is not redrawn if nothing changes visually. This is meant for writing applications and editors, but is pretty useless (and can hurt performance) in most games. + [b]Note:[/b] This option won't have any effect on Android and iOS as it's not implemented yet on those platforms. Amount of sleeping between frames when the low-processor usage mode is enabled (in microseconds). Higher values will result in lower CPU usage. diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index baf6ee952a9c..f8c8b0408325 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -282,6 +282,16 @@ void OS_Android::vibrate_handheld(int p_duration_ms) { godot_java->vibrate(p_duration_ms); } +void OS_Android::set_low_processor_usage_mode(bool p_enabled) { + if (p_enabled) { + WARN_PRINT("Low-processor usage mode is not supported on Android and iOS."); + } +} + +bool OS_Android::is_in_low_processor_usage_mode() const { + return false; +} + bool OS_Android::_check_internal_feature_support(const String &p_feature) { if (p_feature == "mobile") { return true; diff --git a/platform/android/os_android.h b/platform/android/os_android.h index cac7efaa880a..277c76cc69c0 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -120,6 +120,8 @@ class OS_Android : public OS_Unix { virtual String get_system_dir(SystemDir p_dir) const; void vibrate_handheld(int p_duration_ms); + virtual void set_low_processor_usage_mode(bool p_enabled); + virtual bool is_in_low_processor_usage_mode() const; virtual bool _check_internal_feature_support(const String &p_feature); OS_Android(GodotJavaWrapper *p_godot_java, GodotIOJavaWrapper *p_godot_io_java, bool p_use_apk_expansion); diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h index f3bde46717a6..ee2bf093a5aa 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -125,6 +125,8 @@ class OSIPhone : public OS_Unix { virtual String get_unique_id() const override; virtual void vibrate_handheld(int p_duration_ms = 500) override; + virtual void set_low_processor_usage_mode(bool p_enabled); + virtual bool is_in_low_processor_usage_mode() const; virtual bool _check_internal_feature_support(const String &p_feature) override; diff --git a/platform/iphone/os_iphone.mm b/platform/iphone/os_iphone.mm index f0bbbd39caf9..422240f18cf1 100644 --- a/platform/iphone/os_iphone.mm +++ b/platform/iphone/os_iphone.mm @@ -326,6 +326,16 @@ void register_dynamic_symbol(char *name, void *address) { AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); } +void OSIPhone::set_low_processor_usage_mode(bool p_enabled) { + if (p_enabled) { + WARN_PRINT("Low-processor usage mode is not supported on Android and iOS."); + } +} + +bool OSIPhone::is_in_low_processor_usage_mode() const { + return false; +} + bool OSIPhone::_check_internal_feature_support(const String &p_feature) { return p_feature == "mobile"; }