mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-22 02:22:08 +08:00
Menu APIs always execute on the main thread; called from a worker each one pays a blocking round-trip (channel + event-loop hop + recv), so rebuilding a proxy menu issued 200+ such round-trips in a row while the caller waits, and the cost grows when the event loop is busy with webview work. Gather the async inputs (verge/clash/profiles snapshots, proxies and runtime group order) on the caller's task, then construct every menu item and attach it inside a single run_on_main_thread closure where each call runs inline. refresh_proxy_items used the same shape on the old base; the rebuild path now matches it. 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 (8ms work per 16ms frame).