Open preze5 opened 3 years ago
Can you please run a debugger and see what is in block/wait state once ShowAndRun exits?
In theory once you reach that WriteTo
call all of the Fyne drivers have unloaded and the app should quit.
I added a loop which prints out running goroutines every 5 seconds after w.ShowAndRun() and the list stays the same:
1 @ 0x7ff6356a51d5 0x7ff635716985 0x7ff63577ca05 0x7ff635779aec 0x7ff635a8cd71 0x7ff635719c81
# 0x7ff635716984 syscall.Syscall6+0xc4 c:/go/src/runtime/syscall_windows.go:343
# 0x7ff63577ca04 syscall.getQueuedCompletionStatus+0xe4 c:/go/src/syscall/zsyscall_windows.go:826
# 0x7ff635779aeb syscall.GetQueuedCompletionStatus+0xab c:/go/src/syscall/syscall_windows.go:1226
# 0x7ff635a8cd70 github.com/fsnotify/fsnotify.(*Watcher).readEvents+0xb0 C:/work/go/pkg/mod/github.com/fsnotify/fsnotify@v1.4.9/windows.go:381
1 @ 0x7ff6356e64d6 0x7ff6356a8309 0x7ff6356a802b 0x7ff6359e329f 0x7ff635719c81
# 0x7ff6359e329e fyne.io/fyne/v2/internal/painter.SvgCacheMonitorTheme.func1+0x3e C:/work/go/pkg/mod/fyne.io/fyne/v2@v2.0.3/internal/painter/svg_cache.go:109
1 @ 0x7ff6356e64d6 0x7ff6356a8309 0x7ff6356a802b 0x7ff635a0f38f 0x7ff635719c81
# 0x7ff635a0f38e fyne.io/fyne/v2/data/binding.processItems+0x4e C:/work/go/pkg/mod/fyne.io/fyne/v2@v2.0.3/data/binding/queue.go:54
1 @ 0x7ff6356e64d6 0x7ff6356a8309 0x7ff6356a802b 0x7ff635a58fc5 0x7ff635719c81
# 0x7ff635a58fc4 fyne.io/fyne/v2/internal/driver/glfw.(*glCanvas).setupThemeListener.func1+0x44 C:/work/go/pkg/mod/fyne.io/fyne/v2@v2.0.3/internal/driver/glfw/canvas.go:495
1 @ 0x7ff6356e64d6 0x7ff6356a8309 0x7ff6356a802b 0x7ff635a933e8 0x7ff635719c81
# 0x7ff635a933e7 fyne.io/fyne/v2/app.newAppWithDriver.func1+0x47 C:/work/go/pkg/mod/fyne.io/fyne/v2@v2.0.3/app/app.go:120
1 @ 0x7ff6356e64d6 0x7ff6356a8309 0x7ff6356a806b 0x7ff635a93865 0x7ff635719c81
# 0x7ff635a93864 fyne.io/fyne/v2/app.watchFile.func1+0x64 C:/work/go/pkg/mod/fyne.io/fyne/v2@v2.0.3/app/settings_desktop.go:42
1 @ 0x7ff6356e64d6 0x7ff6356f6717 0x7ff635a0f786 0x7ff635719c81
# 0x7ff635a0f785 fyne.io/fyne/v2/data/binding.makeInfiniteQueue.func1+0x265 C:/work/go/pkg/mod/fyne.io/fyne/v2@v2.0.3/data/binding/queue.go:36
1 @ 0x7ff6356e64d6 0x7ff635716d05 0x7ff6359e3052 0x7ff635743302 0x7ff6357431af 0x7ff635719c81
# 0x7ff635716d04 time.Sleep+0xe4 c:/go/src/runtime/time.go:193
# 0x7ff6359e3051 fyne.io/fyne/v2/internal/painter.svgCacheJanitor.func1+0x51 C:/work/go/pkg/mod/fyne.io/fyne/v2@v2.0.3/internal/painter/svg_cache.go:57
# 0x7ff635743301 sync.(*Once).doSlow+0x121 c:/go/src/sync/once.go:68
# 0x7ff6357431ae sync.(*Once).Do+0x4e c:/go/src/sync/once.go:59
1 @ 0x7ff635713905 0x7ff6357fcd22 0x7ff6357fc905 0x7ff6357f7614 0x7ff635a94199 0x7ff6356e60d6 0x7ff635719c81
# 0x7ff635713904 runtime/pprof.runtime_goroutineProfileWithLabels+0x64 c:/go/src/runtime/mprof.go:716
# 0x7ff6357fcd21 runtime/pprof.writeRuntimeProfile+0x1a1 c:/go/src/runtime/pprof/pprof.go:724
# 0x7ff6357fc904 runtime/pprof.writeGoroutine+0xc4 c:/go/src/runtime/pprof/pprof.go:684
# 0x7ff6357f7613 runtime/pprof.(*Profile).WriteTo+0xb3 c:/go/src/runtime/pprof/pprof.go:331
# 0x7ff635a94198 main.main+0x318 c:/work/go/fyne/main.go:39
# 0x7ff6356e60d5 runtime.main+0x215 c:/go/src/runtime/proc.go:225
It also aligns with what I see in dlv - to sum up the following functions related to fyne are in the constant running state: fyne.io/fyne/v2/data/binding.makeInfiniteQueue.func1 fyne.io/fyne/v2/app.watchFile.func1 fyne.io/fyne/v2/app.newAppWithDriver.func1 fyne.io/fyne/v2/internal/driver/glfw.(*glCanvas).setupThemeListener.func1+ fyne.io/fyne/v2/data/binding.processItems fyne.io/fyne/v2/internal/painter.SvgCacheMonitorTheme.func1 There is also a thread in time.Sleep from fyne.io/fyne/v2/internal/painter.svgCacheJanitor.func1
Does it answer your question?
Does it answer your question?
Hmm, not really - none of them are in a blocking state it seems. It should only be the main()
goroutine that can keep the app open when running, all of the others should close automatically... That is what happens on all other platforms so I'm not sure how Windows 8 would be different.
I've noticed in my environment (Fyne 2.0.3 / Go 1.16 / Arch Linux / X11) the close button in the top right corner of the window often does not close the application (both my own applications and the Fyne demo), it just causes it to hang (still displaying the window). This seems to occur randomly. I have found a reliable workaround however, which hopefully will shed some light on the source of the bug.
mainWindow.SetCloseIntercept(func() {
myApp.Quit()
})
If you are able to see if any goroutines are blocking after you ask the window to close that could be helpful. Or see where processor is still being used as we could be in a non-blocking loop somewhere.
One thought I had is that it could be a deadlock due to an attempt to get a Lock
on a mutex that's already locked. I tried to trace though the code path that interacts with the close intercept callback and saw a number of locks but didn't find anything that supported that theory. It just feels like it's locked indefinitely.
I'll see if I can get more useful output on Go's internal state at that point when I can.
I'll see if I can get more useful output on Go's internal state at that point when I can.
Thanks :)
I spoke too soon, my snippet is not a 100% fix, but it reduces the hang from 50% of the time to 0.1% of the time. And now I'm occasionally getting segfault panics at close (very rare). I'm not sure if they are related to this underlying issue, or to my "fix".
Here's one of the traces. I don't have any insights to offer on it yet but posting now in case it's helpful.
Make sure you are working on develop
branch as it's possible that SEGV was fixed already.
Is this still an issue on the latest releases?
I haven't noticed anything in a while for what it's worth, but I can't say for sure that means it's resolved.
The issue is still there at least in my case but I think I found the workaround/root cause. The issue in my case happens on VMWare guest system (Windows 8.1). The graphic driver used is VMWare Virtual SVGA 3D Graphics Adapter. The driver used is coming from VMWare, version 8.17.2.1. I moved my compiled binary to another VMWare guest system, but this time it was Windows 10. The driver was the same, just different version: 8.16.7.8. There it failed throwing an exception: APIUnavailable, the driver does not appear to support OpenGL. So what I did is used Mesa drivers with OpenGL software renderer. It then worked on Windows 10. So I also copied over the Mesa drivers back to Windows 8.1. Same binary, just with Mesa opengl driver in the same directory - all works flawlessly. So to sum-up - in my case it seems there is some bug in VMWare SVGA 3D Graphics driver which caused this issue. If anyone hits it in the future I would first recommend checking if all works well with software renderer.
As a data point I am getting this segfault when closing a window (Sonoma 14.7) with Fyne 2.5.1 pretty often.
As a data point I am getting this segfault when closing a window (Sonoma 14.7) with Fyne 2.5.1 pretty often.
This issue is not about a segfault. Please open a new issue.
Describe the bug:
Fyne application "hangs" or to be precise: doesn't terminate after first window is closed. After running "my first app": https://developer.fyne.io/started/firstapp and clicking at any point in time an X button in upper right corner, the window closes, but application keeps running. I know that my environment is specific (windows 8.1) but unfortunately I'm obliged to use it. I would greatly appreciate any help with debugging. As mentioned below I tried to change go version, gcc compiler version, fyne version, but it doesn't help.
To Reproduce:
1 @ 0x7ff70baeeb9a 0x7ff70bab7e5a 0x7ff70bab7a8b 0x7ff70bcf281b 0x7ff70bb1fc61
0x7ff70bcf281a fyne.io/fyne/v2/internal/painter.SvgCacheMonitorTheme.func1+0x3a C:/work/go/pkg/mod/fyne.io/fyne/v2@v2.0.3/internal/painter/svg_cache.go:109
1 @ 0x7ff70baeeb9a 0x7ff70bab7e5a 0x7ff70bab7a8b 0x7ff70bd1886b 0x7ff70bb1fc61
0x7ff70bd1886a fyne.io/fyne/v2/data/binding.processItems+0x4a C:/work/go/pkg/mod/fyne.io/fyne/v2@v2.0.3/data/binding/queue.go:54
1 @ 0x7ff70baeeb9a 0x7ff70bab7e5a 0x7ff70bab7a8b 0x7ff70bd4d08e 0x7ff70bb1fc61
0x7ff70bd4d08d fyne.io/fyne/v2/internal/driver/glfw.(*glCanvas).setupThemeListener.func1+0x4d C:/work/go/pkg/mod/fyne.io/fyne/v2@v2.0.3/internal/driver/glfw/canvas.go:495
1 @ 0x7ff70baeeb9a 0x7ff70bab7e5a 0x7ff70bab7a8b 0x7ff70bd7e065 0x7ff70bb1fc61
0x7ff70bd7e064 fyne.io/fyne/v2/app.newAppWithDriver.func1+0x44 C:/work/go/pkg/mod/fyne.io/fyne/v2@v2.0.3/app/app.go:120
1 @ 0x7ff70baeeb9a 0x7ff70bab7e5a 0x7ff70bab7acb 0x7ff70bd7e49f 0x7ff70bb1fc61
0x7ff70bd7e49e fyne.io/fyne/v2/app.watchFile.func1+0x5e C:/work/go/pkg/mod/fyne.io/fyne/v2@v2.0.3/app/settings_desktop.go:42
1 @ 0x7ff70baeeb9a 0x7ff70bafe368 0x7ff70bd18a45 0x7ff70bb1fc61
0x7ff70bd18a44 fyne.io/fyne/v2/data/binding.makeInfiniteQueue.func1+0x164 C:/work/go/pkg/mod/fyne.io/fyne/v2@v2.0.3/data/binding/queue.go:36
1 @ 0x7ff70baeeb9a 0x7ff70bb1cca5 0x7ff70bcf26dd 0x7ff70bb2bf37 0x7ff70bb2be2c 0x7ff70bb1fc61
0x7ff70bb1cca4 time.Sleep+0xe4 c:/go/src/runtime/time.go:193
0x7ff70bcf26dc fyne.io/fyne/v2/internal/painter.svgCacheJanitor.func1+0x11c C:/work/go/pkg/mod/fyne.io/fyne/v2@v2.0.3/internal/painter/svg_cache.go:57
0x7ff70bb2bf36 sync.(*Once).doSlow+0xf6 c:/go/src/sync/once.go:68
0x7ff70bb2be2b sync.(*Once).Do+0x4b c:/go/src/sync/once.go:59
1 @ 0x7ff70bb19685 0x7ff70bbb86b5 0x7ff70bbb8467 0x7ff70bbb4f38 0x7ff70bd7eb9d 0x7ff70baee776 0x7ff70bb1fc61
0x7ff70bb19684 runtime/pprof.runtime_goroutineProfileWithLabels+0x64 c:/go/src/runtime/mprof.go:716
0x7ff70bbb86b4 runtime/pprof.writeRuntimeProfile+0xd4 c:/go/src/runtime/pprof/pprof.go:724
0x7ff70bbb8466 runtime/pprof.writeGoroutine+0xa6 c:/go/src/runtime/pprof/pprof.go:684
0x7ff70bbb4f37 runtime/pprof.(*Profile).WriteTo+0x3f7 c:/go/src/runtime/pprof/pprof.go:331
0x7ff70bd7eb9c main.main+0x2bc C:/work/go/fyne/main.go:35
0x7ff70baee775 runtime.main+0x255 c:/go/src/runtime/proc.go:225
-->
Device (please complete the following information):