bugaevc / wl-clipboard

Command-line copy/paste utilities for Wayland
GNU General Public License v3.0
1.59k stars 60 forks source link

wl-copy infinatly hangs #210

Open Dialgatrainer02 opened 9 months ago

Dialgatrainer02 commented 9 months ago

i can copy fine but trying to pipe into wl-copy hangs forever including the example ls ~/Downloads | wl-copy

what logs can i provide and how do i get them?

bugaevc commented 9 months ago

Hi!

i can copy fine

Do you mean that wl-copy some text works fine for you, and only hangs when you pipe something into it? Does wl-paste work?

Does the thing you're copying appear in the clipboard despite wl-copy hanging? What distro, Wayland compositor, and version of wl-clipboard is this on?

what logs can i provide and how do i get them?

The Wayland debug log, which you can get like this:

ls ~/Downloads | WAYLAND_DEBUG=1 wl-copy 2>/tmp/wayland-debug.log

and the strace log:

ls ~/Downloads | strace -f wl-copy 2>/tmp/strace.log
Dialgatrainer02 commented 9 months ago

Do you mean that wl-copy some text works fine for you, and only hangs when you pipe something into it? Does wl-paste work?

yes i can copy and i can paste it only hangs when trying to use clipboard history with dmenu

ls ~/Downloads | WAYLAND_DEBUG=1 wl-copy 2>/tmp/wayland-debug.log

i ran this and hyprland crashed

ls ~/Downloads | strace -f wl-copy 2>/tmp/strace.log

strace.log

when i copy without piping it work and shows in cliphist however piping something in hsngs untill i ctrl c it

bugaevc commented 9 months ago

i ran this and hyprland crashed

That certainly sounds like an issue with Hyprland, you should report the crash to them.

strace.log

That looks like wl-copy is waiting for xdg-mime, which is waiting for xprop, which is waiting to connect to X11 (likely Xwayland). Why it needs or uses xprop on Wayland, I don't know.

Are you able to run xprop without it hanging? Are you able to run xdg-mime (e.g. xdg-mime query filetype /etc/os-release) without it hanging? If no, that's where your issue is. You should be able to work around this by specifying the MIME type explicitly, like so: ls ~/Downloads | wl-copy --type text/plain

Dialgatrainer02 commented 9 months ago

xdg mime hangs
with --type it works fine this is a fresh arch install so im unsure why xdg mime is hanging but thank you for the fix

marmitar commented 6 months ago

I'm also having problem here, but I'm not so sure it is xprop's fault. Looking at the code, xdg-mime uses xprop in the detectDE function to figure out the current running Desktop Environment. It does so using XDG_CURRENT_DESKTOP first, which is set in my DE (GNOME), so it woldn't need to touch xprop here. Also, xdg-mime runs really fast when used directly:

~> time xdg-mime query filetype ~/.ssh/id_ed25519_sk.pub
application/vnd.ms-publisher

________________________________________________________
Executed in   16.35 millis    fish           external
   usr time   10.49 millis  889.00 micros    9.60 millis
   sys time    8.18 millis  453.00 micros    7.72 millis

~> time xdg-mime query filetype (cat ~/.ssh/id_ed25519_sk.pub | psub)
text/plain

________________________________________________________
Executed in   19.43 millis    fish           external
   usr time   16.31 millis  202.00 micros   16.11 millis
   sys time    4.13 millis  102.00 micros    4.03 millis

~> time wl-copy < ~/.ssh/id_ed25519_sk.pub

________________________________________________________
Executed in   11.10 secs      fish           external
   usr time    5.30 millis  323.00 micros    4.97 millis
   sys time   21.42 millis  158.00 micros   21.26 millis

~> time wl-copy --type text/plain < ~/.ssh/id_ed25519_sk.pub

________________________________________________________
Executed in   28.33 secs      fish           external
   usr time    3.62 millis  873.00 micros    2.75 millis
   sys time    3.35 millis  416.00 micros    2.94 millis

Weirdly, it seems like CPU time is really low (less than 50 ms), but somehow the running time varies wildly, from 2 seconds up to 1 minute.

Logs

I can't run strace without sudo on my system, so here are the Wayland logs.

WAYLAND_DEBUG=1 wl-copy < ~/.ssh/id_ed25519_sk.pub ```log [3337414.129] -> wl_display@1.get_registry(new id wl_registry@2) [3337414.147] -> wl_display@1.sync(new id wl_callback@3) [3337414.338] wl_display@1.delete_id(3) [3337414.348] wl_registry@2.global(1, "wl_compositor", 6) [3337414.355] -> wl_registry@2.bind(1, "wl_compositor", 2, new id [unknown]@4) [3337414.362] wl_registry@2.global(2, "wl_eglstream_display", 1) [3337414.370] wl_registry@2.global(3, "wl_drm", 2) [3337414.375] wl_registry@2.global(4, "wl_shm", 1) [3337414.381] -> wl_registry@2.bind(4, "wl_shm", 1, new id [unknown]@5) [3337414.391] wl_registry@2.global(5, "wl_output", 4) [3337414.397] wl_registry@2.global(6, "zxdg_output_manager_v1", 3) [3337414.403] wl_registry@2.global(7, "wl_data_device_manager", 3) [3337414.408] -> wl_registry@2.bind(7, "wl_data_device_manager", 1, new id [unknown]@6) [3337414.412] wl_registry@2.global(8, "zwp_primary_selection_device_manager_v1", 1) [3337414.417] -> wl_registry@2.bind(8, "zwp_primary_selection_device_manager_v1", 1, new id [unknown]@7) [3337414.422] wl_registry@2.global(9, "wl_subcompositor", 1) [3337414.427] wl_registry@2.global(10, "xdg_wm_base", 6) [3337414.432] -> wl_registry@2.bind(10, "xdg_wm_base", 1, new id [unknown]@8) [3337414.437] wl_registry@2.global(11, "gtk_shell1", 5) [3337414.442] -> wl_registry@2.bind(11, "gtk_shell1", 4, new id [unknown]@9) [3337414.447] wl_registry@2.global(12, "wp_viewporter", 1) [3337414.453] wl_registry@2.global(13, "wp_fractional_scale_manager_v1", 1) [3337414.458] wl_registry@2.global(14, "zwp_pointer_gestures_v1", 3) [3337414.463] wl_registry@2.global(15, "zwp_tablet_manager_v2", 1) [3337414.467] wl_registry@2.global(16, "wl_seat", 8) [3337414.472] -> wl_registry@2.bind(16, "wl_seat", 2, new id [unknown]@10) [3337414.480] wl_registry@2.global(17, "zwp_relative_pointer_manager_v1", 1) [3337414.484] wl_registry@2.global(18, "zwp_pointer_constraints_v1", 1) [3337414.490] wl_registry@2.global(19, "zxdg_exporter_v2", 1) [3337414.494] wl_registry@2.global(20, "zxdg_importer_v2", 1) [3337414.499] wl_registry@2.global(21, "zxdg_exporter_v1", 1) [3337414.503] wl_registry@2.global(22, "zxdg_importer_v1", 1) [3337414.508] wl_registry@2.global(23, "zwp_linux_dmabuf_v1", 5) [3337414.512] wl_registry@2.global(24, "wp_single_pixel_buffer_manager_v1", 1) [3337414.517] wl_registry@2.global(25, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1) [3337414.521] wl_registry@2.global(26, "zwp_text_input_manager_v3", 1) [3337414.525] wl_registry@2.global(27, "wp_presentation", 1) [3337414.530] wl_registry@2.global(28, "xdg_activation_v1", 1) [3337414.535] -> wl_registry@2.bind(28, "xdg_activation_v1", 1, new id [unknown]@11) [3337414.541] wl_registry@2.global(29, "zwp_idle_inhibit_manager_v1", 1) [3337414.545] wl_callback@3.done(6546) [3337414.550] -> wl_display@1.sync(new id wl_callback@3) [3337414.685] wl_display@1.delete_id(3) [3337414.692] wl_seat@10.capabilities(3) [3337414.696] wl_seat@10.name("seat0") [3337414.701] wl_callback@3.done(6546) [3337414.707] -> wl_data_device_manager@6.get_data_device(new id wl_data_device@3, wl_seat@10) [3337442.337] -> wl_data_device_manager@6.create_data_source(new id wl_data_source@12) [3337442.349] -> wl_data_source@12.offer("application/vnd.ms-publisher") [3337442.354] -> wl_data_source@12.offer("text/plain") [3337442.358] -> wl_data_source@12.offer("text/plain;charset=utf-8") [3337442.362] -> wl_data_source@12.offer("TEXT") [3337442.367] -> wl_data_source@12.offer("STRING") [3337442.370] -> wl_data_source@12.offer("UTF8_STRING") [3337442.375] -> wl_seat@10.get_keyboard(new id wl_keyboard@13) [3337442.743] wl_keyboard@13.keymap(1, fd 5, 70198) [3337442.773] -> wl_compositor@4.create_surface(new id wl_surface@14) [3337442.778] -> xdg_wm_base@8.get_xdg_surface(new id xdg_surface@15, wl_surface@14) [3337442.783] -> xdg_surface@15.get_toplevel(new id xdg_toplevel@16) [3337442.786] -> xdg_toplevel@16.set_title("wl-clipboard") [3337442.791] -> gtk_shell1@9.get_gtk_surface(new id gtk_surface1@17, wl_surface@14) [3337442.796] -> wl_surface@14.commit() [3337442.800] -> wl_display@1.sync(new id wl_callback@18) [3337445.204] wl_display@1.delete_id(18) [3337445.220] xdg_toplevel@16.configure(0, 0, array[0]) [3337445.225] xdg_surface@15.configure(456) [3337445.230] -> xdg_surface@15.ack_configure(456) [3337445.237] wl_callback@18.done(6546) [3337445.263] -> wl_shm@5.create_pool(new id wl_shm_pool@18, fd 6, 4) [3337445.273] -> wl_shm_pool@18.create_buffer(new id wl_buffer@19, 0, 1, 1, 4, 0) [3337445.280] -> wl_surface@14.attach(wl_buffer@19, 0, 0) [3337445.287] -> wl_surface@14.damage(0, 0, 1, 1) [3337445.293] -> gtk_surface1@17.present(0) [3337445.301] -> wl_surface@14.commit() [3337452.414] xdg_wm_base@8.ping(5363667) [3337452.433] -> xdg_wm_base@8.pong(5363667) [3397516.017] wl_keyboard@13.enter(6552, wl_surface@14, array[0]) [3397516.059] -> wl_data_device@3.set_selection(wl_data_source@12, 6552) [3397516.084] -> wl_display@1.sync(new id wl_callback@20) [3397516.106] wl_keyboard@13.modifiers(6552, 0, 0, 16, 0) [3397516.121] wl_data_device@3.data_offer(new id wl_data_offer@4278190080) [3397516.133] wl_data_offer@4278190080.offer("text/plain") [3397516.145] wl_data_offer@4278190080.offer("text/plain;charset=utf-8") [3397516.157] wl_data_offer@4278190080.offer("UTF8_STRING") [3397516.174] wl_data_offer@4278190080.offer("STRING") [3397516.184] wl_data_offer@4278190080.offer("TEXT") [3397516.194] wl_data_offer@4278190080.offer("application/glfw+clipboard-2478") [3397516.205] wl_data_device@3.selection(wl_data_offer@4278190080) [3397516.227] -> wl_data_offer@4278190080.destroy() [3397516.240] xdg_toplevel@16.configure(1, 1, array[4]) [3397516.256] xdg_surface@15.configure(458) [3397516.268] -> xdg_surface@15.ack_configure(458) [3397516.693] wl_display@1.delete_id(20) [3397516.715] wl_data_device@3.data_offer(new id wl_data_offer@4278190081) [3397516.734] wl_data_offer@4278190081.offer("UTF8_STRING") [3397516.778] wl_data_offer@4278190081.offer("STRING") [3397516.788] wl_data_offer@4278190081.offer("TEXT") [3397516.801] wl_data_offer@4278190081.offer("text/plain;charset=utf-8") [3397516.811] wl_data_offer@4278190081.offer("text/plain") [3397516.822] wl_data_offer@4278190081.offer("application/vnd.ms-publisher") [3397516.832] wl_data_device@3.selection(wl_data_offer@4278190081) [3397516.843] -> wl_data_offer@4278190081.destroy() [3397516.854] wl_data_source@12.send("text/plain;charset=utf-8", fd 6) [3397519.197] wl_callback@20.done(6552) [3397519.227] -> xdg_toplevel@16.destroy() [3397519.247] -> xdg_surface@15.destroy() [3397519.271] -> gtk_surface1@17.release() [3397519.282] -> wl_surface@14.destroy() [3397521.678] wl_display@1.delete_id(16) [3397521.717] wl_display@1.delete_id(15) [3397521.725] wl_display@1.delete_id(17) [3397521.733] wl_display@1.delete_id(14) [3397521.738] wl_keyboard@13.leave(6553, nil) [3425178.637] wl_data_source@12.cancelled() ```
jidanni commented 3 months ago

In emacs | runs the command shell-command-on-region. Guaranteed to hang when piping into wl-copy. P.S., https://www.emacswiki.org/emacs/CopyAndPaste#h5o-4 says something about this.