-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the cleanup logic for the Android render thread #94661
Fix the cleanup logic for the Android render thread #94661
Conversation
unfortunately not yet (on Samsung Tab S7, Android 13) with 1 sec delayError ResourceFormatSaverTextInstance::save(const String &p_path, const Ref<Resource> &p_resource, uint32_t p_flags) {
if (p_path.ends_with(".tscn")) {
packed_scene = p_resource;
}
Error err;
Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::WRITE, &err);
ERR_FAIL_COND_V_MSG(err, ERR_CANT_OPEN, "Cannot save file '" + p_path + "'.");
Ref<FileAccess> _fref(f);
print_line("BEGIN DELAY: ", OS::get_singleton()->get_ticks_usec());
OS::get_singleton()->delay_usec(1000000); // 1 000 000 = 1 sec
print_line("END DELAY: ", OS::get_singleton()->get_ticks_usec());
local_path = ProjectSettings::get_singleton()->localize_path(p_path); Logcat:
The editor does not crash due to bugfix #94593. The editor loads the default settings. I have switched to English, but then it switches to the default “German”, my system language. Test without PR #94593 singleton = ResourceLoader::load(config_file_path, "EditorSettings");
//before PR #94593
singleton->set_path(get_newest_settings_path()); // Settings can be loaded from older version file, so make sure it's newest.
if (singleton.is_null()) {
ERR_PRINT("Could not load editor settings from path: " + config_file_path);
//PR #94593
//config_file_path = get_newest_settings_path();
goto fail;
}
//PR #94593
//singleton->set_path(get_newest_settings_path()); // Settings can be loaded from older version file, so make sure it's newest.
singleton->save_changed_setting = true; Crash:
Empty file: |
Notes: I can't see on Android: (Dev-Build) from with print_line("BEGIN DELAY: ", OS::get_singleton()->get_ticks_usec());
OS::get_singleton()->delay_usec(50000); // 1 000 000 = 1 sec
print_line("END DELAY: ", OS::get_singleton()->get_ticks_usec()); If
|
3f8dc42
to
d27514f
Compare
On Android the exit logic goes through `Godot#onDestroy()` who attempts to cleanup the engine using the following code: ``` runOnRenderThread { GodotLib.ondestroy() forceQuit() } ``` The issue however is that by the time we ran this code, the render thread has already been paused (but not yet destroyed), and thus `GodotLib.ondestroy()` and `forceQuit()` which are scheduled on the render thread are not executed. To address this, we instead explicitly request the render thread to exit and block until it does. As part of it exit logic, the render thread has been updated to properly destroy and clean the native instance of the Godot engine, resolving the issue.
d27514f
to
4d0da74
Compare
Thanks for testing @Alex2782! I made some additional changes which should address the issue. I was able to confirm by replicating your test - adding a delay to the saving logic - and I'm no longer able to repro the issue. Can you take another look. |
Looks great! Tested with up to 10 seconds delay (no ANRs) and |
Thanks! |
On Android the exit logic goes through
Godot#onDestroy()
who attempts to cleanup the engine using the following code:The issue however is that by the time we ran this code, the render thread has already been paused (but not yet destroyed), and thus
GodotLib.ondestroy()
andforceQuit()
which are scheduled on the render thread queue, are not pulled out off the queue and not executed.To address this, we instead explicitly request the render thread to exit and block until it does. As part of it exit logic, the render thread has been updated to properly destroy and clean the native instance of the Godot engine, resolving the issue.
Fixes #93826