linux: call XInitThreads() to make X11 access thread-safe#2816
Conversation
Flutter’s engine spawns multiple threads (UI, raster, etc.). Under X11 these threads may issue X calls concurrently, which is undefined unless XInitThreads() is invoked before the first X request. Without this, the app aborts on launch with: [xcb] Unknown request in queue while dequeuing [xcb] Most likely this is a multi-threaded client and XInitThreads has not been called KomodoWallet: xcb_io.c:175: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed. This patch: * adds `#include <X11/Xlib.h>` * calls `XInitThreads()` at the very start of `main()` in `linux/runner/main.cc` * ensures libX11 is linked via CMake Wayland sessions were already stable; this change fixes crashes when running under pure X11 or XWayland. - flutter/flutter#170937 - flutter/flutter#169470
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Visit the preview URL for this PR (updated for commit e9c8ba2): https://walletrc--pull-2816-merge-330w8asu.web.app (expires Tue, 01 Jul 2025 20:55:55 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: f66a4ff03faa546f12f0ae5a841bd9eff2714dcc |
CharlVS
left a comment
There was a problem hiding this comment.
Thank you so much for getting to the bottom of this.
smk762
left a comment
There was a problem hiding this comment.
Built and running on Ubuntu24 with XDG_SESSION_TYPE: x11 for over an hour without any stability issues.
Flutter’s engine spawns multiple threads (UI, raster, etc.). Under X11 these threads may issue X calls concurrently, which is undefined unless XInitThreads() is invoked before the first X request.
Without this, the app aborts on launch with:
This patch:
#include <X11/Xlib.h>XInitThreads()at the very start ofmain()inlinux/runner/main.ccWayland sessions were already stable; this change fixes crashes when running under pure X11 or XWayland.