mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-21 09:42:09 +08:00
Every tauri menu API call from a non-main thread blocks on a synchronous round-trip to the app event loop. Building the tray menu with proxy groups enabled issued one such round-trip per menu item (200+ for a typical subscription) while holding the menu update lock, and the cost grows when the event loop is busy with webview work. Gather the async inputs (verge/clash/profiles snapshots and the proxy view) on the caller's task, then construct every menu item inside a single run_on_main_thread closure and hand the finished menu back; set_menu and the per-group refresh keep their original call sites. Measured on a standalone tauri bench (5 groups x 40 nodes): a rebuild drops from ~6.2ms to ~1.6ms on an idle event loop and from ~11.4ms to ~1.6ms with the loop busy. refresh_proxy_items already used this shape; the rebuild path now matches it.