Repository navigation
Backlog
Labels
bugSomething isn't working
Description
版本 / Version
v0.9.5
最后正常的版本 / Last version that worked
No response
安装包 / Package
Linux amd64 deb
系统及版本 / OS and version
Ubuntu 24.04 KDE Wayland
运行方式 / How traffic is taken over
虚拟网卡 / TUN(桌面 / desktop)
问题出在哪 / Area
安装、启动或闪退 / Install, launch or crash
能否稳定复现 / Reproducible
每次都会 / Every time
复现步骤 / Steps to reproduce
- 第一次安装使用
- 打开后可以正常使用各项功能
- 点击窗口右上角关闭窗口隐藏到系统托盘
- 再次点击系统托盘打开窗口无响应,也无法退出
- 重新从应用启动器打开也无法打开
期望结果 / Expected behavior
从右上角点击关闭再从系统托盘点击可以恢复窗口
实际结果 / Actual behavior
无论是通过系统托盘还是应用启动器都无法显示主界面
日志 / Log
# 说明:因复现(点击关闭按钮隐藏窗口到托盘)后 GTK 主线程立即死锁,窗口无法再次唤起以点击 GUI 内的“导出日志”,以下为复现全过程的 systemd/journalctl 日志及死锁线程内核状态采集:
=== 1. 启动、隐藏窗口与再次唤醒超时的系统日志 (journalctl --user) ===
11月 30 16:19:25 juel systemd[1857]: Started app-FlClash-f8a26e7847c5404782ef03ee0b82d158.scope - FlClash - FlClash.
11月 30 16:19:25 juel plasmashell[51516]: [IMPORTANT:flutter/shell/platform/embedder/embedder_surface_gl_impeller.cc(127)] Using the Impeller rendering backend (OpenGLESSDF).
11月 30 16:19:25 juel FlClash[51516]: Failed to read XDG desktop portal settings: GDBus.Error:org.freedesktop.portal.Error.NotFound: 未找到请求的设置
11月 30 16:19:25 juel FlClash[51516]: Unable to load from the cursor theme
11月 30 16:19:26 juel dbus-daemon[2197]: [session uid=1000 pid=2197] Activating service name='org.gnome.ScreenSaver' requested by ':1.421' (uid=1000 pid=51516 comm="/usr/bin/FlClash" label="unconfined")
11月 30 16:19:26 juel kwin_wayland_wrapper[2961]: kwin_core: Cannot grant a token to KWaylandServer::ClientConnection(0x5f2f8832e410)
11月 30 16:19:26 juel org.kde.kded5[37848]: Registering "org.kde.StatusNotifierItem-51516-1/StatusNotifierItem" to system tray
11月 30 16:19:28 juel FlClash[51516]: Timed out waiting for subsurface frame of size 2560x1760 (have 1360x1160)
11月 30 16:19:30 juel plasmashell[51516]: https://github.com/concord-net/FlClash/releases/latest
11月 30 16:19:41 juel plasmashell[51516]: Error: SocketException: Connection failed (OS Error: 没有那个文件或目录, errno = 2), address = /run/flclash/helper.sock, port = 0
# [此时点击窗口右上角关闭按钮 (X) 隐藏到托盘,随后点击托盘图标无响应;于 16:21:18 再次从应用菜单点击 FlClash 尝试唤醒主实例]
11月 30 16:21:18 juel systemd[1857]: Started app-FlClash-f686208df643493b9883538040cedb80.scope - FlClash - FlClash.
11月 30 16:21:43 juel plasmashell[51831]: Failed to register: 已到超时限制
=== 2. 窗口隐藏后死锁状态下的线程与 WCHAN 状态 (ps -L -p 51516) ===
TID COMMAND %CPU STAT WCHAN
51516 FlClash 0.0 Sl futex_do_wait
51517 pool-spawner 0.0 Sl futex_do_wait
51518 gmain 0.0 Sl poll_schedule_timeout.constprop.0
51519 gdbus 0.0 Sl poll_schedule_timeout.constprop.0
51533 io.flutter.rast 40.3 Rl poll_schedule_timeout.constprop.0
51534 io.flutter.io 0.0 Sl ep_poll
51586 screens 0.0 Sl ep_poll
51621 hotkey-events 0.0 Sl futex_do_wait
51622 network-netlink 0.0 Sl skb_wait_for_more_packets
51623 network-watch 0.0 Sl futex_do_wait
51630 tray 0.0 Sl ep_poll
51650 ipc-server 0.0 Sl ep_poll
=== 3. 主线程与 Raster 渲染线程上下文切换对比 (/proc/51516/task/*/status,间隔 4 分钟采样) ===
# 采样 1:
/proc/51516/task/51516/status:Name: FlClash
/proc/51516/task/51516/status:State: S (sleeping)
/proc/51516/task/51516/status:voluntary_ctxt_switches: 139042
/proc/51516/task/51533/status:Name: io.flutter.rast
/proc/51516/task/51533/status:State: R (running)
/proc/51516/task/51533/status:voluntary_ctxt_switches: 197536242
# 采样 2(约 240 秒后):
/proc/51516/task/51516/status:Name: FlClash
/proc/51516/task/51516/status:State: S (sleeping)
/proc/51516/task/51516/status:voluntary_ctxt_switches: 139042 # 主线程彻底卡死在 futex_do_wait (FlViewRendererSubsurface->mutex),0 次切换
/proc/51516/task/51533/status:Name: io.flutter.rast
/proc/51516/task/51533/status:State: R (running)
/proc/51516/task/51533/status:voluntary_ctxt_switches: 225925950 # io.flutter.rast 持有 mutex 在 poll() 中每秒空转 ~11.8 万次
通过检查死锁状态下的进程线程状态及反汇编 libflutter_linux_gtk.so 与 librust_api.so,定位到這是 Flutter Linux GTK 引擎的 Wayland 子表面渲染器(FlViewRendererSubsurface)在父窗口 gtk_widget_hide() 时引发的跨线程锁竞争 / 死锁
详细过程如下
1.在 Wayland 原生模式下(GDK_IS_WAYLAND_DISPLAY(display) == true),fl_view_new 选择FlViewRendererSubsurface(通过 wl_subsurface + wl_egl_window 渲染),其内部使用互斥锁 self->mutex(偏移 +0x70)保护 subsurface 与 subsurface_renderer。
2.当用户点击关闭按钮时,librust_api.so 拦截关闭操作并在 GTK 主线程调用 gtk_widget_hide(window)。
3.在 GTK3 Wayland 后端中,gtk_widget_hide(window) 会立即 unmap 并销毁顶层 GdkWaylandWindow 的 wl_surface(gdk_wayland_window_get_wl_surface(window) 变为 NULL),同时触发 FlViewRendererSubsurface 的 update_subsurface / unmap / size-allocate 回调,在 GTK 主线程尝试获取 g_mutex_lock(&self->mutex)。
4.若此时 io.flutter.rast 渲染线程正处于 fl_view_renderer_subsurface_render() 中,它已经持有了 self->mutex,并在锁内调用 fl_subsurface_renderer_render() -> eglSwapBuffers()。
5.由于顶层父 wl_surface 已被销毁,且 FlWaylandDisplay 与 GTK 主线程共享同一个 wl_display,io.flutter.rast 在 eglSwapBuffers 内部等待 Wayland 缓冲区释放/事件队列完成时陷入高频 poll() 循环,无法退出并释放 self->mutex;而负责泵送主事件循环与 Wayland 队列的 GTK 主线程又在等待 io.flutter.rast 释放 self->mutex,形成死锁。
6.一旦 GTK 主线程死锁在 self->mutex 上:
托盘线程通过 GLib 主循环投递的 gtk_widget_show / gtk_window_present 任务永远无法被主循环执行(对应 librust_api.so 中的 "the main loop did not answer");
新启动的 FlClash 实例通过 D-Bus 向主实例发送的 activate-window / org.gtk.Application.Activate 也无法得到响应,25 秒后超时失败。
相关配置 / Relevant configuration
截图或录屏 / Screenshots or recording
No response
确认 / Checks
- 我已更新到最新版,问题仍然存在。/ I updated to the latest release and the problem is still there.
- 我搜索过已有 issue(包括已关闭的),没有相同的。/ I searched the existing issues, open and closed, and found no duplicate.
- 我已删掉订阅链接、服务器地址、密码和 UUID。/ I removed subscription URLs, server addresses, passwords and UUIDs.
- 这个 issue 只报告一个问题。/ This issue reports one problem.
- 换别的节点,或在别的客户端用同一节点对比过,不是机场或节点本身的问题。/ I compared with another node, or the same node in another client, and it is not a problem of the subscription provider or the node.
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
mahiroiii commentedon Dec 1, 2026
可以参考一下 #3124 ,我通过拉取源码重新构建,确实可以解决这个问题。