Skip to content
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

Creating a windows inside onClose handler causes Fyne to panic. #1106

Closed
ababo opened this issue Jun 15, 2020 · 12 comments
Closed

Creating a windows inside onClose handler causes Fyne to panic. #1106

ababo opened this issue Jun 15, 2020 · 12 comments
Labels
bug Something isn't working
Milestone

Comments

@ababo
Copy link

ababo commented Jun 15, 2020

Indeed I have encountered that while trying to workaround a missing WillClose() handler (needed to prevent closing the window, so I tried to reopen it again). So when I try to create a window within the handler I get:

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

goroutine 1 [running, locked to thread]:
github.com/go-gl/glfw/v3.3/glfw.(*Window).Focus.func1(0x0)
	/Users/ababo/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20200222043503-6f7a984d4dc4/window.go:607 +0x22
github.com/go-gl/glfw/v3.3/glfw.(*Window).Focus(0x0)
	/Users/ababo/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20200222043503-6f7a984d4dc4/window.go:607 +0x2b
fyne.io/fyne/internal/driver/glfw.(*window).create.func3()
	/Users/ababo/go/pkg/mod/fyne.io/fyne@v1.3.0/internal/driver/glfw/window.go:1172 +0x3f5
fyne.io/fyne/internal/driver/glfw.(*gLDriver).runGL(0xc000031b80)
	/Users/ababo/go/pkg/mod/fyne.io/fyne@v1.3.0/internal/driver/glfw/loop.go:96 +0x59b
fyne.io/fyne/internal/driver/glfw.(*gLDriver).Run(0xc000031b80)
	/Users/ababo/go/pkg/mod/fyne.io/fyne@v1.3.0/internal/driver/glfw/driver.go:70 +0x37
fyne.io/fyne/app.(*fyneApp).Run(0xc0000723c0)
	/Users/ababo/go/pkg/mod/fyne.io/fyne@v1.3.0/app/app.go:57 +0x93
main.main()

Reproduced on OSX 10.15.5 with Go 1.14.1.

@andydotxyz
Copy link
Member

Can you please share the code that you are using to cause this panic?

@andydotxyz andydotxyz added bug Something isn't working question A question has been asked labels Jun 15, 2020
@ababo
Copy link
Author

ababo commented Jun 15, 2020

Fairly simple: win.SetOnClosed(func() { app.NewWindow("title").Show() })

@andydotxyz
Copy link
Member

Thanks. I guess that this is the only window visible at the time?
I can replicate it under those circumstances as the creation of a new window is happening after the app realises it should quit.

I can fix the crash, but I will have to think about how this could be supported. It's a bit troublesome and #467 is probably tracking the right way to do this.

In the meantime you can add time.Sleep(time.Second) after Window.Show() - it will not delay your application but it will stop the shutdown of the app long enough to realise that there is now another window...

@andydotxyz andydotxyz removed the question A question has been asked label Jun 15, 2020
@andydotxyz
Copy link
Member

This patch fixes the panic, though it does not change the overall behaviour - for that we need #467 .
Feel free to test the patch :)

@andydotxyz
Copy link
Member

The patch is landed on develop for testing, will be in 1.3.1 at some point.
The bigger picture issue is tracked in #467 but with the timer workaround you should be OK.

@andydotxyz andydotxyz added this to the 1.3.x milestone Jun 16, 2020
@ababo
Copy link
Author

ababo commented Jun 23, 2020

The issue still persists on v1.3.1-0.20200622224053-33c346cb13d6.

@andydotxyz
Copy link
Member

Can you please post the revised panic stack trace? I can no longer replicate it here...

@ababo
Copy link
Author

ababo commented Jun 23, 2020

	/usr/local/Cellar/go/1.14.1/libexec/src/runtime/panic.go:967 +0x166
github.com/go-gl/glfw/v3.3/glfw.(*Window).Focus.func1(0x0)
	/Users/ababo/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20200222043503-6f7a984d4dc4/window.go:607 +0x22
github.com/go-gl/glfw/v3.3/glfw.(*Window).Focus(0x0)
	/Users/ababo/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20200222043503-6f7a984d4dc4/window.go:607 +0x2b
fyne.io/fyne/internal/driver/glfw.(*window).create.func3()
	/Users/ababo/go/pkg/mod/fyne.io/fyne@v1.3.0/internal/driver/glfw/window.go:1172 +0x3f5
fyne.io/fyne/internal/driver/glfw.(*gLDriver).runGL(0xc00002f540)
	/Users/ababo/go/pkg/mod/fyne.io/fyne@v1.3.0/internal/driver/glfw/loop.go:96 +0x59b
fyne.io/fyne/internal/driver/glfw.(*gLDriver).Run(0xc00002f540)
	/Users/ababo/go/pkg/mod/fyne.io/fyne@v1.3.0/internal/driver/glfw/driver.go:70 +0x37
fyne.io/fyne/app.(*fyneApp).Run(0xc000078240)

@andydotxyz
Copy link
Member

That is still using the v1.3.0 release

@ababo
Copy link
Author

ababo commented Jun 23, 2020

oh, sorry, will redo

@ababo
Copy link
Author

ababo commented Jun 23, 2020

/usr/local/Cellar/go/1.14.1/libexec/src/runtime/panic.go:967 +0x166
github.com/go-gl/glfw/v3.3/glfw.(*Window).Focus.func1(0x0)
	/Users/ababo/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20200222043503-6f7a984d4dc4/window.go:607 +0x22
github.com/go-gl/glfw/v3.3/glfw.(*Window).Focus(0x0)
	/Users/ababo/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20200222043503-6f7a984d4dc4/window.go:607 +0x2b
fyne.io/fyne/internal/driver/glfw.(*window).create.func3()
	/Users/ababo/go/pkg/mod/fyne.io/fyne@v1.3.1-0.20200622224053-33c346cb13d6/internal/driver/glfw/window.go:1177 +0x3f5
fyne.io/fyne/internal/driver/glfw.(*gLDriver).runGL(0xc00002f500)
	/Users/ababo/go/pkg/mod/fyne.io/fyne@v1.3.1-0.20200622224053-33c346cb13d6/internal/driver/glfw/loop.go:96 +0x5b8
fyne.io/fyne/internal/driver/glfw.(*gLDriver).Run(0xc00002f500)
	/Users/ababo/go/pkg/mod/fyne.io/fyne@v1.3.1-0.20200622224053-33c346cb13d6/internal/driver/glfw/driver.go:70 +0x37
fyne.io/fyne/app.(*fyneApp).Run(0xc000070240)
	/Users/ababo/go/pkg/mod/fyne.io/fyne@v1.3.1-0.20200622224053-33c346cb13d6/app/app.go:57 +0x93

@andydotxyz
Copy link
Member

Ah yes, it turns out I missed a fine in my commit sorry - there is a more complete solution in PR #1133

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants