'Signal: Bus Error' when running on MacOS
I've been trying to use this package to integrate with an application written in Wails. However, whenever I try to run it, it throws an error saying signal: bus error. I've tried taking the basic example from the repo, but even that seems to throw the same error. I have a feeling something is wrong with CGO in my case.
My System
MacOS version: Ventura 13.1 Go Version: 20.2 (I've tried 1.19 and 1.17 but same result) CC env in Go: /usr/bin/clang (I tried the default as well but same result) GCCGO env in GO: gccgo
The Code
package main
import (
"fmt"
"time"
"fyne.io/systray"
"fyne.io/systray/example/icon"
)
func main() {
onExit := func() {
now := time.Now()
fmt.Println("Exit at", now.String())
}
systray.Run(onReady, onExit)
}
func addQuitItem() {
mQuit := systray.AddMenuItem("Quit", "Quit the whole app")
mQuit.Enable()
go func() {
<-mQuit.ClickedCh
fmt.Println("Requesting quit")
systray.Quit()
fmt.Println("Finished quitting")
}()
systray.AddSeparator()
}
func onReady() {
systray.SetTemplateIcon(icon.Data, icon.Data)
systray.SetTitle("Awesome App")
systray.SetTooltip("Lantern")
addQuitItem()
// We can manipulate the systray in other goroutines
go func() {
systray.SetTemplateIcon(icon.Data, icon.Data)
systray.SetTitle("Awesome App")
systray.SetTooltip("Pretty awesome棒棒嗒")
mChange := systray.AddMenuItem("Change Me", "Change Me")
mChecked := systray.AddMenuItemCheckbox("Checked", "Check Me", true)
mEnabled := systray.AddMenuItem("Enabled", "Enabled")
// Sets the icon of a menu item. Only available on Mac.
mEnabled.SetTemplateIcon(icon.Data, icon.Data)
systray.AddMenuItem("Ignored", "Ignored")
subMenuTop := systray.AddMenuItem("SubMenuTop", "SubMenu Test (top)")
subMenuMiddle := subMenuTop.AddSubMenuItem("SubMenuMiddle", "SubMenu Test (middle)")
subMenuBottom := subMenuMiddle.AddSubMenuItemCheckbox("SubMenuBottom - Toggle Panic!", "SubMenu Test (bottom) - Hide/Show Panic!", false)
// subMenuMiddle.AddSeparator()
subMenuBottom2 := subMenuMiddle.AddSubMenuItem("SubMenuBottom - Panic!", "SubMenu Test (bottom)")
systray.AddSeparator()
mToggle := systray.AddMenuItem("Toggle", "Toggle some menu items")
shown := true
toggle := func() {
if shown {
subMenuBottom.Check()
subMenuBottom2.Hide()
mEnabled.Hide()
shown = false
} else {
subMenuBottom.Uncheck()
subMenuBottom2.Show()
mEnabled.Show()
shown = true
}
}
mReset := systray.AddMenuItem("Reset", "Reset all items")
for {
select {
case <-mChange.ClickedCh:
mChange.SetTitle("I've Changed")
case <-mChecked.ClickedCh:
if mChecked.Checked() {
mChecked.Uncheck()
mChecked.SetTitle("Unchecked")
} else {
mChecked.Check()
mChecked.SetTitle("Checked")
}
case <-mEnabled.ClickedCh:
mEnabled.SetTitle("Disabled")
mEnabled.Disable()
case <-subMenuBottom2.ClickedCh:
panic("panic button pressed")
case <-subMenuBottom.ClickedCh:
toggle()
case <-mReset.ClickedCh:
systray.ResetMenu()
addQuitItem()
case <-mToggle.ClickedCh:
toggle()
}
}
}()
}
Command
go run .
Expected Behaviour
You should see a new icon on the system tray.
Actual Behaviour
An error is returned: signal: bus error
Any idea why this occurs? I've tried the same program on a Windows 10 machine and it works fine.
Can you please include the full stack trace? Just the error text does not include enough information for debugging purposes.
Does the included example app work without modifications?