ShardBrowser icon indicating copy to clipboard operation
ShardBrowser copied to clipboard

Linux/X11: launcher aborts with xcb_xlib_threads_sequence_lost when starting a profile (screen_resolution_mode=fingerprint)

Open DT-DEK2 opened this issue 1 week ago • 1 comments

Environment

  • ShardBrowser Launcher 2.1.6 (.deb from GitHub Releases) on Ubuntu 22.04.5 LTS, x86_64, glibc 2.35
  • X11 session (GNOME Shell on Xorg), single monitor eDP-1, 1920x1080, scale factor 1
  • Engine: bundled ShardX-Linux (Chromium 158), downloaded on first run
  • Profile: Linux, screen 1920x1080, SOCKS5 proxy bound

Summary

With the default screen_resolution_mode: "fingerprint", pressing Start on a profile aborts the whole launcher process with an XCB threading assertion. The engine never opens; the launcher window disappears. Repro rate 3/3.

Steps to reproduce

  1. Install 2.1.6 and start the app with default settings (~/.config/shardx-launcher/settings.json → "screen_resolution_mode": "fingerprint").
  2. Create any profile (Linux) and press Start.
  3. The launcher aborts; no browser window appears.

Actual

[launcher] display: name=Some("eDP-1") physical=1920x1080 scale=1 -> logical=1920x1080
[launcher] display: fingerprint screen=1920x1080
[launcher] display: real 1920x1080 >= fp 1920x1080 — keeping FP screen
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
shardbrowser-launcher: ../../src/xcb_io.c:278: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Aborted (core dumped)

Expected

The profile starts and the browser window opens.

Workaround

Set "screen_resolution_mode": "real" in ~/.config/shardx-launcher/settings.json and restart the launcher. The same profile then starts normally (verified: engine process running, browser window opened, profile usable).

Analysis / pointer

  • The abort happens right after clamp_screen_to_real_display() logs its decision, and before the engine spawn lines (widevine, QUIC/WebRTC) appear.
  • In src-tauri/src/launch.rs (v2.1.6), async start_browser() calls crate::clamp_screen_to_real_display(&w, &mut raw) (if !use_real_screen), which calls window.primary_monitor() (tao/GTK). On X11 that reaches Xlib from a non-main thread while XInitThreads() was never called — matching the assertion above.
  • Because wants_real_screen() returning true skips that branch, the "real" mode avoids the crash. That is consistent with the workaround working.

Impact

Every Linux/X11 user on the default setting cannot start any profile (the launcher dies instead). The app is unusable out of the box on this platform.

Related

  • #63 (screen clamp overriding the profile screen at launch) — same function, different symptom.

Extra data

  • Crash also occurs with no proxy bound and with the default profile created by the UI (no API involved).
  • The machine has one monitor; primary_monitor() and current_monitor() return the same display.
  • Happy to test a build with XInitThreads() called at startup, or with the monitor query moved to the Tauri main thread, if useful.

DT-DEK2 avatar Nov 24 '26 05:11 DT-DEK2

Follow-up after more testing on the same machine — the "real" workaround is incomplete, root cause confirmed, better workaround found.

  1. screen_resolution_mode: "real" only skips clamp_screen_to_real_display() when all of these hold: the mode is real, the profile is not mobile, and its screen was not picked by hand. The launcher still aborts with the same XCB assertion for:

    • Android/phone profiles (claims_mobile → use_real_screen == false),
    • profiles with _meta.screen_custom == true,
    • and profile create/save in the editor (profile_save → the same clamp call).
  2. The assertion is consistent with Xlib being used from more than one thread without XInitThreads(). Calling XInitThreads() before anything touches X11 makes the crash disappear.

  3. Workaround that works (tested 2/2, including a phone profile):

    /* xinitthreads.c */
    #include <X11/Xlib.h>
    __attribute__((constructor)) static void init(void) { XInitThreads(); }
    
    gcc -shared -fPIC -O2 -o libxinitthreads.so xinitthreads.c -lX11
    LD_PRELOAD=/path/to/libxinitthreads.so shardbrowser-launcher
    

    With screen_resolution_mode back at the default "fingerprint":

    • Linux profile: display: real 1920x1080 >= fp 1470x956 — keeping FP screen → launcher stays alive, CDP ready, browser opens.
    • Android/phone profile: display: phone profile — keeping its own screen → launcher stays alive, CDP ready, browser opens.

Suggested fix: call XInitThreads() once at startup on Linux (e.g. at the top of main() before tauri::Builder), or move the primary_monitor() query onto the Tauri main thread. A one-line XInitThreads() is enough on this machine.

DT-DEK2 avatar Nov 24 '26 05:11 DT-DEK2