nwg-piotr / nwg-dock

GTK3-based dock for sway
MIT License
170 stars 9 forks source link

nwg-dock crashes if a floating window is split in sway; references compile-time directory #35

Closed lilacpixel closed 1 year ago

lilacpixel commented 1 year ago

Describe the bug If a floating window is split horizontally or vertically, nwg-dock crashes with the following output:

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

goroutine 35 [running]:
main.createTask(...)
    /home/cari/Downloads/nwg-dock/tools.go:235
main.listTasks()
    /home/cari/Downloads/nwg-dock/tools.go:209 +0xc79
main.getTaskChangesChannel.func2()
    /home/cari/Downloads/nwg-dock/tools.go:98 +0x4c
created by main.getTaskChangesChannel
    /home/cari/Downloads/nwg-dock/tools.go:95 +0x125

It's referencing the folder where I compiled the application, which, of course, no longer exists. I'm not sure why it might still be trying to access anything in this folder after compiling and installing.

The same crash occurs when attempting to launch nwg-dock when a split floating window already exists.

To Reproduce

  1. Launch nwg-dock.
  2. Open a floating window in sway.
  3. Split the window either horizontally or vertically.
  4. nwg-dock crashes.

Expected behavior nwg-dock should not crash, nor should it attempt to access the compile-time directory after being compiled and installed.

Desktop (please complete the following information):

Thanks for taking a look! ☺️

nwg-piotr commented 1 year ago

It looks like a bug in the go-sway library. A floating node treated this way (at least viewed through go-sway) no longer has AppID or PID, and my code was not ready for this. I added a workaround, that skips such tasks while crating the task list. They will be invisible to the dock, however.

nwg-piotr commented 1 year ago

Could you build and install from the fix35 branch, and tell me how it behaves on your side?

lilacpixel commented 1 year ago

fix35 branch is working perfectly! I don't use floating windows in this way very often—just a weird edge case that I thought was worth reporting, but it's awesome to have it fixed so quickly! Thank you so much! As a macOS switcher, I couldn't be more thrilled to have a beautiful dock like this for sway :smile_cat:

nwg-piotr commented 1 year ago

Haha! I admit it gave me a headache. But I fixed 2 more issues by the way.

As a macOS switcher, I couldn't be more thrilled to have a beautiful dock like this for sway

There's also a Hyprland version. After years on sway, I finally find Hyprland more flexible. All my stuff is currently being ported to Hyprland, most part is ready to use.

nwg-piotr commented 1 year ago

BTW: pull the latest commits, just in case you're out of date. I'm not merging tonight, it needs some more testing.