omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Quickshell freezes for 1–2 seconds when a focused panel reads from a stalled Wayland clipboard owner

Open forbidden-game opened this issue 3 months ago • 3 comments

System details

ThinkPad T14p, Intel Core Ultra 9 285H, Intel Arrow Lake-P iGPU

  • Omarchy 4.0.1-1
  • Quickshell 0.3.1-1
  • Hyprland 0.56.2-1
  • Qt Wayland / Qt Declarative 6.11.2-1
  • Kernel 7.1.9-arch1-2

What's wrong?

Opening a keyboard-focused Omarchy Shell panel can block the entire Quickshell UI for approximately 1–2 seconds when the current Wayland clipboard owner is temporarily unresponsive.

Regular application windows remain responsive. The bar and Shell panels are blocked together.

This reproduces consistently using the stock Clock widget and the following local clipboard owner.

Steps to reproduce

  1. In terminal 1, watch the relevant log:

    journalctl --user -f -o cat |
      rg --line-buffered 'QWaylandDataOffer|mimeType'
    
  2. In terminal 2, create and run a deliberately stalled clipboard owner:

    cat >/tmp/stalled-clipboard.qml <<'QML'
    import QtQuick 2.15
    import QtQuick.Window 2.15
    
    Window {
        width: 240
        height: 80
        visible: true
        title: "Stalled clipboard owner"
    
        TextInput {
            anchors.fill: parent
            text: "omarchy-clipboard-timeout-repro"
    
            Component.onCompleted: {
                forceActiveFocus()
                selectAll()
                copy()
                stall.start()
            }
        }
    
        Timer {
            id: stall
            interval: 5000
    
            onTriggered: {
                const deadline = Date.now() + 30000
                while (Date.now() < deadline) {
                    // Simulate an unresponsive clipboard owner.
                }
                Qt.quit()
            }
        }
    }
    QML
    
    qml /tmp/stalled-clipboard.qml
    
  3. Within five seconds, click the small “Stalled clipboard owner” window once.

  4. Wait until that window becomes unresponsive, then manually click the stock Clock widget in the Omarchy bar.

Actual result

The Clock panel/bar becomes unresponsive for approximately 1–2 seconds. The journal prints:

QWaylandDataOffer: timeout reading from pipe
QWaylandDataOffer: error reading data for mimeType text/plain;charset=utf-8
QWaylandDataOffer: timeout reading from pipe
QWaylandDataOffer: error reading data for mimeType text/plain

The test application exits automatically after 30 seconds.

The same log occurs intermittently with normal clipboard contents, which is the real-world symptom this reproducer models.

Expected result

An unresponsive clipboard owner should not block the Quickshell GUI thread. The Clock panel and the rest of the Omarchy Shell should remain responsive, even if paste availability cannot be determined immediately.

Trace

GDB shows the Quickshell main thread synchronously reading the clipboard:

QWaylandDataOffer::startReceiving
QWaylandDataOffer::retrieveData_sys
QInternalMimeData::retrieveData
QClipboard::mimeData
QQuickTextInput::q_canPasteChanged

This indicates that a QQuickTextInput paste-availability update performs a blocking clipboard read on the Shell GUI thread.

forbidden-game avatar Aug 28 '26 13:08 forbidden-game

Reproduced on a stock Omarchy worker (Qt 6.11.2, Quickshell 0.3.1) with quattro at c352b62d6. With a clipboard owner whose GUI thread is stalled, opening the clock panel left the shell unable to answer omarchy-shell shell ping for 2009 ms, against 31 ms with a normal owner, and the journal printed the same four QWaylandDataOffer lines you quoted.

The cause is in Qt, and the shell exposes it. Every QQuickTextInput connects to the clipboard's dataChanged signal, and its q_canPasteChanged() reads the clipboard text synchronously unless the input is read-only. It reads whether or not the input is visible, focused or enabled. On Wayland that read waits up to a second per MIME type on the owner's pipe, which gives the two timeouts and the roughly two-second stall. A bare Qt window shows the same thing with no Omarchy code involved: one unfocused TextInput stalled it for 2024–2030 ms when it took focus, the same window without the input for 40–58 ms, and with a read-only input for 73–77 ms.

Fixing the clock panel alone would not help, because the shell keeps several text inputs alive all the time. These include the clock panel's two life-editing fields (shell/plugins/panels/clock/Panel.qml:382 and :405, only hidden while not editing, and the panel's loader is always active), the weather panel's location editor, the polkit agent's password input (shell/plugins/polkit/PolkitAgent.qml:310) and the lock preview's LockView. Any one of them is enough. The shell's clipboard history reads through wl-paste subprocesses and is not in this path.

There are two possible workarounds in Omarchy, and neither removes the stall while a field is actually being typed in. One is to create each text input only while it is in use. The other is to bind readOnly: !activeFocus on the shell's inputs, since Qt skips the read for a read-only input. Both touch the lock screen and polkit password inputs, so which one to use, if either, is a design decision for the maintainer, not a contained fix. No pull request has been opened. #12608 reports the same timeouts stalling shell overlays, with WeChat as the clipboard owner, and looks like the same mechanism.

Second opinion: Codex Medium also reviewed the source. It agreed on the mechanism and that both workarounds are design choices, though its independence from this review is not guaranteed. On its own it found the always-alive weather and lock-preview inputs listed above. This waits on the maintainer.

omarchybot avatar Oct 09 '26 06:10 omarchybot

One more measurement: a clipboard owner that trickles its data makes this stall unbounded, and it reproduces with no third-party plugin.

Repro. Omarchy shell as installed, Qt 6.11.2, no plugins enabled. A data-control client takes the selection and, when asked for the data, writes one byte every 0.8 s and never closes the pipe. Then open a shell panel that takes the keyboard (qs ipc call omarchy.monitor open).

  • The shell does not answer while the owner trickles: an IPC ping took 5.6 s, against 71 ms with a normal owner, and it grows with the trickle. The process reading the offer is the shell itself.
  • With no shell panel open, the shell does not read the offer and does not stall.
  • An owner that writes nothing costs about 1 s per MIME type and two per change (text/plain;charset=utf-8, then text/plain). That's the 1–2 s reported here.

Why it's unbounded. QWaylandDataOffer's read waits QDeadlineTimer(1s) on each poll(), inside a Q_FOREVER loop with no total deadline. Any byte that arrives within the second starts the wait again. The loop is the same on every Qt branch, dev included.

Ways out

  • Qt has fixed the TextInput side. qt/qtdeclarative@ef692a52e3 ("QQuickTextInput: don't call QMimeData::text() for canPaste")switches tohasText()`, the same check TextEdit already uses. It's on dev and was picked to the 6.12 (bcbfae6761) and 6.11 (7d0a433a9d) branches after 6.12.0 and 6.11.2 were tagged, so it should ship in the next patch releases. It removes the read on a clipboard change. An explicit paste still reads through the unbounded loop.
  • In Omarchy, until then: build the shell's text fields on TextEdit instead of TextInput. TextEdit's paste check looks only at the offered formats (QQuickTextControl) and never reads the data, so a new selection costs nothing, even while a field has focus and is being typed in. The Devices plugin's text field works this way, which is why its fields add no read here.
  • For paste itself, a shell that must stay responsive can read the clipboard out of process, with a deadline and a byte cap (`wl-paste in a subprocess), the way Omarchy's clipboard history already does.

jenseralmeida avatar Oct 14 '26 17:10 jenseralmeida

I checked the new comment against Qt's source and against quattro at 84cfb9395. Most of it holds, and it changes what Omarchy needs to do.

The Qt fix is real but not released yet. In qt/qtdeclarative, ef692a52e3 changes both canPaste() and q_canPasteChanged() in QQuickTextInput to use hasText() instead of reading the text. It is on dev, and was picked to 6.12 as bcbfae6761 and to 6.11 as 7d0a433a9d. Neither cherry-pick is in v6.12.0 or v6.11.2, and no later tag exists yet. It removes the read this issue traces (q_canPasteChanged → QClipboard::mimeData), so the freeze when a panel opens should go away once Arch ships a Qt patch release that carries it, with no change to Omarchy.

The read can stall without limit. In qtbase 6.11, QWaylandMimeData::readData (src/plugins/platforms/wayland/qwaylanddataoffer.cpp:242) creates a fresh QDeadlineTimer(1s) for every poll() inside Q_FOREVER, and only a timeout, an error or EOF ends the loop. An owner that writes a byte faster than once a second therefore keeps the shell's GUI thread blocked. That is consistent with the 5.6 s measured above. I confirmed this in the source and did not reproduce it on a worker. An explicit paste still goes through this loop after the Qt fix, in both TextInput and TextEdit. That is a Qt Wayland problem to report upstream.

TextEdit is not a drop-in workaround here. Its paste check only looks at the offered formats, as the comment says. But quattro has no TextEdit field and no Devices plugin: the shell's fields are shell/Ui/TextField.qml (Qt Quick Controls TextField, which is a TextInput) and shell/Ui/NumberField.qml:73. The lock and polkit password inputs (shell/plugins/lock/LockView.qml:180, shell/plugins/polkit/PolkitAgent.qml:324) depend on echoMode, which TextEdit does not have. Moving the shell to TextEdit would be a redesign of its inputs, not a contained fix. One correction to my earlier comment: panels are now built the first time they open, not at startup (shell/Ui/KeyboardPanel.qml:66). The fields in a panel still stay alive after that, so this narrows the exposure but does not remove it.

No pull request has been opened. My suggestion is to wait for the Qt patch release rather than change the shell, then rerun the original reproducer against it. Whether to do that, or to work around it in Omarchy until then, is for the maintainer to decide.

Second opinion: Codex Medium checked the same claims against source. It agreed on each point; its independence from this review is not guaranteed. It contributed the correction above about panels being built on first open. It could not reach GitHub to check the commit hashes, so I checked those myself through the API.

omarchybot avatar Oct 14 '26 17:10 omarchybot