Skip to content

Systray app on macOS panic when started while machine sleeps #3609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
d1ss0nanz opened this issue Jan 27, 2023 · 2 comments
Closed
2 tasks done

Systray app on macOS panic when started while machine sleeps #3609

d1ss0nanz opened this issue Jan 27, 2023 · 2 comments
Labels
unverified A bug that has been reported but not verified

Comments

@d1ss0nanz
Copy link
Contributor

d1ss0nanz commented Jan 27, 2023

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

Our app gets updated by an external process and is restarted.
When this happens while the machine sleeps (macBook: closed lid), the app crashes reproducably.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x45148fe]

goroutine 1 [running, locked to thread]:
github.com/go-gl/glfw/v3.3/glfw.(*Monitor).GetPhysicalSize.func1(0x0?, 0x0?, 0x0?)
	/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20221017161538-93cebf72946b/monitor.go:152 +0x1e
github.com/go-gl/glfw/v3.3/glfw.(*Monitor).GetPhysicalSize(0xc000532000?)
	/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20221017161538-93cebf72946b/monitor.go:152 +0x51
fyne.io/fyne/v2/internal/driver/glfw.(*window).detectScale(0x4078f2f?)
	/pkg/mod/fyne.io/fyne/v2@v2.3.0/internal/driver/glfw/window_desktop.go:284 +0x35
fyne.io/fyne/v2/internal/driver/glfw.(*window).create.func3()
	/pkg/mod/fyne.io/fyne/v2@v2.3.0/internal/driver/glfw/window_desktop.go:722 +0x385
fyne.io/fyne/v2/internal/driver/glfw.runOnMain(0xc000473c60)
	/pkg/mod/fyne.io/fyne/v2@v2.3.0/internal/driver/glfw/loop.go:61 +0x129
fyne.io/fyne/v2/internal/driver/glfw.(*window).create(0xc000532000)
	/pkg/mod/fyne.io/fyne/v2@v2.3.0/internal/driver/glfw/window_desktop.go:705 +0xee
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).SetSystemTrayMenu.func1()
	/pkg/mod/fyne.io/fyne/v2@v2.3.0/internal/driver/glfw/driver_desktop.go:53 +0xe9
sync.(*Once).doSlow(0x400d71d?, 0x45c4140?)
	/usr/local/opt/go/libexec/src/sync/once.go:68 +0xc2
sync.(*Once).Do(...)
	/usr/local/opt/go/libexec/src/sync/once.go:59
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).SetSystemTrayMenu(0xc000500000?, 0xc0000ac150?)
	/pkg/mod/fyne.io/fyne/v2@v2.3.0/internal/driver/glfw/driver_desktop.go:35 +0x5f
fyne.io/fyne/v2/app.(*fyneApp).SetSystemTrayMenu(0x464aa91?, 0xc?)
	/pkg/mod/fyne.io/fyne/v2@v2.3.0/app/app_desktop_darwin.go:30 +0x42
main.makeTray({0x4757db0?, 0xc00050a000?}, 0x0)
	/cmd/02Playground/main.go:44 +0x22b
main.main()
	/cmd/02Playground/main.go:19 +0x6e

How to reproduce

// build the attached code
// go build -o test main.go
// run it with
while true; do  ./test; done
// close the lid, should crash after a few seconds

Screenshots

No response

Example code

package main

import (
	"fmt"
	"log"
	"time"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/driver/desktop"
	"fyne.io/fyne/v2/theme"
)

func main() {
	time.Sleep(1 * time.Second)
	a := app.NewWithID("io.fyne.demo")
	a.SetIcon(theme.FyneLogo())

	makeTray(a, 0)
	go func() {
		for i := 1; ; i++ {
			time.Sleep(1 * time.Second)
			makeTray(a, i)
			if i == 5 {
				log.Println("quit")
				a.Quit()
				log.Println("return")
				return
			}
		}
	}()
	a.Run()
}

func makeTray(a fyne.App, i int) {
	if desk, ok := a.(desktop.App); ok {
		showInfoMenuItem := fyne.NewMenuItem(fmt.Sprintf("Print %d...", i), func() {})
		showInfoMenuItem.Action = func() {
			log.Println(fmt.Sprintf("iteration %d", i))
		}

		items := []*fyne.MenuItem{showInfoMenuItem}
		menu := fyne.NewMenu(fmt.Sprintf("Iteration %d", i), items...)
		desk.SetSystemTrayMenu(menu)
	}
}

Fyne version

2.3.0

Go compiler version

1.19.2

Operating system

macOS

Operating system version

13.2

Additional Information

No response

@d1ss0nanz d1ss0nanz added the unverified A bug that has been reported but not verified label Jan 27, 2023
@dweymouth
Copy link
Contributor

dweymouth commented Jan 27, 2023

I have run into a very similar but intermittent crash on an M1 macbook with an external screen connected. I'm not sure if it's the M1 chip or the multiple monitors but I haven't seen this crash on my older x86_64 macbook using just the built-in screen

andydotxyz added a commit to andydotxyz/fyne that referenced this issue Jan 28, 2023

Verified

This commit was signed with the committer’s verified signature. The key has expired.
chrischdi Christian Schlotter
Seems this can happen when display asleep or working through VNC etc.
Fixes fyne-io#3609, fyne-io#2972
andydotxyz added a commit to andydotxyz/fyne that referenced this issue Jan 28, 2023
Seems this can happen when display asleep or working through VNC etc.
Fixes fyne-io#3609, fyne-io#2972
@andydotxyz
Copy link
Member

Fixed on develop ready for next release

@andydotxyz andydotxyz added this to the Fixes (v2.3.x) milestone Feb 8, 2023
andydotxyz added a commit to andydotxyz/fyne that referenced this issue Feb 8, 2023
Seems this can happen when display asleep or working through VNC etc.
Fixes fyne-io#3609, fyne-io#2972
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unverified A bug that has been reported but not verified
Projects
None yet
Development

No branches or pull requests

3 participants