From 27ab97501b4b39ce200c0609071d2dd12d7b7c12 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Thu, 6 Aug 2020 16:20:05 +0200 Subject: [HTML5] Add override keyword, cleanup methods. --- platform/javascript/os_javascript.h | 44 ++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 25 deletions(-) (limited to 'platform/javascript/os_javascript.h') diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 22234f9355..23809d35a1 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -52,49 +52,43 @@ class OS_JavaScript : public OS_Unix { static void file_access_close_callback(const String &p_file, int p_flags); protected: - virtual void initialize(); + void initialize() override; - virtual void set_main_loop(MainLoop *p_main_loop); - virtual void delete_main_loop(); + void set_main_loop(MainLoop *p_main_loop) override; + void delete_main_loop() override; - virtual void finalize(); + void finalize() override; - virtual bool _check_internal_feature_support(const String &p_feature); + bool _check_internal_feature_support(const String &p_feature) override; public: // Override return type to make writing static callbacks less tedious. static OS_JavaScript *get_singleton(); - virtual void initialize_joypads(); + void initialize_joypads() override; - virtual bool has_touchscreen_ui_hint() const; - - virtual int get_audio_driver_count() const; - virtual const char *get_audio_driver_name(int p_driver) const; - - virtual MainLoop *get_main_loop() const; + MainLoop *get_main_loop() const override; void finalize_async(); bool main_loop_iterate(); - virtual Error execute(const String &p_path, const List &p_arguments, bool p_blocking = true, ProcessID *r_child_id = nullptr, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr); - virtual Error kill(const ProcessID &p_pid); - virtual int get_process_id() const; + Error execute(const String &p_path, const List &p_arguments, bool p_blocking = true, ProcessID *r_child_id = nullptr, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr) override; + Error kill(const ProcessID &p_pid) override; + int get_process_id() const override; - String get_executable_path() const; - virtual Error shell_open(String p_uri); - virtual String get_name() const; + String get_executable_path() const override; + Error shell_open(String p_uri) override; + String get_name() const override; // Override default OS implementation which would block the main thread with delay_usec. // Implemented in javascript_main.cpp loop callback instead. - virtual void add_frame_delay(bool p_can_draw) {} - virtual bool can_draw() const; + void add_frame_delay(bool p_can_draw) override {} - virtual String get_cache_path() const; - virtual String get_config_path() const; - virtual String get_data_path() const; - virtual String get_user_data_dir() const; + String get_cache_path() const override; + String get_config_path() const override; + String get_data_path() const override; + String get_user_data_dir() const override; void set_idb_available(bool p_idb_available); - virtual bool is_userfs_persistent() const; + bool is_userfs_persistent() const override; void resume_audio(); bool is_finalizing() { return finalizing; } -- cgit v1.2.3 From dccd71c7a36fc31f6cc19e0f7f587fb0860c973a Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Fri, 18 Sep 2020 17:25:05 +0200 Subject: JS synchronous start, better persistent FS sync. The engine now expects to emscripten FS to be setup and sync-ed before main is called. This is exposed via `Module["initFS"]` which also allows to setup multiple persistence paths (internal use only for now). Additionally, FS syncing is done **once** for every loop if at least one file in a persistent path was open for writing and closed, and if the FS is not syncing already. This should potentially fix issues reported by users where "autosave" would not work on the web (never calling `syncfs` because of too many writes). --- platform/javascript/os_javascript.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'platform/javascript/os_javascript.h') diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 23809d35a1..85551d708b 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -44,8 +44,7 @@ class OS_JavaScript : public OS_Unix { bool finalizing = false; bool idb_available = false; - int64_t sync_wait_time = -1; - int64_t last_sync_check_time = -1; + bool idb_needs_sync = false; static void main_loop_callback(); @@ -62,6 +61,8 @@ protected: bool _check_internal_feature_support(const String &p_feature) override; public: + bool idb_is_syncing = false; + // Override return type to make writing static callbacks less tedious. static OS_JavaScript *get_singleton(); -- cgit v1.2.3