Skip to content
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

Unused export plugins are polling in the background #59787

Open
rcorre opened this issue Apr 1, 2022 · 0 comments
Open

Unused export plugins are polling in the background #59787

rcorre opened this issue Apr 1, 2022 · 0 comments

Comments

@rcorre
Copy link
Contributor

rcorre commented Apr 1, 2022

Godot version

3.4.4.stable.arch_linux

System information

Linux 5.16.16-arch1-1

Issue description

While looking into #35868, I noticed that the Javascript, IOS, and Android exporters are in a constant poll loop as soon as I start the editor. They're not consuming an excessive amount of CPU, so it isn't a huge deal, but would it be worth starting the threads only if you have an export target for that platform?

static void _check_for_changes_poll_thread(void *ud) {
EditorExportPlatformIOS *ea = (EditorExportPlatformIOS *)ud;
while (!ea->quit_request.is_set()) {
// Nothing to do if we already know the plugins have changed.
if (!ea->plugins_changed.is_set()) {
ea->plugins_lock.lock();
Vector<PluginConfigIOS> loaded_plugins = get_plugins();
if (ea->plugins.size() != loaded_plugins.size()) {
ea->plugins_changed.set();
} else {
for (int i = 0; i < ea->plugins.size(); i++) {
if (ea->plugins[i].name != loaded_plugins[i].name || ea->plugins[i].last_updated != loaded_plugins[i].last_updated) {
ea->plugins_changed.set();
break;
}
}
}
ea->plugins_lock.unlock();
}
uint64_t wait = 3000000;
uint64_t time = OS::get_singleton()->get_ticks_usec();
while (OS::get_singleton()->get_ticks_usec() - time < wait) {
OS::get_singleton()->delay_usec(300000);
if (ea->quit_request.is_set()) {
break;
}
}
}
}

Thread 9 (Thread 0x7fffb77fe640 (LWP 83945) "godot.x11.opt.t"):
#0  0x00007ffff7b64a55 in clock_nanosleep@GLIBC_2.2.5 () from /usr/lib/libc.so.6
#1  0x00007ffff7b69717 in nanosleep () from /usr/lib/libc.so.6
#2  0x00000000013f7270 in OS_Unix::delay_usec (this=<optimized out>, p_usec=<optimized out>) at drivers/unix/os_unix.cpp:243
#3  0x0000000001d5f9ed in EditorExportPlatformJavaScript::_server_thread_poll (data=0x9a1a430) at platform/javascript/export/export.cpp:966
#4  0x0000000003179a05 in Thread::callback (p_self=<optimized out>, p_settings=..., p_callback=0x1d5f9c0 <EditorExportPlatformJavaScript::_server_thread_poll(void*)>, p_userdata=0x9a1a430) at core/os/thread.cpp:77
#5  0x00000000034d3ed4 in execute_native_thread_routine ()
#6  0x00007ffff7b195c2 in start_thread () from /usr/lib/libc.so.6
#7  0x00007ffff7b9e584 in clone () from /usr/lib/libc.so.6

Thread 8 (Thread 0x7fffb7fff640 (LWP 83944) "godot.x11.opt.t"):
#0  0x00007ffff7b64a55 in clock_nanosleep@GLIBC_2.2.5 () from /usr/lib/libc.so.6
#1  0x00007ffff7b69717 in nanosleep () from /usr/lib/libc.so.6
#2  0x00000000013f7270 in OS_Unix::delay_usec (this=<optimized out>, p_usec=<optimized out>) at drivers/unix/os_unix.cpp:243
#3  0x0000000001d58c86 in EditorExportPlatformIOS::_check_for_changes_poll_thread (ud=0xa427e00) at platform/iphone/export/export.cpp:171
#4  0x0000000003179a05 in Thread::callback (p_self=<optimized out>, p_settings=..., p_callback=0x1d58b70 <EditorExportPlatformIOS::_check_for_changes_poll_thread(void*)>, p_userdata=0xa427e00) at core/os/thread.cpp:77
#5  0x00000000034d3ed4 in execute_native_thread_routine ()
#6  0x00007ffff7b195c2 in start_thread () from /usr/lib/libc.so.6
#7  0x00007ffff7b9e584 in clone () from /usr/lib/libc.so.6

Thread 7 (Thread 0x7fffbcb38640 (LWP 83943) "godot.x11.opt.t"):
#0  0x00007ffff7b64a55 in clock_nanosleep@GLIBC_2.2.5 () from /usr/lib/libc.so.6
#1  0x00007ffff7b69717 in nanosleep () from /usr/lib/libc.so.6
#2  0x00000000013f7270 in OS_Unix::delay_usec (this=<optimized out>, p_usec=<optimized out>) at drivers/unix/os_unix.cpp:243
#3  0x0000000001d0af43 in EditorExportPlatformAndroid::_check_for_changes_poll_thread (ud=0x9f59d30) at platform/android/export/export_plugin.cpp:380
#4  0x0000000003179a05 in Thread::callback (p_self=<optimized out>, p_settings=..., p_callback=0x1d0adc0 <EditorExportPlatformAndroid::_check_for_changes_poll_thread(void*)>, p_userdata=0x9f59d30) at core/os/thread.cpp:77
#5  0x00000000034d3ed4 in execute_native_thread_routine ()
#6  0x00007ffff7b195c2 in start_thread () from /usr/lib/libc.so.6
#7  0x00007ffff7b9e584 in clone () from /usr/lib/libc.so.6

Moved from godotengine/godot-proposals#4241.

Steps to reproduce

  1. Build godot with debug symbols
  2. Start a new project
  3. Pause with the debugger
  4. List threads

Minimal reproduction project

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants