fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
25.08k stars 1.39k forks source link

SIGSEGV: Fyne v2.0.4 on Pop OS panics using README example #2399

Open brittonhayes opened 3 years ago

brittonhayes commented 3 years ago

Describe the bug:

When attempting to run the example code from the readme, the fyne application panics. This appears to occur when it attempts to run the CreateWindow function from glfw which I believe is called by ShowAndRun().

To Reproduce:

  1. Run example code from README.md
  2. View panic when calling glfw CreateWindow

The code that panics from fyne/internal/driver:

https://github.com/fyne-io/fyne/blob/1f05de7da27eaaf9dbf358ebe235ea306864ce76/internal/driver/glfw/window.go#L1330-L1334

Screenshots:

image

Example code:

package main

// Here I import fyne/v2 as demonstrated in the demo

import (
    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/container"
    "fyne.io/fyne/v2/widget"
)

func main() {
    a := app.New()
    w := a.NewWindow("Hello")

    hello := widget.NewLabel("Hello Fyne!")
    w.SetContent(container.NewVBox(
        hello,
        widget.NewButton("Hi!", func() {
            hello.SetText("Welcome :)")
        }),
    ))

    w.ShowAndRun()
}

Device (please complete the following information):

image

Additional Context

andydotxyz commented 3 years ago

Linux crashes seem to be caused by the graphics environment, either window manager or X setup. Please can you confirm:

Your window manager / desktop environment. Is this a local X server and is there any special connection or configuration information?

brittonhayes commented 3 years ago

Hey Andy! Thanks for the quick reply.

This is on a System 76 oryx pro laptop running vanilla pop os.

No tweaks to the window manager aside from what comes default installed.

Do you think this could be a conflict with the default pop os tiling window manager?

I've run the same code on a MacBook and obviously don't run into the same issue so I do believe it's clearly Linux/PopOS specific rather than anything to do with 2.0.4 on other OS's.

Is there any further info I can provide that might help diagnose what's up?

andydotxyz commented 3 years ago

Yes, we seem to have issues with some tiling window managers as they can draw windows below the specified minimum size.

For those of us not familiar with PopOS is their window manager installable on other platforms so we can test in more standard distributions?

brittonhayes commented 3 years ago

Yeah absolutely! I believe the window manager is available within the pop shell here.

https://github.com/pop-os/shell

Here's an article about installing the shell on other distros too.

https://www.linuxuprising.com/2020/05/how-to-install-pop-shell-tiling.html?m=1

vurguuz commented 3 years ago

I have the same crash on MacOS Big Sur 11.5.2. Reproduced by running fyne_demo and resizing the window on the Table page.

fatal error: unexpected signal during runtime execution

[signal SIGSEGV: segmentation violation code=0x2 addr=0x10 pc=0x18b1c3240]

runtime stack:
runtime.throw(0x10282d702, 0x2a)
        /opt/homebrew/Cellar/go/1.16.6/libexec/src/runtime/panic.go:1117 +0x54
runtime.sigpanic()
        /opt/homebrew/Cellar/go/1.16.6/libexec/src/runtime/signal_unix.go:718 +0x29c

goroutine 18 [syscall, locked to thread]:
runtime.cgocall(0x102807180, 0x140001edd28, 0x14048008000)
        /opt/homebrew/Cellar/go/1.16.6/libexec/src/runtime/cgocall.go:154 +0x50 fp=0x140001edcf0 sp=0x140001edcb0 pc=0x102522140
github.com/go-gl/gl/v3.2-core/gl._Cfunc_glowClear(0x1cd5e65f4, 0x3e4243c500004100)
        _cgo_gotypes.go:3663 +0x40 fp=0x140001edd20 sp=0x140001edcf0 pc=0x10271a9d0
github.com/go-gl/gl/v3.2-core/gl.Clear(...)
        /Users/vurguuz/go/pkg/mod/github.com/go-gl/gl@v0.0.0-20190320180904-bf2b1f2f34d7/v3.2-core/gl/package.go:8667
fyne.io/fyne/v2/internal/painter/gl.(*glPainter).glClearBuffer(0x140000bcd20)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/painter/gl/gl_core.go:188 +0xd8 fp=0x140001edd50 sp=0x140001edd20 pc=0x10273f1e8
fyne.io/fyne/v2/internal/painter/gl.(*glPainter).Clear(0x140000bcd20)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/painter/gl/painter.go:53 +0x28 fp=0x140001edd70 sp=0x140001edd50 pc=0x10273f9e8
fyne.io/fyne/v2/internal/driver/glfw.(*glCanvas).paint(0x14000410100, 0x443ec00044b14000)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/driver/glfw/canvas.go:431 +0x68 fp=0x140001eddf0 sp=0x140001edd70 pc=0x10278c648
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).repaintWindow.func1()
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/driver/glfw/loop.go:164 +0x70 fp=0x140001ede50 sp=0x140001eddf0 pc=0x102798f70
fyne.io/fyne/v2/internal/driver/glfw.(*window).RunWithContext(0x140001d4540, 0x140001ede90)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/driver/glfw/window.go:1207 +0x50 fp=0x140001ede70 sp=0x140001ede50 pc=0x1027967f0
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).repaintWindow(0x1400018a6e0, 0x140001d4540)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/driver/glfw/loop.go:155 +0x50 fp=0x140001edeb0 sp=0x140001ede70 pc=0x10278ec40
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).startDrawThread.func1(0x1400018a6e0, 0x1400018c720, 0x1400018a780)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/driver/glfw/loop.go:211 +0x278 fp=0x140001edfc0 sp=0x140001edeb0 pc=0x102799318
runtime.goexit()
        /opt/homebrew/Cellar/go/1.16.6/libexec/src/runtime/asm_arm64.s:1130 +0x4 fp=0x140001edfc0 sp=0x140001edfc0 pc=0x102583954
created by fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).startDrawThread
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/driver/glfw/loop.go:182 +0xac

goroutine 1 [chan send, locked to thread]:
fyne.io/fyne/v2/internal/driver/glfw.runOnDraw(...)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/driver/glfw/loop.go:64
fyne.io/fyne/v2/internal/driver/glfw.(*window).platformResize(0x140001d4540, 0x443ec00044b12000)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/driver/glfw/window_notlinux.go:14 +0x100
fyne.io/fyne/v2/internal/driver/glfw.(*window).resized(0x140001d4540, 0x1400046a000, 0x589, 0x2fb)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/driver/glfw/window.go:553 +0xa0
github.com/go-gl/glfw/v3.3/glfw.goWindowSizeCB(0x10d705af0, 0x2fb00000589)
        /Users/vurguuz/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20210410170116-ea3d685f79fb/window.go:213 +0x58
github.com/go-gl/glfw/v3.3/glfw._Cfunc_glfwPollEvents()
        _cgo_gotypes.go:1474 +0x40
github.com/go-gl/glfw/v3.3/glfw.PollEvents()
        /Users/vurguuz/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20210410170116-ea3d685f79fb/window.go:949 +0x20
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).tryPollEvents(0x1400018a6e0)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/driver/glfw/loop.go:225 +0x3c
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).runGL(0x1400018a6e0)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/driver/glfw/loop.go:102 +0x1b4
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).Run(0x1400018a6e0)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/driver/glfw/driver.go:80 +0x38
fyne.io/fyne/v2/internal/driver/glfw.(*window).ShowAndRun(0x140001d4540)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/driver/glfw/window.go:449 +0x38
main.main()
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/cmd/fyne_demo/main.go:129 +0xcb4

goroutine 6 [sleep]:
time.Sleep(0x22ecb25c00)
        /opt/homebrew/Cellar/go/1.16.6/libexec/src/runtime/time.go:193 +0xc4
fyne.io/fyne/v2/internal/painter.svgCacheJanitor.func1()
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/painter/svg_cache.go:57 +0xe0
sync.(*Once).doSlow(0x102e8d030, 0x14000024d70)
        /opt/homebrew/Cellar/go/1.16.6/libexec/src/sync/once.go:68 +0x120
sync.(*Once).Do(0x102e8d030, 0x14000024d70)
        /opt/homebrew/Cellar/go/1.16.6/libexec/src/sync/once.go:59 +0x44
created by fyne.io/fyne/v2/internal/painter.svgCacheJanitor
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/painter/svg_cache.go:55 +0x9c

goroutine 7 [select]:
fyne.io/fyne/v2/data/binding.makeInfiniteQueue.func1(0x1400018c0c0, 0x140000100c8)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/data/binding/queue.go:36 +0xf8
created by fyne.io/fyne/v2/data/binding.makeInfiniteQueue
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/data/binding/queue.go:21 +0xa0

goroutine 8 [chan receive]:
fyne.io/fyne/v2/data/binding.processItems()
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/data/binding/queue.go:54 +0x3c
created by fyne.io/fyne/v2/data/binding.init.0
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/data/binding/queue.go:15 +0x30

goroutine 9 [chan receive]:
fyne.io/fyne/v2/test.NewApp.func1(0x1400018c360, 0x1400040a070)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/test/testapp.go:104 +0x3c
created by fyne.io/fyne/v2/test.NewApp
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/test/testapp.go:102 +0x200

goroutine 10 [syscall]:
syscall.syscall6(0x1027b22e0, 0x6, 0x0, 0x0, 0x1400011ae88, 0xa, 0x102e8d120, 0x0, 0x0, 0x0)
        /opt/homebrew/Cellar/go/1.16.6/libexec/src/runtime/sys_darwin.go:41 +0x1c
golang.org/x/sys/unix.kevent(0x6, 0x0, 0x0, 0x1400011ae88, 0xa, 0x102e8d120, 0x0, 0x0, 0x0)
        /Users/vurguuz/go/pkg/mod/golang.org/x/sys@v0.0.0-20200720211630-cb9d2d5c5666/unix/zsyscall_darwin_arm64.go:292 +0x80
golang.org/x/sys/unix.Kevent(0x6, 0x0, 0x0, 0x0, 0x1400011ae88, 0xa, 0xa, 0x102e8d120, 0x1400018c540, 0x0, ...)
        /Users/vurguuz/go/pkg/mod/golang.org/x/sys@v0.0.0-20200720211630-cb9d2d5c5666/unix/syscall_bsd.go:413 +0x60
github.com/fsnotify/fsnotify.read(0x6, 0x1400011ae88, 0xa, 0xa, 0x102e8d120, 0x1400011ae88, 0x0, 0xa, 0x0, 0x0)
        /Users/vurguuz/go/pkg/mod/github.com/fsnotify/fsnotify@v1.4.9/kqueue.go:511 +0x50
github.com/fsnotify/fsnotify.(*Watcher).readEvents(0x14000078a20)
        /Users/vurguuz/go/pkg/mod/github.com/fsnotify/fsnotify@v1.4.9/kqueue.go:274 +0x76c
created by github.com/fsnotify/fsnotify.NewWatcher
        /Users/vurguuz/go/pkg/mod/github.com/fsnotify/fsnotify@v1.4.9/kqueue.go:62 +0x15c

goroutine 11 [chan receive]:
fyne.io/fyne/v2/app.watchFile.func1(0x14000078a20, 0x14000032320, 0x45, 0x14000021f00, 0x14000021f10)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/app/settings_desktop.go:42 +0x48
created by fyne.io/fyne/v2/app.watchFile
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/app/settings_desktop.go:41 +0xd4

goroutine 14 [chan receive]:
fyne.io/fyne/v2/app.newAppWithDriver.func1(0x1400018c5a0, 0x1400040a0e0)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/app/app.go:120 +0x34
created by fyne.io/fyne/v2/app.newAppWithDriver
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/app/app.go:118 +0x1bc

goroutine 15 [syscall]:
syscall.syscall6(0x1027b22e0, 0x9, 0x0, 0x0, 0x1400004c688, 0xa, 0x102e8d120, 0x0, 0x0, 0x0)
        /opt/homebrew/Cellar/go/1.16.6/libexec/src/runtime/sys_darwin.go:41 +0x1c
golang.org/x/sys/unix.kevent(0x9, 0x0, 0x0, 0x1400004c688, 0xa, 0x102e8d120, 0x0, 0x0, 0x0)
        /Users/vurguuz/go/pkg/mod/golang.org/x/sys@v0.0.0-20200720211630-cb9d2d5c5666/unix/zsyscall_darwin_arm64.go:292 +0x80
golang.org/x/sys/unix.Kevent(0x9, 0x0, 0x0, 0x0, 0x1400004c688, 0xa, 0xa, 0x102e8d120, 0x1400018c6c0, 0x0, ...)
        /Users/vurguuz/go/pkg/mod/golang.org/x/sys@v0.0.0-20200720211630-cb9d2d5c5666/unix/syscall_bsd.go:413 +0x60
github.com/fsnotify/fsnotify.read(0x9, 0x1400004c688, 0xa, 0xa, 0x102e8d120, 0x1400004c688, 0x0, 0xa, 0x0, 0x0)
        /Users/vurguuz/go/pkg/mod/github.com/fsnotify/fsnotify@v1.4.9/kqueue.go:511 +0x50
github.com/fsnotify/fsnotify.(*Watcher).readEvents(0x14000078cc0)
        /Users/vurguuz/go/pkg/mod/github.com/fsnotify/fsnotify@v1.4.9/kqueue.go:274 +0x76c
created by github.com/fsnotify/fsnotify.NewWatcher
        /Users/vurguuz/go/pkg/mod/github.com/fsnotify/fsnotify@v1.4.9/kqueue.go:62 +0x15c

goroutine 16 [chan receive]:
fyne.io/fyne/v2/app.watchFile.func1(0x14000078cc0, 0x1400002d8c0, 0x35, 0x1400040e050, 0x1400040e060)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/app/settings_desktop.go:42 +0x48
created by fyne.io/fyne/v2/app.watchFile
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/app/settings_desktop.go:41 +0xd4

goroutine 19 [chan receive]:
fyne.io/fyne/v2/internal/driver/glfw.(*window).runEventQueue(0x140001d4540)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/driver/glfw/window.go:1267 +0x90
created by fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).createWindow.func1
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/driver/glfw/window.go:1292 +0xfc

goroutine 20 [chan receive]:
fyne.io/fyne/v2/internal/driver/glfw.(*glCanvas).setupThemeListener.func1(0x1400018c780, 0x14000410100)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/driver/glfw/canvas.go:495 +0x40
created by fyne.io/fyne/v2/internal/driver/glfw.(*glCanvas).setupThemeListener
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/driver/glfw/canvas.go:493 +0x94

goroutine 25 [chan receive]:
fyne.io/fyne/v2/internal/painter.SvgCacheMonitorTheme.func1(0x1400018c1e0)
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/painter/svg_cache.go:109 +0x2c
created by fyne.io/fyne/v2/internal/painter.SvgCacheMonitorTheme
        /Users/vurguuz/go/pkg/mod/fyne.io/fyne/v2@v2.0.4/internal/painter/svg_cache.go:107 +0x8c
exit status 2
andydotxyz commented 3 years ago

@vurguuz that is not the same crash. What you are reporting is #2188.

brittonhayes commented 3 years ago

Hey again @andydotxyz!

I've done some research on this over the past couple days and have found some exciting details on why this is happening. So the System 76 Oryx Laptop (my device running pop os), can run in two graphics modes: hybrid and nvidia. The hybrid dynamically selecting when to use the graphics card and the nvidia mode always using it for rendering.

I've noticed other people having Open GL issues when using hybrid mode so I booted the device into Nvidia-only mode. After doing this I ran a few different fyne demos and they all worked beautifully :smile:. So I'm all up and running here!

If you'd like to close this issue please feel free, as my problem is solved. But if you have another user come along using a system 76 device running pop with this issue, now I think this is a solid thing to have them try!

Thanks again for your assistance and I hope this is helpful!

andydotxyz commented 3 years ago

Thanks for this info. Is there any way we can signal to the GPU/OS that we require OpenGL so that hybrid mode does not crash? We have the same problem with Windows laptops and dual graphics setups (onboard vs GPU).

brittonhayes commented 3 years ago

That's a good question. I'm honestly not sure, that may require some more digging.

At the very least it looks like we can check for the presence/support of OpenGL with this function so the error can be handled and indicate to the user that open gl is a requirement.

https://github.com/go-gl/glfw/blob/0db043d8d5be/v3.2/glfw/context.go#L64-L78

andydotxyz commented 3 years ago

At the very least it looks like we can check for the presence/support of OpenGL with this function so the error can be handled and indicate to the user that open gl is a requirement.

This is a good idea - but I don't know what extension parameter could be specified to check that basic OpenGL is available.

joematune commented 10 months ago

Thanks @brittonhayes :+1:

Details on Pop OS graphics and guide to switching here: https://support.system76.com/articles/graphics-switch-pop/

andydotxyz commented 10 months ago

Thanks for that link, from what is written I wonder if the following tip fixes the issue at the user end?

GLX applications must be launched with this command to be rendered on the dGPU (NVIDIA):

__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia <application>