wallet: parseBitcoinUriFromFile blocks the GUI thread on network-mounted paths #541

Closed
opened 2026-03-28 19:40:38 +00:00 by epicleafies · 1 comment
epicleafies commented 2026-03-28 19:40:38 +00:00 (Migrated from github.com)

WalletQmlModel::parseBitcoinUriFromFile reads the file synchronously on the GUI thread (QFile::open + readAll). For files on local storage, the existing 1 MiB size guard makes this acceptable. However, if the user drags a file from a network-mounted volume (NFS, SMB, SSHFS), the blocking I/O can stall the main thread for several seconds, freezing the UI.

Proposed fix

Move file I/O off the GUI thread using QtConcurrent::run. The result should be returned asynchronously — the C++ side emits a signal carrying the parsed QVariantMap; the QML side connects to it and calls applyParsedPaymentRequest from the signal handler rather than blocking on the Q_INVOKABLE return value.

Rough sketch:

// walletqmlmodel.h
Q_SIGNAL void bitcoinUriFromFileParsed(QVariantMap result);
Q_INVOKABLE void parseBitcoinUriFromFileAsync(const QString& source_path);

// walletqmlmodel.cpp
void WalletQmlModel::parseBitcoinUriFromFileAsync(const QString& source_path)
{
    QtConcurrent::run([this, source_path]() {
        QVariantMap result = /* existing read + parse logic */;
        Q_EMIT bitcoinUriFromFileParsed(result);
    });
}
// Send.qml
Connections {
    target: root.wallet
    function onBitcoinUriFromFileParsed(result) {
        sendPage.applyParsedPaymentRequest(result, qsTr("file"))
    }
}

Priority

Low for mobile (no NFS mounts in practice). Should be addressed before any desktop-focused release where drag-from-network-share is a plausible workflow.

  • Introduced alongside the URI import feature (issue #523)
`WalletQmlModel::parseBitcoinUriFromFile` reads the file synchronously on the GUI thread (`QFile::open` + `readAll`). For files on local storage, the existing 1 MiB size guard makes this acceptable. However, if the user drags a file from a network-mounted volume (NFS, SMB, SSHFS), the blocking I/O can stall the main thread for several seconds, freezing the UI. ## Proposed fix Move file I/O off the GUI thread using `QtConcurrent::run`. The result should be returned asynchronously — the C++ side emits a signal carrying the parsed `QVariantMap`; the QML side connects to it and calls `applyParsedPaymentRequest` from the signal handler rather than blocking on the `Q_INVOKABLE` return value. Rough sketch: ```cpp // walletqmlmodel.h Q_SIGNAL void bitcoinUriFromFileParsed(QVariantMap result); Q_INVOKABLE void parseBitcoinUriFromFileAsync(const QString& source_path); // walletqmlmodel.cpp void WalletQmlModel::parseBitcoinUriFromFileAsync(const QString& source_path) { QtConcurrent::run([this, source_path]() { QVariantMap result = /* existing read + parse logic */; Q_EMIT bitcoinUriFromFileParsed(result); }); } ``` ```qml // Send.qml Connections { target: root.wallet function onBitcoinUriFromFileParsed(result) { sendPage.applyParsedPaymentRequest(result, qsTr("file")) } } ``` ## Priority Low for mobile (no NFS mounts in practice). Should be addressed before any desktop-focused release where drag-from-network-share is a plausible workflow. ## Related - Introduced alongside the URI import feature (issue #523)
epicleafies commented 2026-03-28 19:47:37 +00:00 (Migrated from github.com)

PR for this issue not ready yet.

PR for this issue not ready yet.
Sign in to join this conversation.
No description provided.