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

Panic from workspace event listener #5

Closed
JakeStanger opened this issue Oct 11, 2022 · 6 comments
Closed

Panic from workspace event listener #5

JakeStanger opened this issue Oct 11, 2022 · 6 comments
Labels
bug Something isn't working
Milestone

Comments

@JakeStanger
Copy link

JakeStanger commented Oct 11, 2022

Hey, I'm integrating this library into ironbar for JakeStanger/ironbar#18 and I've hit a bug:

When creating and switching to a new workspace, the event listener receives the added event and the change event. It appears when you then open a program (in this case kitty) it panics.

This can be reproduced simply by starting the program, using hyperctl dispatch workspace 4 (or the number of any workspace that does not currently exist), and then opening a window in the new workspace.

Minimal code to reproduce:

let mut event_listener = EventListener::new();

event_listener.add_workspace_added_handler(|id| println!("workspace added: {id:?}"));
event_listener.add_workspace_destroy_handler(|id| println!("workspace removed: {id:?}"));
event_listener.add_workspace_change_handler(|id| println!("workspace changed to {id:?}"));

event_listener.start_listener().await.unwrap();

Stdout and the relevant part of the backtrace:

workspace changed to Regular(2)
workspace changed to Regular(1)
workspace changed to Regular(3)
workspace changed to Regular(1)
workspace changed to Regular(3)
workspace added: Regular(4)
workspace changed to Regular(4)
The application panicked (crashed).
Message:  something has went down -[]-
Location: /home/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/hyprland-0.2.4/src/event_listener/shared.rs:228

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 7 frames hidden ⋮                               
   8: hyprland::event_listener::shared::event_parser::h59e666c08b605020
      at /home/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/hyprland-0.2.4/src/event_listener/shared.rs:228
   9: hyprland::event_listener::immutable::EventListener::start_listener::{{closure}}::h8810f2076f1a9397
      at /home/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/hyprland-0.2.4/src/event_listener/immutable.rs:260
  10: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h1c521f9b23072b06
      at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/future/mod.rs:91
  11: ironbar::clients::hyprland::HyprlandEventClient::new::{{closure}}::h70a2c01650c455c5
      at /home/jake/Programming/ironbar/src/clients/hyprland.rs:25
  12: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hdb2b9da00f74bf77

The line that's crashing is here:
https://github.com/yavko/hyprland-rs/blob/0f1b676924d9a614278f2a7e3bf4284369de64e1/src/event_listener/shared.rs#L228

It looks like perhaps there's another event being received after those two that is unsupported?

Hyprland version: hyprland-git r1728.7a775c0-1
Library version: 0.2.4


As an aside, it'd probably be better to return an Err rather than panic in the library, so binaries can control how to handle the error.

@yavko
Copy link
Member

yavko commented Oct 11, 2022

Hey, I'm integrating this library into ironbar for JakeStanger/ironbar#18 and I've hit a bug:

When creating and switching to a new workspace, the event listener receives the added event and the change event. It appears when you then open a program (in this case kitty) it panics.

This can be reproduced simply by starting the program, using hyperctl dispatch workspace 4 (or the number of any workspace that does not currently exist), and then opening a window in the new workspace.

Minimal code to reproduce:

let mut event_listener = EventListener::new();

event_listener.add_workspace_added_handler(|id| println!("workspace added: {id:?}"));
event_listener.add_workspace_destroy_handler(|id| println!("workspace removed: {id:?}"));
event_listener.add_workspace_change_handler(|id| println!("workspace changed to {id:?}"));

event_listener.start_listener().await.unwrap();

Stdout and the relevant part of the backtrace:

workspace changed to Regular(2)
workspace changed to Regular(1)
workspace changed to Regular(3)
workspace changed to Regular(1)
workspace changed to Regular(3)
workspace added: Regular(4)
workspace changed to Regular(4)
The application panicked (crashed).
Message:  something has went down -[]-
Location: /home/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/hyprland-0.2.4/src/event_listener/shared.rs:228

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 7 frames hidden ⋮                               
   8: hyprland::event_listener::shared::event_parser::h59e666c08b605020
      at /home/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/hyprland-0.2.4/src/event_listener/shared.rs:228
   9: hyprland::event_listener::immutable::EventListener::start_listener::{{closure}}::h8810f2076f1a9397
      at /home/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/hyprland-0.2.4/src/event_listener/immutable.rs:260
  10: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h1c521f9b23072b06
      at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/future/mod.rs:91
  11: ironbar::clients::hyprland::HyprlandEventClient::new::{{closure}}::h70a2c01650c455c5
      at /home/jake/Programming/ironbar/src/clients/hyprland.rs:25
  12: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hdb2b9da00f74bf77

The line that's crashing is here:

https://github.com/yavko/hyprland-rs/blob/0f1b676924d9a614278f2a7e3bf4284369de64e1/src/event_listener/shared.rs#L228

It looks like perhaps there's another event being received after those two that is unsupported?

Hyprland version: hyprland-git r1728.7a775c0-1 Library version: 0.2.4

As an aside, it'd probably be better to return an Err rather than panic in the library, so binaries can control how to handle the error.

Yeah I've already fixed this in 0.3.0 of hyprland-rs that I'm working on, should be out soon!

@yavko yavko added this to the 0.3.0 milestone Nov 8, 2022
@yavko
Copy link
Member

yavko commented Nov 8, 2022

Hey, I'm integrating this library into ironbar for JakeStanger/ironbar#18 and I've hit a bug:
When creating and switching to a new workspace, the event listener receives the added event and the change event. It appears when you then open a program (in this case kitty) it panics.
This can be reproduced simply by starting the program, using hyperctl dispatch workspace 4 (or the number of any workspace that does not currently exist), and then opening a window in the new workspace.
Minimal code to reproduce:

let mut event_listener = EventListener::new();

event_listener.add_workspace_added_handler(|id| println!("workspace added: {id:?}"));
event_listener.add_workspace_destroy_handler(|id| println!("workspace removed: {id:?}"));
event_listener.add_workspace_change_handler(|id| println!("workspace changed to {id:?}"));

event_listener.start_listener().await.unwrap();

Stdout and the relevant part of the backtrace:

workspace changed to Regular(2)
workspace changed to Regular(1)
workspace changed to Regular(3)
workspace changed to Regular(1)
workspace changed to Regular(3)
workspace added: Regular(4)
workspace changed to Regular(4)
The application panicked (crashed).
Message:  something has went down -[]-
Location: /home/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/hyprland-0.2.4/src/event_listener/shared.rs:228

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 7 frames hidden ⋮                               
   8: hyprland::event_listener::shared::event_parser::h59e666c08b605020
      at /home/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/hyprland-0.2.4/src/event_listener/shared.rs:228
   9: hyprland::event_listener::immutable::EventListener::start_listener::{{closure}}::h8810f2076f1a9397
      at /home/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/hyprland-0.2.4/src/event_listener/immutable.rs:260
  10: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h1c521f9b23072b06
      at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/future/mod.rs:91
  11: ironbar::clients::hyprland::HyprlandEventClient::new::{{closure}}::h70a2c01650c455c5
      at /home/jake/Programming/ironbar/src/clients/hyprland.rs:25
  12: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hdb2b9da00f74bf77

The line that's crashing is here:
https://github.com/yavko/hyprland-rs/blob/0f1b676924d9a614278f2a7e3bf4284369de64e1/src/event_listener/shared.rs#L228

It looks like perhaps there's another event being received after those two that is unsupported?
Hyprland version: hyprland-git r1728.7a775c0-1 Library version: 0.2.4
As an aside, it'd probably be better to return an Err rather than panic in the library, so binaries can control how to handle the error.

Yeah I've already fixed this in 0.3.0 of hyprland-rs that I'm working on, should be out soon!

Well soon didn't age well... Well anyways I hope and I say hope I'll be able to get by the end of the week, no promises

@yavko yavko added the bug Something isn't working label Nov 8, 2022
@yavko
Copy link
Member

yavko commented Nov 20, 2022

Hey i just entered a week break, expect new release soon

@yavko
Copy link
Member

yavko commented Nov 30, 2022

Hey i just entered a week break, expect new release soon

Update: Hyprland stopped working for me in my NixOS install (where I was developing 0.3.0), and so I have to use my old Manjaro install which is frankly out of disk space, so I'll have to leave it on pause until I'm able to fix Hyprland or NixOS, not sure what the issue is. Thanks for using Hyprland-rs!

@yavko
Copy link
Member

yavko commented Dec 22, 2022

This issue has been fixed in master.
For those wanting to test out 0.3.0, you can do so by

hyprland = { git = "https://github.com/hyprland-community/hyprland-rs.git" }

@yavko yavko closed this as completed Dec 22, 2022
@Houndie
Copy link

Houndie commented Dec 27, 2022

I appreciate your work on this!

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

3 participants