You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to express my gratitude for developing this package! It has been incredibly helpful in many aspects of my work, and I truly appreciate the time and effort you've invested in it. However, I have noticed some performance issues and unexpected behavior when using it in a Linux Wayland session desktop environment.
I noticed that each write operation starts a coroutine that then enters a C function
gofunc() { // serve as a daemon until the ownership is terminated.runtime.LockOSThread()
deferruntime.UnlockOSThread()
cs:=C.CString(s)
deferC.free(unsafe.Pointer(cs))
h:=cgo.NewHandle(start)
varok C.intiflen(buf) ==0 {
ok=C.clipboard_write(cs, nil, 0, C.uintptr_t(h))
} else {
ok=C.clipboard_write(cs, (*C.uchar)(unsafe.Pointer(&(buf[0]))), C.size_t(len(buf)), C.uintptr_t(h))
}
ifok!=C.int(0) {
fmt.Fprintf(os.Stderr, "write failed with status: %d\n", int(ok))
}
done<-struct{}{}
close(done)
}()
Within the C function clipboard_write, it appears to enter a loop that seems unable to exit (at least, I haven't found an exit condition so far).
// clipboard_write writes the given buf of size n as type typ.// if start is provided, the value of start will be changed to 1 to indicate// if the write is availiable for reading.intclipboard_write(char*typ, unsigned char*buf, size_tn, uintptr_thandle) {
// ...... XEventevent;
XSelectionRequestEvent*xsr;
intnotified=0;
for (;;) { // loop foreverif (notified==0) {
syncStatus(handle, 1); // notify Go sidenotified=1;
}
(*P_XNextEvent)(d, &event);
switch (event.type) {
caseSelectionClear:
(*P_XCloseDisplay)(d);
return0;
caseSelectionNotify:
break;
caseSelectionRequest:
// ......if ((R&2) ==0) (*P_XSendEvent)(d, ev.requestor, 0, 0, (XEvent*)&ev);
break;
}
}
}
I am concerned that repeatedly calling write in this way could lead to performance issues over time. If there’s no performance impact, could you kindly explain why? I would love to understand the mechanics better and learn from your insights.
--
Doesn't Work as Expected on Linux Wayland-session DE
I'm encountering an issue with clipboard operations in a Wayland session on Linux. Here’s a summary of the problem:
// Initialization...<-clipboard.Write(f, []byte("123456")) // This hangs indefinitely until I manually send a Control-C signal.//go func() { <-changed }()returnnil
However, this approach doesn’t work as expected—the clipboard doesn’t receive the data successfully. I suspect this is because the Goroutine handling the Write operation doesn't complete before the program exits.
This works, but introducing an arbitrary sleep is not ideal.
Expected Behavior:
I expected that, after successfully writing to the clipboard, the channel would receive a signal or value indicating completion. This way, I could avoid any delay-based workarounds.
Would you be able to clarify if there’s a preferred way to ensure the Write operation completes before the program exits? Or is there an internal mechanism for confirming successful writes that I might have missed?
The text was updated successfully, but these errors were encountered:
woshikedayaa
changed the title
question: performance problem and doesn't work as expected on linux wayland-session DE.
Question: performance issues and doesn't work as expected on Linux wayland-session DE.
Oct 31, 2024
First of all
I want to express my gratitude for developing this package! It has been incredibly helpful in many aspects of my work, and I truly appreciate the time and effort you've invested in it. However, I have noticed some performance issues and unexpected behavior when using it in a Linux Wayland session desktop environment.
Environment
Performance issues
I noticed that each write operation starts a coroutine that then enters a C function
Within the C function clipboard_write, it appears to enter a loop that seems unable to exit (at least, I haven't found an exit condition so far).
I am concerned that repeatedly calling write in this way could lead to performance issues over time. If there’s no performance impact, could you kindly explain why? I would love to understand the mechanics better and learn from your insights.
--
Doesn't Work as Expected on Linux Wayland-session DE
I'm encountering an issue with clipboard operations in a Wayland session on Linux. Here’s a summary of the problem:
To troubleshoot, I modified the code as follows:
However, this approach doesn’t work as expected—the clipboard doesn’t receive the data successfully. I suspect this is because the Goroutine handling the
Write
operation doesn't complete before the program exits.To verify, I added a short delay after
Write
:This works, but introducing an arbitrary sleep is not ideal.
Expected Behavior:
I expected that, after successfully writing to the clipboard, the channel would receive a signal or value indicating completion. This way, I could avoid any delay-based workarounds.
Would you be able to clarify if there’s a preferred way to ensure the
Write
operation completes before the program exits? Or is there an internal mechanism for confirming successful writes that I might have missed?The text was updated successfully, but these errors were encountered: