fyne-io / systray

a cross platfrom Go library to place an icon and menu in the notification area
Apache License 2.0
223 stars 41 forks source link

Add support for removing a menu item #34

Closed bdwyertech closed 1 year ago

bdwyertech commented 1 year ago

Resolves #33 and https://github.com/fyne-io/fyne/issues/3463

bdwyertech commented 1 year ago

Nice addition, thanks. I think some code is needed for unix as well?

I'll have to give the Unix code a further look. Quick glance says pruning the button ID from a slice and triggering a refresh.

Also, I did notice another memory leak I cannot quite figure out... Seems to be related to the Icon setting code on Darwin specifically. If I use a test harness to delete/create a new MenuItem every few seconds, after a few hours the memory usage multiplies exponentially. pprof nor Datadog show anything. If I remove SetIcon from the loop, the memory does not balloon. My thought is something is not freeing up transient resources, probably something in the cast from CGO -> NSData -> NSImage -> NSMenuItem.image.

andydotxyz commented 1 year ago

Thanks, do post here if you need more assistance with the unix code.

With regards to icon memory leak, I think that also was reported in our usage in the toolkit at https://github.com/fyne-io/fyne/issues/3463, so you're not the only one to see it. The image data is obviously not being cleaned up in the C code.

bdwyertech commented 1 year ago

Thanks, do post here if you need more assistance with the unix code.

With regards to icon memory leak, I think that also was reported in our usage in the toolkit at fyne-io/fyne#3463, so you're not the only one to see it. The image data is obviously not being cleaned up in the C code.

Should all be resolved now. Tested the tray on Kali, that dbus system is pretty interesting!