dweymouth / supersonic

A lightweight and full-featured cross-platform desktop client for self-hosted music servers
GNU General Public License v3.0
675 stars 26 forks source link

Random Crashing with 'Invalid scancode: 123' (v0.7.0) #281

Open freshgum-bubbles opened 7 months ago

freshgum-bubbles commented 7 months ago

Hiya,

I'm a frequent user of Supersonic, and am experiencing quite an annoying issue. Randomly, the client will crash (logs below); this typically happens when navigating around the UI. It seems to prefer being left alone.

I'm not really sure what the error means, but perhaps you can make sense of it. To summarize, it just says "Invalid scancode".

I downloaded Supersonic on Flatpak (v0.7.0).

System info.

➜  ~ uname -a
Linux localhost.localdomain 6.5.9-1-default #1 SMP PREEMPT_DYNAMIC Wed Oct 25 10:31:37 UTC 2023 (29edc7c) x86_64 x86_64 x86_64 GNU/Linux

Logs

plasmashell[9259]: 2023/11/14 00:14:34 Fyne error:  GLFW waitEvents error: InvalidValue: Invalid scancode 122
plasmashell[9259]: 2023/11/14 00:14:34   At: /run/build/supersonic/vendor/fyne.io/fyne/v2/internal/driver/glfw/loop_desktop.go:30
vsce-sign[9746]: SignatureIntegrityPolicy for timestamp signature succeeded.
vsce-sign[9746]: SignatureValidityPolicy for timestamp signature succeeded.
vsce-sign[9746]: X.509 certificate chain validation will use the fallback certificate bundle for timestamping.
vsce-sign[9746]: SignatureTrustPolicy for timestamp signature succeeded.
vsce-sign[9746]: X.509 certificate chain validation will use the fallback certificate bundle for code signing.
vsce-sign[9746]: SignatureTrustPolicy for primary signature succeeded.
vsce-sign[9746]: Primary signature type:  repository primary signature
vsce-sign[9746]: Primary signature status:  OK
vsce-sign[9746]: Timestamp signature status:  OK
vsce-sign[9746]: Exit code:  Success
kde.dataengine.mpris: "org.mpris.MediaPlayer2.Supersonic" has an invalid URL for the xesam:url entry of the "Metadata" property
kde.dataengine.mpris: "org.mpris.MediaPlayer2.Supersonic" has an invalid URL for the mpris:artUrl entry of the "Metadata" property
kde.dataengine.mpris: "org.mpris.MediaPlayer2.Supersonic" has an invalid URL for the xesam:url entry of the "Metadata" property
kde.dataengine.mpris: "org.mpris.MediaPlayer2.Supersonic" has an invalid URL for the xesam:url entry of the "Metadata" property
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=634a52fa7ca2c905356e2>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=b152995497d4476a01cc8>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=9c946acc19119f1e2a79a>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=56cabba41f177312c6f25>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=fbea3eb65ef53936e555c>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=25f73f3bccd0f2820a79b>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=77d54133a6e5561016420>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=d0b0b1ab44ef376b0a2d4>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=3e76893e8dc8b74176fa3>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=e693691c4ba673492e8c8>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=c8d3d488d9ae74b71a0bf>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=e7516b3af634b02f91089>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=802245687fd811bd5a2ee>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=c0957eecdb09d96be7fda>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=86bd28333003039226077>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=c0112e77deb3f84500a7b>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=d186de46fe2b48d1d1d89>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=7340605ddbddd50f51798>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=1b13e7783aa05ae396357>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=4a26a4c24501ac21598f2>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=dfd1c25b2536f005f70bd>
Adding playback URL: https://REDACTED/rest/stream?c=supersonic&f=xml&format=raw&id=3cc2c7ef2d22070f82135>
Fyne error:  GLFW waitEvents error: InvalidValue: Invalid scancode 123
  At: /run/build/supersonic/vendor/fyne.io/fyne/v2/internal/driver/glfw/loop_desktop.go:30
Fyne error:  GLFW waitEvents error: InvalidValue: Invalid scancode 123
  At: /run/build/supersonic/vendor/fyne.io/fyne/v2/internal/driver/glfw/loop_desktop.go:30
Fyne error:  GLFW waitEvents error: InvalidValue: Invalid scancode 123
  At: /run/build/supersonic/vendor/fyne.io/fyne/v2/internal/driver/glfw/loop_desktop.go:30

These were captured right after the client exited. If there's a way to capture additional debugging info, would be happy to send :-)

dweymouth commented 7 months ago

Thanks for the issue report - from the log it looks like a keyboard scancode unrecognized by the Go-GLFW windowing library is causing the crash. What keyboard layout or other input devices are you using? If you're able to find out a way to consistently reproduce this by pressing various keys or other input device buttons while the window is focused, and narrowing it down to a specific key/button that is causing this, it would be super helpful and then I can report it upstream to Fyne (the UI library) and probably further upstream to Go-GLFW as I think this is where the real root cause is.

I haven't run into any crashes like this myself, but I'm using a standard english-US keyboard layout.

freshgum-bubbles commented 7 months ago

What keyboard layout or other input devices are you using?

en-GB. It's a laptop keyboard with FnLock and no number pad.
image

It would be helpful if I could turn on some sort of debugging switch to get more information in the case of an error. I doubt the words "Invalid scancode" are particularly helpful.

I haven't found a way to reliably reproduce this yet, but it seems like there's a chance of it happening whenever you navigate across screens (so, say you're looking at an album, and then go to All Tracks.)

Just found another bug, seemingly a race condition in the search logic:

  1. Go to All Tracks, and focus the search bar
  2. Type in "park", Ctrl+A, and type it in again quickly
  3. The app reliably crashes

That results in...

error: Tracklist.trackModelAt: index out of range
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0xada02a]
goroutine 154 [running]:
github.com/dweymouth/supersonic/ui/widgets.(*TrackRow).Update(0xc003812f20, 0xc001989ea8?, 0xb)
        /run/build/supersonic/ui/widgets/tracklist.go:760 +0x2a
github.com/dweymouth/supersonic/ui/widgets.NewTracklist.func3(0xa, {0xe44500?, 0xc003812f20})
        /run/build/supersonic/ui/widgets/tracklist.go:151 +0x86
fyne.io/fyne/v2/widget.(*listLayout).setupListItem(0xc001dd1630, 0xc0000daee0, 0xa, 0x18?)
        /run/build/supersonic/vendor/fyne.io/fyne/v2/widget/list.go:611 +0xc6
fyne.io/fyne/v2/widget.(*listLayout).updateList(0xc001dd1630, 0x0)
        /run/build/supersonic/vendor/fyne.io/fyne/v2/widget/list.go:698 +0x67b
fyne.io/fyne/v2/widget.(*List).Resize(0xc0030bca80, {0x0?, 0x0?})
        /run/build/supersonic/vendor/fyne.io/fyne/v2/widget/list.go:190 +0x7d
fyne.io/fyne/v2/layout.(*borderLayout).Layout(0xc001a05f40, {0xc001cbd980, 0x2, 0xc000db6600?}, {0x21ccb00?, 0xc0?})
        /run/build/supersonic/vendor/fyne.io/fyne/v2/layout/borderlayout.go:61 +0x4f3
fyne.io/fyne/v2.(*Container).layout(...)
        /run/build/supersonic/vendor/fyne.io/fyne/v2/container.go:195
fyne.io/fyne/v2.(*Container).Refresh(0xc001dd1450)
        /run/build/supersonic/vendor/fyne.io/fyne/v2/container.go:114 +0x47
fyne.io/fyne/v2/internal/widget.(*SimpleRenderer).Refresh(0xe468e0?)
        /run/build/supersonic/vendor/fyne.io/fyne/v2/internal/widget/simple_renderer.go:64 +0x25
fyne.io/fyne/v2/widget.(*BaseWidget).Refresh(0xc000db6600?)
        /run/build/supersonic/vendor/fyne.io/fyne/v2/widget/widget.go:139 +0x26
github.com/dweymouth/supersonic/ui/widgets.(*Tracklist).Refresh(...)
        /run/build/supersonic/ui/widgets/tracklist.go:364
github.com/dweymouth/supersonic/ui/widgets.(*TracklistLoader).loadMoreTracks(0xc001dd14a0, 0x19)
        /run/build/supersonic/ui/widgets/tracklistloader.go:71 +0x54
created by github.com/dweymouth/supersonic/ui/widgets.NewTracklistLoader in goroutine 153
        /run/build/supersonic/ui/widgets/tracklistloader.go:29 +0x187

Could open a separate issue to track that if you like, though it is arguably relevant here.

dweymouth commented 7 months ago

I will create a second issue for the searching tracks crash, as that one should be a pretty quick fix and I had fixed a similar race condition crash on the searchable album grids. The "invalid scancode" issue will take more time to track down especially since the issue doesn't originate from Supersonic's codebase, but from go-glfw. You can see here where Fyne captures and logs out the panic, but it's really coming from glfw.PollEvents. I tried looking up what scancode 123 is but found nothing conclusive.

freshgum-bubbles commented 7 months ago

Hey, thanks for creating the issue, and... wow, that was an amazingly quick fix :D

The only real info I've found re: "invalid scancode" is that a small subset of people experience it, and the developers don't seem to know what's going on (investigated their GH issues.)

Without any (useful) debugging info from Fyne, I feel like I'm clutching at straws re: how to figure out what's causing this, and how to remedy it. I did try the Fyne demo app, and it seemed happy with my keyboard. I'm happy to help and follow any instructions you might have.

...all this, and from my small understanding of Go, it seems like an invalid scancode shouldn't result in termination of the app -- from investigating the Fyne source tree, it seems that it just logs an error to the console, and is happy to continue.

Anyway, I'll do a bit more digging and maybe I'll come up with something.
I'll test 0.8.0 (perhaps that fixed the issue?) and report back...

dweymouth commented 7 months ago

I think what's happening is that even though Fyne catches and logs that error, the GLFW eventing system itself can't recover from it, so afterwards Fyne never receives any more input events from GLFW. Not sure I have much more helpful info, sorry

dweymouth commented 2 weeks ago

I am guessing this could potentially be resolved since the latest release uses the latest version of the Fyne UI library which itself uses the latest release of GLFW. Can you confirm if this still happens with 0.11.0?