Skip to content

fix(linux): prevent startup panic from unrealized capsule GDK window | fix(linux): 修复胶囊窗口因 GDK 未实例化导致的启动崩溃#792

Open
yuanchenglu wants to merge 1 commit into
Open-Less:betafrom
yuanchenglu:fix/linux-startup-crash-unrealized-capsule-window
Open

fix(linux): prevent startup panic from unrealized capsule GDK window | fix(linux): 修复胶囊窗口因 GDK 未实例化导致的启动崩溃#792
yuanchenglu wants to merge 1 commit into
Open-Less:betafrom
yuanchenglu:fix/linux-startup-crash-unrealized-capsule-window

Conversation

@yuanchenglu

@yuanchenglu yuanchenglu commented Jul 12, 2026

Copy link
Copy Markdown

User description

Problem

OpenLess crashes on Linux X11 immediately at startup with:

Root Cause

The capsule window is defined in tauri.conf.json with visible: false + transparent: true. On Linux/GTK3, a hidden window never has its underlying GDK window realized. When capsule.set_ignore_cursor_events(true) is called during startup, tao internally calls window.window().unwrap() which returns None for the unrealized window — panic.

This is the same issue reported in:

Fix

Before calling set_ignore_cursor_events, move the window off-screen and call show() to force GDK window realization. The window is then repositioned correctly by the existing position_capsule_bottom_center() and hidden as normal.

The change is Linux-only (#[cfg(target_os = "linux")]) and confined to the capsule setup block; no other call sites are touched.

Testing

Verified on Deepin Linux 23 (X11, DDE/kwin_x11):

  • Before: crashes 100% on startup
  • After: app initializes normally, hotkey listeners register, tray icon appears, capsule shows/hides on speak

References


PR Type

Bug fix


Description

  • Fix Linux startup crash due to unrealized GDK capsule window.

  • Force GDK window realization before calling set_ignore_cursor_events.


Diagram Walkthrough

flowchart LR
  Capsule["Capsule window (visible=false)"]
  GDK["GDK window unrealized"]
  Crash["Panic at set_ignore_cursor_events"]
  Fix["Move off-screen & show()"]
  Ok["Window realized, repositioned"]
  Capsule --> GDK
  GDK --> Crash
  GDK -.-> Fix
  Fix --> Ok
Loading

File Walkthrough

Relevant files
Bug fix
lib.rs
Fix Linux capsule GDK realization crash                                   

openless-all/app/src-tauri/src/lib.rs

  • Add Linux-specific block to force GDK window realization before
    setting ignore cursor events.
  • Move window off-screen and show() to trigger realization, then
    reposition.
+12/-0   

…| fix(linux): 修复胶囊窗口因 GDK 未实例化导致的启动崩溃

On Linux X11, when the capsule window is created with `visible: false` +
`transparent: true` in tauri.conf.json, its underlying GDK window is never
realized. The subsequent call to `capsule.set_ignore_cursor_events(true)`
triggers a panic inside tao's Linux event loop (event_loop.rs:457) because
`window.window().unwrap()` returns `None` for an unrealized GDK window.

The fix follows the same approach as voicebox PR#837 (PhamBit):
force GDK window realization before calling set_ignore_cursor_events, by
first moving the window off-screen and calling show(). The window is then
repositioned correctly by the existing position_capsule_bottom_center()
call and hidden as normal.

Refs:
  - jamiepine/voicebox#837
  - tauri-apps/tao#635

在 Linux X11 上,tauri.conf.json 中定义的 capsule 窗口设置了
visible: false + transparent: true,导致其底层 GDK 窗口从未被实例化。
随后调用 capsule.set_ignore_cursor_events(true) 时,tao 的 Linux 事件循环
(event_loop.rs:457) 因 window.window().unwrap() 返回 None 而 panic 崩溃。

修复方法参考 voicebox PR#837:在设置鼠标穿透前先将窗口移出屏幕并
调用 show() 强制 GDK 实例化,后续由原有的 position_capsule_bottom_center()
重新定位并隐藏。
@github-actions

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

680 - Partially compliant

Compliant requirements:

(none)

Non-compliant requirements:

  • PR does not modify polish.rs or any retry logic; this ticket is not addressed.

Requires further human verification:

(none)

680 - Partially compliant

Compliant requirements:

(none)

Non-compliant requirements:

  • PR does not modify voicebox polish code; this ticket is not addressed.

Requires further human verification:

(none)

635 - Partially compliant

Compliant requirements:

(none)

Non-compliant requirements:

  • PR does not modify ASR credential logic; this ticket is not addressed.

Requires further human verification:

(none)

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ No major issues detected

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant