omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Every editable text field makes the shell read the entire clipboard on any app's clipboard change (Qt 6.11.2 / QTBUG-149610; unbounded on Wayland)

Open rmcdavid opened this issue 1 month ago • 4 comments

Up front: I am a hobbyist, not a professional software developer. This report was researched and written with the help of an AI assistant while I was building a third-party shell plugin. I have tried to make it accurate and to include the evidence behind every claim, but please read the technical details with that in mind. If anything here is wrong or unhelpful, tell me and I will correct it or close it.

What happens

Every editable text field in the shell makes omarchy-shell read the entire clipboard, synchronously, on its main thread, whenever any application on the desktop changes the clipboard. No keypress is needed; the field only has to exist. On Wayland that read is a pipe with a 1 s timeout per read, no total byte limit and no overall deadline, so a client offering N bytes of text/plain grows the shell by about 2N, and one that drips a byte every 900 ms holds the shell's main thread for as long as it likes.

Ui/TextField.qml inherits Qt Quick Controls TextField and leaves readOnly false, as every caller does while its panel is open: the network passphrase prompt, the clock and weather panels, tailscale, MultiSelect, SearchableDropdown, and the lock screen's password field (read-only only while authenticating). On the Qt Omarchy ships (6.11.2; released 6.12.0 behaves the same) every editable QQuickTextInput connects QClipboard::dataChanged to q_canPasteChanged(), which calls QMimeData::text() — the whole offer — not just a type check.

What I expected

A clipboard change by another program costs the shell nothing until the user pastes, and a paste reads a bounded amount.

How to reproduce

Three ten-line QML files and one wl-copy, on Omarchy 4.0.4 / Qt 6.11.2 / Hyprland 0.56.2:

// editable.qml  (readonly.qml is the same with readOnly: true;
//                nofield.qml replaces the TextField with a Rectangle)
import QtQuick
import QtQuick.Controls
import QtQuick.Window
Window {
  width: 320; height: 120; visible: true
  TextField { width: 300; readOnly: false; maximumLength: 2048 }
  Timer { interval: 9000; running: true; onTriggered: Qt.quit() }
}
QT_QPA_PLATFORM=wayland /usr/lib/qt6/bin/qml editable.qml &
sleep 2.5
python3 -c "import sys; sys.stdout.write('A'*(100*1024*1024))" | wl-copy --type text/plain &
# sample the qml process's VmRSS from /proc every 100 ms for 4 s
printf '' | wl-copy   # restore your clipboard afterwards

Evidence

Resident set of the throwaway client, sampled from outside every 100 ms, 2026-10-11:

probe RSS before RSS peak growth last growth at
TextField { readOnly: false } 164 MB 403 MB +238 MB 600 ms after the offer
TextField { readOnly: true } 163 MB 163 MB +0 —
no field (a Rectangle) 105 MB 157 MB +52 MB (toolkit start-up, see below) —

Attribution with a gdb catchpoint on pipe2 (the Wayland offer read creates its pipe there), backtrace at every hit after the offer, editable probe:

#0  pipe2
#2  QInternalMimeData::retrieveData(QString const&, QMetaType) const
#4  QMimeData::text() const
#5  QQuickTextInput::q_canPasteChanged
#7  QQuickTextInput::qt_metacall
#8  QQuickTextField::qt_metacall
#10 QPlatformClipboard::emitChanged
#16 wl_display_dispatch_queue_pending
#17 QtWaylandClient::QWaylandDisplay::flushRequests

Fourteen such hits for one offer on the editable probe (QMimeData::text() tries two mime types and the signal fires per mode); zero pipes created after the offer on the no-field probe, so its 52 MB was never the clipboard.

On the real shell's form of my plugin, under a nested headless cage with the same 100 MB offer: +240..+297 MB and 673..793 ms stalls of the main thread over seven runs; after making the fields read-only to Qt, +0 MB and a 124 ms worst case.

Upstream status

This is Qt's QTBUG-149610 ("TextInput canPaste is recomputed eagerly on QClipboard::dataChanged() (2 s stall per focus-in on Wayland)"), Closed / Fixed, affected 6.8.8, 6.10.3, 6.11.0–6.11.2, 6.12.0; fix versions 6.8.10, 6.12.1 and 6.13. The read arrived in qtdeclarative c82ef988 on the 6.11 branch (2026-02-18, shipped in 6.11.2) and 7d0a433a removed it (2026-09-15, "QQuickTextInput: don't call QMimeData::text() for canPaste", Fixes: QTBUG-149610). As of today no release Omarchy could ship carries the removal, and the 6.11 branch has no fix version listed at all. readOnly is the only switch on that slot in every version.

Ask

Until a Qt with 7d0a433a ships, keep the kit's fields readOnly: true whenever they are not being edited (or always, and edit through the key handlers the panels already have), and/or bound what the shell will read. The IPTV plugin (io.github.rmcdavid.iptv, 0.13.5) did the former for its own form after a marketplace review raised it (omarchy-plugin-marketplace#11077): every field read-only to Qt, editing applied by the plugin over its own model, paste through a helper process that reads at most 32 KiB of wl-paste's output under a deadline and hands the shell one bounded reply. The stated loss of that approach is input-method composition (dead keys) into a read-only field, which may matter more for the kit than it did for a URL form.

rmcdavid avatar Oct 12 '26 01:10 rmcdavid

Thanks for the thorough write-up. Same root cause as #14980: editable TextFields subscribe to clipboard changes and pull the full selection synchronously (QTBUG-149610), which on Wayland is unbounded and can stall or OOM the shell.

I'd track this as a duplicate of #14980. Severity is real (DoS / surprise clipboard reads while any TextField exists) — worth a shell-side mitigation (don't bind clipboard on fields that don't paste, or gate on focus) even before an upstream Qt fix. No need for a separate public security report if we keep the discussion on the issue.

jandrusk avatar Oct 12 '26 18:10 jandrusk

Extra data points from #14980 (same reporter, same 6.11.2 shell), for whatever they're worth here.

Real call sites in the shipped shell — all inherit Ui/TextField.qml and stay non-readOnly for as long as their panel is open:

  • panels/clock/Panel.qml:381 and :404
  • panels/network/Panel.qml:1841 (enterprise identity) and :1865 (Wi-Fi passphrase, password: true)
  • panels/tailscale/Panel.qml:601
  • panels/weather/Panel.qml:615

A second, read-free field type, from source. On 6.11.2, QQuickTextEdit's control (QQuickTextControl) never connects to QClipboard::dataChanged; it only touches the clipboard from the explicit paste shortcut (canPaste()/paste() are plain members, not slot handlers). So swapping Controls.TextField for QtQuick.TextEdit also drops the eager read, which may be a lighter option than forcing readOnly + an external model on fields that do legitimately accept paste.

Caveat for the readOnly route: the Wi-Fi passphrase field needs masking (password: true / echoMode: TextInput.Password), which a plain QtQuick.TextEdit can't replicate, so that one can't simply be swapped to a TextEdit; and the IME-composition loss you noted is arguably worst exactly there. A per-field decision may be needed rather than a single rule.

For my plugin I ended up doing the TextEdit swap plus a bounded explicit-paste helper (timeout 2 wl-paste --no-newline, capped at 4 KiB, fail-closed), and the shell reloads clean with it.

iampoul avatar Oct 12 '26 23:10 iampoul

Extra data points in case they help whoever picks this up; please disregard anything already covered above.

Gating readOnly on focus or editing is not enough. QQuickTextInput::setReadOnly() calls q_canPasteChanged() itself (qquicktextinput.cpp, setReadOnly, 6.11/6.12), so switching a field to editable when it gains focus already pulls the whole current clipboard offer. The field then keeps reading every later change for as long as it is editable. A marketplace plugin that tried exactly this measured +106 MB on a single click into the field with a 96 MB offer present (omarchy-plugin-marketplace#11195). For the TextField route, the field has to stay readOnly for its whole life, and paste has to go around Qt entirely, not through readOnly = false; paste().

The TextEdit route needs three more doors closed. TextEdit does not read on clipboard changes, but QQuickTextControl still has three paths that go through the same unbounded QMimeData read:

  • keyboard paste;
  • middle-click, which pastes the primary selection (mouseReleaseEvent, MiddleButton → insertFromMimeData);
  • dropped text (dropEvent → insertFromMimeData).

So the swap is safe only once Ctrl+V and Shift+Insert are routed to a bounded helper and middle-click and drops are swallowed.

For a masked field kept readOnly (the Wi-Fi passphrase caveat above): Qt paints no caret on a read-only TextInput. A cursorDelegate fixes that, but Qt only creates it once cursorVisible turns true, which a read-only input never does by itself, so set cursorVisible = activeFocus explicitly.

A working component that combines both routes, MIT: https://github.com/JanitorHead/omarchy-quotatank/blob/6e845e56ef96845665caa2e308c21958f3535492/SettingsField.qml. It uses a single-line TextEdit for plain fields, a permanently read-only Ui.TextField for masked ones, and paste through timeout 2 wl-paste | head -c 64KiB in a separate process.

JanitorHead avatar Oct 14 '26 10:10 JanitorHead

I looked at this today. It looks like the same bug as #8753, which was reported first, but I have neither labelled it nor closed it, because today's second opinion was unavailable.

What it matches. #8753 traces the same cause: in Qt 6.11.2 every editable QQuickTextInput, and so every shell/Ui/TextField.qml, runs q_canPasteChanged() on each clipboard change and reads the whole clipboard text on the shell's main thread unless the field is read-only. #8753 caught it as a 1–2 s freeze when a panel opens, and its thread already covers the unbounded QWaylandMimeData::readData() loop with a trickling owner. What this report adds is the memory side of the same read (+238 MB for a 100 MB offer), and the comments here add the per-field details a shell workaround would need: setReadOnly() reading the clipboard itself, the three paste paths TextEdit still has, and the masked passphrase field. The fix is the same for both: Qt's 7d0a433a9d on 6.11 (bcbfae6761 on 6.12) replaces the read with hasText(), and no Qt release carries it yet. Whether to work around it in the shell until then is the maintainer's decision. #14980 and #12608 describe the same mechanism.

What was checked. I read this report and its comments, and #8753, #14980 and #12608 with theirs. I found no open pull request that fixes it. Nothing was run, since #8753 already has the reproduction on a stock worker.

Why it is not settled. I classified this as a bug, and it should be closed as a duplicate of #8753. Both steps need a second model to agree before they take effect, and the configured reviewer, Codex Medium, had already used up today's reviews, so neither took effect. This rests on one model's reading, Claude Opus 5.5's.

Next: it goes back through triage, where a second opinion can settle the class and the duplicate. The underlying decision waits on the maintainer, on #8753.

omarchybot avatar Oct 22 '26 10:10 omarchybot