mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 07:54:42 +00:00
Fee selection and coin control: move remaining queries and writes off the GUI thread #974
Labels
No labels
Android
Bug
Build system
Design suggestion
Doc
Needs design review
Needs rebase
Stage
UX
Up for grabs
Upstream
Wallet
duplicate
enhancement
good first issue
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin-core/gui-qml#974
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent: #923 — Fee selection and coin control.
A transaction notification can refresh the coin list twice, even while its view is hidden. CoinsListModel subscribes to both transaction and balance signals; each refresh scans coins and queries labels and lock state. Locking or unlocking outputs can also write wallet data synchronously.
Selected available-balance reads and custom fee target/rate lookups remain on the GUI thread. The expensive fee-preview calculation already uses a worker, but some preflight and setter queries do not.
Coin views and getters should use cached state. Move remaining queries and persistent lock commands off the GUI thread, avoid redundant backend refreshes, and make completion callbacks apply results only. Preserve selection across reordering, never apply an action to the wrong output, show pending/errors and prevent stale fee results from replacing current values.
Acceptance checks should cover blocked queries and writes with a responsive GUI, repeated notifications, hidden views, changed selections, removed outputs, write failures and stale fee previews.
This was a source-traced risk; the original IBD runs did not measure wallet stalls.
Three concrete cases for the selection and refresh work here, recorded on
qt6atd567e3eb2497, macOS / Qt 6.9.0, using disposable regtest wallets.A temporary reorg snapshot permanently removes a manual selection
listunspentand the GUI selection.The change output returns as spendable, but Send drops from two selected inputs to one. Reconnecting the block does not restore the selection. Mining an ordinary new block preserves both selections.
With that change output as the only selected coin and Use maximum enabled, losing the selection expands the draft to the wallet-wide maximum. The all-funds warning and final review show the larger amount; nothing was broadcast. This adds a transient-refresh trigger to the empty-selection behavior tracked in #1001.
In the tested code,
CoinsListModel::update()removes selections whenever an outpoint is absent from its current coin snapshot. During disconnection, a wallet transaction can briefly be absent before returning to the mempool. Selection intent needs to survive that temporary state, with unavailable inputs handled explicitly rather than broadening the payment’s input scope.View coins retains bulk marks for spent outputs
The spent output is gone and the change output is unchecked, but the footer still says 1 selected, with Lock/Unlock enabled. Clicking Lock clears the count without locking anything.
The separate QML
markedIdslist is not reconciled with removed rows. This is distinct from Send’s manual input selection. An incoming-payment control that merely reordered rows preserved the correct selection.Repeated label scans cause measurable GUI stalls
With Activity open and no coin view visible, an incoming payment to a synthetic wallet containing 5,000 coins and 1,668 receiving addresses blocked GUI responses for approximately 5.5 seconds offscreen and 5.8–5.9 seconds with Cocoa. Labeling the same wallet’s receiving addresses reduced the offscreen stall to about 0.43 seconds.
CoinsListModel::update()asks for every coin’s label. An empty label triggersgetAddressLabel()to scan the full address book, although that fallback cannot supply information missing from the direct lookup. Repeated notifications multiply the work.The tested #990 build’s cached label lookup substantially reduced this cost. The selection cases above still need independent coverage when changing refresh scheduling, particularly temporary absence, actual removal, and reordered rows.
Since #1049 a display-unit change runs this coin-list refresh for every open wallet, including hidden ones.
To reproduce:
Each click leaves the window unresponsive for 0.52 to 0.67 s, offscreen and native. Other measurements with the same wallets:
WalletQmlModel::setDisplayUnitwhile the wallet views are created. With BTC saved there is none.Each open wallet now has its own view (DesktopWallets.qml#L444-L452), and each view's Activity list binds the global unit into its wallet whether or not the view is active (ActivityList.qml#L88-L93).
setDisplayUnitemitsbalanceChanged(walletqmlmodel.cpp#L3187-L3201), which is connected toCoinsListModel::update(coinslistmodel.cpp#L16-L18). That is the per-coin label scan measured above for incoming payments. A unit change does not alter any coin, so it should not need the coin list rebuilt.Before #1049 there was a single Activity list bound to the selected wallet, so a unit change refreshed that wallet only. That comparison is by source; I did not run a build from before #1049.
The cached label lookup tested with #990 should cut the cost of each refresh. I have not checked that branch for the per-wallet binding.
Reproduced on merged
qt6ateed1f426fcb6, macOS / Qt 6.9, isolated regtest, offscreen and native. Clicks went through the test bridge. Timing was noisy on a loaded machine: one native session's closed-wallet control read 0.13 to 0.58 s, and some native runs were several times slower than the figures above for reasons I could not isolate. I have left those out.