Files
arcrun-collector/cmd/arcrun-app
Leo 643acc0f74 t194 修:托盤必須在主執行緒建立——交付警察攔下,實跑才發現會 crash
交付警察問「leo 現在去測會不會發現你沒發現的東西」⇒ 我去真的跑一次,
**發現這版根本起不來**。我原本只驗了「打包產物有沒有那些檔案」,沒驗它會不會活著。

## 兩個 crash,都要真機跑才看得到
① `systray.Run()` 自己開 loop ⇒ 與 Wails 搶 macOS 主 loop
   ⇒ SIGTRAP `signal arrived during cgo execution`
② 改用 RunWithExternalLoop 但在 OnStartup/goroutine 裡呼叫 start
   ⇒ SIGABRT `NSWindow should only be instantiated on the main thread!`
   (NSStatusItem 內部會 new NSWindow,AppKit 規定只能在主執行緒)
   ⚠️ 我一度想「加個 sleep 丟 goroutine」——那只是拖延,goroutine 永遠不是主執行緒。

## 正解
main() 一開始(還在主執行緒)就 RunWithExternalLoop 註冊並 trayStart(),
它**不阻塞**,接著把主執行緒交給 wails.Run();defer trayEnd() 收尾。

## 實測(跑真的 .app,非只看檔案)
  App 活著 pid 59162 
  它拉起自己的 collector (arcrun-app/.../arcrun-collector,與舊 fyne 版並存不衝突)
  crash 訊號 0 /log 僅 1 行 
兩支機械閘仍全過。

⚠️ 未驗:托盤左右鍵的**點擊行為**要人真的去點(我點不了)。
2026-08-05 00:46:52 +08:00
..

README

About

This is the official Wails Vanilla template.

You can configure the project by editing wails.json. More information about the project settings can be found here: https://wails.io/docs/reference/project-config

Live Development

To run in live development mode, run wails dev in the project directory. This will run a Vite development server that will provide very fast hot reload of your frontend changes. If you want to develop in a browser and have access to your Go methods, there is also a dev server that runs on http://localhost:34115. Connect to this in your browser, and you can call your Go code from devtools.

Building

To build a redistributable, production mode package, use wails build.