-
Notifications
You must be signed in to change notification settings - Fork 81
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
add timeout to clipboard initialization #185
Conversation
Err(_) => {}, // we have been released, don't panic | ||
} | ||
}); | ||
let mut clipboard = match receiver.recv_timeout(Duration::from_millis(1000)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 second is probably over-cautious, if anybody can defend a shorter timeout, pls do. (I didn't do any research into how long it takes for cli_clipboard to init normally)
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## master #185 +/- ##
==========================================
- Coverage 43.27% 43.10% -0.17%
==========================================
Files 18 18
Lines 2542 2552 +10
==========================================
Hits 1100 1100
- Misses 1442 1452 +10
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
4861ff2
to
554bbf8
Compare
554bbf8
to
79ebb44
Compare
Note: I'm actually having trouble replicating the issue I faced in other environments (even other WSL2 envs). |
I'll try to have a look at it in the next couple of days. In the mean time, would you mind reporting the bug upstream to the relevant crate? Maybe they have some deadlock or other bug that can be fixed for that platform. |
Issues seem to already be stacking up. Maybe switching to 1Password's arboard https://github.com/1Password/arboard could be good if they're not resolved timely? cli_clipboard x11_clipboard @piegamesde you also added this and it's still open |
Thanks for digging into this. I'm fine if you want to make a switch to arboard, the only requirement I have is that it has native Wayland support. Using it would have the added benefit of not depending on any native X libraries, as we currently do. |
Finally had a look at the code. It looks okay, but I think it can be simplified: since we always only send one value, you can simply have it as return value of the closure and not use a channel at all. On the main thread, one would then Of course you could also try out arboard, which will probably make the background thread obsolete. |
Okay, so I think you're correct in that the timeout fix should be upstream, but the cli_clipoard is too far downstream (depends on x11_clipboard, which depends on x11rb). So I tried switching to arboard, but it actually has the same issue. Thankfully, they depend on x11rb directly, and a small fix is possible. So I submitted a PR there, and we'll see how it progresses. If it goes through, I'll PR the switch to arboard. |
I actually don't think it's possible without a channel unless there's some API I missed for joining threads. (very well might be) |
Alright, so my PR finally got merged in 1Password/arboard#100 There seems to be the option to have Wayland by default: |
Okay, how to proceed with this? Do you want to try switching to arboard? |
Yeah I'll PR the switch to arboard. Sorry for the lapse. |
Switch is PR'd in #203 |
TL;DR
cli_clipboard
hangs on initialization in some weird x11 setups (e.g. my WSL2)cli_clipboard
depends on a connection to a socket.Context:
I wanted to try my hand at the sending text feature,
so I tried getting this repo setup on WSL2, but I couldn't get my binary to run. It kept hanging with no output.
Into debug mode I went:
All I got was
[2023-03-06T23:58:31Z DEBUG wormhole_rs] Logging enabled.
Now to debug Rust for the first time:
I found that it was stuck inside the cli_clipboard ClipboardContext::new() function.
And noticed that for Linux environments, it depends on an x11 socket.
There doesn't seem to be any kind of test suite for the cli at the moment, so let me know if there something I should add.
Note: I'm brand spanking new to Rust. So please be verbose with comments and teachings. 😅