Repository navigation
Description
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
43.7.7 (also reproduces on 40.0.0)
What operating system(s) are you using?
Other Linux
Operating System Version
CachyOS (Arch-based), KDE Plasma 6.7.5, KWin 6.7.5, Wayland session, launched with --ozone-platform=wayland (uname -a: Linux cachyos-x8664 6.x x86_64)
What arch are you using?
x64
Last Known Working Electron version
Unknown
Does the issue also appear in Chromium / Google Chrome?
I don't know how to test
Expected Behavior
After another application puts new content on the system clipboard, clipboard.readImage() / clipboard.readBuffer('image/png') should return that new content, so that pasting in the app matches what every other app sees.
Actual Behavior
If the app writes to the clipboard while no input event has been processed by the app (in my test: clipboard.writeImage() from a setTimeout 3 s after startup, without clicking the window), then every later clipboard read in that app keeps returning the app's own just-written image and ignores all subsequent copies made by other applications — for the rest of the app's lifetime. Other applications (Krita, the KDE clipboard manager history, a plain Wayland client) see the current clipboard correctly.
Reproduced with both Electron 43.7.7 (Chromium 150.0.7871.250) and Electron 40.0.0 (Chromium 144.0.7559.60). Observed in the wild with a shipped Electron app: QQ for Linux 3.2.34 (Electron 40) — after copying an image inside that app, "paste image" in that app keeps pasting that same image no matter what is copied afterwards elsewhere, until the app is restarted.
Testcase Gist URL
Additional Information
Run with npm i [email protected] && WAYLAND_DEBUG=1 npx electron --ozone-platform=wayland .; do not click the window. After ~3 s the app logs WROTE bytes=292 sha=aed04030680eec8f. Then set the clipboard to a different image from any other app:
WROTE bytes=292 sha=aed04030680eec8f
read bytes=442 sha=738b75e6c5e4af47 <- own data (re-encoded)
read bytes=442 sha=738b75e6c5e4af47 <- unchanged, while the real clipboard is now another image (685 bytes, sha 5171e045…)
In-depth investigation
ui/ozone/platform/wayland/host/wayland_clipboard.cc — Write() sets source_ (so IsSelectionOwner() becomes true) before checking whether a serial is available; when none is found it only logs a warning, so wl_data_device.set_selection is never sent:
void Write(const ui::PlatformClipboard::DataMap* data) final {
if (!data || data->empty()) {
offered_data_.clear();
source_.reset();
} else {
offered_data_ = *data;
source_ = manager_->CreateSource(this); // ownership claimed locally
source_->Offer(GetOfferedMimeTypes());
auto serial = connection_->serial_tracker().GetSerial(
{wl::SerialType::kTouchPress, wl::SerialType::kMousePress, wl::SerialType::kKeyPress});
if (serial.has_value()) {
GetDevice()->SetSelectionSource(source_.get(), serial->value);
} else {
LOG(WARNING) << "No serial found for selection."; // compositor is never told
}
}
...
}(Chromium 144 has a TODO at this exact spot: "This function should just no-op if no serial is found (ie: no recent input event has been processed yet)…"; 150's FinishWrite() has the same shape without the TODO.)
Ownership then short-circuits two more places, so the wrong belief is never corrected:
bool IsSelectionOwner() const final { return !!source_; }
void HandleNewSelectionOffer(ui::WaylandDataOfferBase* offer) const {
if (IsSelectionOwner())
return; // new selection offers are dropped, no notification
NotifyClipboardChanged();
}and ui/base/clipboard/clipboard_ozone.cc serves reads from the local cache while that flag is set:
// We can use a fastpath if we are the owner of the selection.
if (platform_clipboard_->IsSelectionOwner(buffer)) {
auto it = offered_data_[buffer].find(mime_type);
if (it == offered_data_[buffer].end())
return {};
return base::span(it->second->as_vector());
}
if (auto data = Read(buffer, mime_type)) // only reached when we do NOT think we own it
return base::span(data->as_vector());with the member documented as // Clipboard data that had been offered most recently. Used as a cache to read data if we still own it. (base::flat_map<ClipboardBuffer, PlatformClipboard::DataMap> offered_data_;)
Because set_selection was never sent, the compositor never learns about the data source and can never send wl_data_source.cancelled, so source_ is never reset and the app stays latched. In WAYLAND_DEBUG output collected during the test: create_data_source + offer("image/png") appear, set_selection appears 0 times, and after the app's own write the app receives wl_data_device.selection(wl_data_offer@…) for the new content but issues 0 wl_data_offer.receive(...) calls for it.
The same code path also causes a stale-read window when a serial is available: clicking a button in the test app (providing a serial) produces a valid set_selection; reads then generate zero wl_data_offer.receive traffic while the app believes it owns the selection, and its wl_data_source was not cancelled until 6.9 s later, when another client wrote the clipboard. In that window the app also reports its own content while other apps see the real clipboard.
Possible fixes: don't enter the "we own the selection" state when no serial is available (as the existing TODO suggests), and/or don't serve reads from offered_data_ purely because of a local ownership flag, and/or don't skip the clipboard-change notification in HandleNewSelectionOffer() while that flag is set.
Note on venue: the faulty code is in Chromium's Ozone/Wayland clipboard layer, but I could not find a way to trigger the no-serial write from Chrome web content (clipboard writes there require user activation, which provides a serial), whereas Electron's main-process clipboard.writeImage() can write with no input event at all — which is why I am filing it here.
Activity
github-actions commentedon Oct 5, 2026
Hello @Loss-of-time. Thanks for taking the time to open an issue and helping to make Electron better!
This issue was automatically closed because its body does not follow any of this repository's issue templates. Maintainers rely on the sections in those templates to triage issues, and issues that are missing them usually cannot be acted upon.
To get this issue triaged, please either:
[-]Linux/Wayland: clipboard write without a tracked input serial latches the app onto its own clipboard cache (all later copies ignored)[/-][+]Linux/Wayland: clipboard reads keep returning the app's own last-copied content and ignore later copies made by other apps[/+][-]Linux/Wayland: clipboard reads keep returning the app's own last-copied content and ignore later copies made by other apps[/-][+][BUG]: Linux/Wayland: clipboard reads keep returning the app's own last-copied content and ignore later copies made by other apps[/+]nwparker commentedon Oct 6, 2026
Our Orca users are hitting it (stablyai/orca#23229). Had my AI investigate; repro below if helpful.
Copy/paste reproduction: awaited write succeeds locally, then Electron stays on B while the system clipboard advances to C
Tested on native Wayland: Sway 1.9 / wlroots 0.17.1, Ubuntu 24.04 x64, with Electron 44.5.1 / Chromium 152.0.7977.130 and Electron 45.0.0-alpha.15 / Chromium 156.0.8077.0. Our earlier reproduction also fails on Electron 43.7.5. This uses only Electron and
wl-clipboard; no Orca code or native module.Needs Node/npm and
wl-copy/wl-paste(wl-clipboard; e.g.sudo apt install wl-clipboardon Debian/Ubuntu). Run this in a Wayland session. Leave the new window untouched until the automatic test finishes. The test replaces your clipboard with the A/B/C text markers.Paste this entire block into a terminal:
Expected on a working implementation: step 2 reads B from both Electron and
wl-paste; step 3 reads C from both.Actual output on the affected implementation:
After it finishes, Ctrl+V into the provided textarea also pastes B, although
wl-paste --no-newlinein another terminal returns C. Further copies in other apps remain invisible to this Electron process. In the earlier diagnostic I verified this with real compositor keyboard input, not a simulated DOM paste.The initial A/A read checks that the app can read the real clipboard before its programmatic write. No click/key press is required to trigger the bug. The
awaitis intentional: the new Promise API resolves even though the compositor never takes ownership of B.For a trace,
WAYLAND_DEBUG=1is already enabled. In the no-input case, Electron creates/offers a data source without sendingwl_data_device.set_selection; incoming external selection offers still arrive afterward. In the stale-input variant,set_selectionis sent with an older input serial and the compositor rejects it. Both leave Electron's local ownership/cache set. The script removesWAYLAND_DEBUGonly from thewl-copy/wl-pastechildren to keep their output readable.Calling
clipboard.clear()after the failed write restores reads of C in our tests, but doesn't make the attempted copy of B reach the system clipboard. A cache-only fix would prevent the stuck state while still dropping the programmatic copy.fix(linux): keep Wayland clipboard text current (#27772)