Closed
Description
Checklist
- I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
- This issue only relates to a single bug. I will open new issues for any other problems.
Describe the bug
Hello! I am porting a systray application to fyne, and I believe I have found a race condition. If an application refreshes the system tray menu from a Goroutine, menu items can be duplicated.
How to reproduce
- Create an application with a system tray menu.
- Add a lifecycle hook which refreshes the menu from a Goroutine (see example code)
- When run, menu items will be duplicated.
Screenshots

Example code
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/driver/desktop"
)
func main() {
a := app.New()
if desk, ok := a.(desktop.App); ok {
m := fyne.NewMenu("MyApp",
fyne.NewMenuItem("Example", nil),
)
desk.SetSystemTrayMenu(m)
a.Lifecycle().SetOnStarted(func() {
go func() {
m.Refresh()
}()
})
}
a.Run()
}
Fyne version
2.4.4
Go compiler version
1.22.0
Operating system and version
macOS Sonoma
Additional Information
No response
Activity