1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-09 12:50:35 +00:00
Files
godot/platform/linuxbsd/wayland/wayland_thread.cpp
Dery Almas ab205a78ce Wayland: defer event thread initialization to late initialization
This race condition made me pull my hair. `wl_display_roundtrip` has its
own little event loop, which apparently conflicts hard with the
always-running event loop thread.

I kinda assumed that it would be thread-safe thanks to its internal
`wl_display_prepare_read` call that the docs talk about but that's
clearly not enough.

Luckily this method is called very few times and the only dangerous
instances are in the initialization routine, which first starts the
thread and then does various roundtrips. Libdecor has also some internal
roundtrips of its own which would often fail. Starting the thread after
all initialization fixes the issue.

Tested this by spamming *lots* of `wl_display_roundtrip` in
`WaylandThread::init()` with and without this fix.
2025-10-10 23:25:00 +02:00

164 KiB