Skip to content

Improve the GUI responsiveness when progress dialogs are used - #343

Merged
hebasto merged 2 commits into
bitcoin-core:masterfrom
hebasto:210522-ppd
May 29, 2021
Merged

hebasto merged 2 commits into
bitcoin-core:masterfrom
hebasto:210522-ppd

Conversation

@hebasto

@hebasto hebasto commented May 22, 2021

Copy link
Copy Markdown
Member

QProgressDialog estimates the time the operation will take (based on time for steps), and only shows itself if that estimate is beyond minimumDuration.

The default minimumDuration value is 4 seconds, and it could make users think that the GUI is frozen.

This PR sets minimumDuration to zero for all progress dialogs, that affects ones in the WalletControllerActivity class.

hebasto added 2 commits May 22, 2021 21:33
QProgressDialog shows itself if the estimated time an operation will
take is beyond the minimumDuration value.

Direct call show() breaks that behavior on macos.
QProgressDialog estimates the time the operation will take (based on
time for steps), and only shows itself if that estimate is beyond
minimumDuration. The default minimumDuration value is 4 seconds, and it
could make users think that the GUI is frozen.

@ryanofsky ryanofsky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK 4935ac5. I'm not very familiar with this API but all the changes and explanations make sense and are very clear, and this seems like it should be an improvement.

Comment on lines +210 to +211
// The setValue call forces QProgressDialog to start the internal duration estimation.
// See details in https://bugreports.qt.io/browse/QTBUG-47042.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryanofsky

Thank you for your review.

I agree with you that there is a possibility to dedup the code more generally. As such a change must be refactoring, I intentionally leaved it for a follow up, if there are no objections from you.

A comment added here because this dialog is not actually a "progress" one, it is a busy indicator without meaningful values. But it requires to call setValue(0) to start internal timer.

In other cases calling setValue() is natural, as dialogs are real "progress" ones, and the value shows the progress.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the progress here is [0,0].

@promag promag left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK.

Comment thread src/qt/guiutil.cpp
// for steps), and only shows itself if that estimate is beyond minimumDuration.
// The default minimumDuration value is 4 seconds, and it could make users
// think that the GUI is frozen.
dialog->setMinimumDuration(0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just show()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From QTBUG-47042:

QProgressDialog is designed to show itself automatically, based on an internal estimate for the duration of the operation and the minimumDuration property. You never call show() or exec() on it manually. You're also not supposed to keep it around when it's not used. In 5.4, the only way to start the internal duration estimation was to call setValue(0). But we noticed that many people didn't call setValue(0), but just handed external progress information on to the progress dialog, and whether or not that progress information started at 0 or, say, 1, would determine whether the dialog would show itself at all, or not. This was thought to be a bit fragile, so we changed it so that the start time of the duration estimate was the dialog construction time unless setValue(0) (or, more correctly, setValue(minimum()) was called, leading to the dialog showing itself minimumDuration after its construction, even if it was constructed not for immediate use (which the dialog cannot distinguish from a really long-running operation).

@promag promag left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK 4935ac5.

Comment on lines +210 to +211
// The setValue call forces QProgressDialog to start the internal duration estimation.
// See details in https://bugreports.qt.io/browse/QTBUG-47042.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the progress here is [0,0].

@jarolrod jarolrod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 4935ac5

Code review ACK and light tested ACK of progress bars. Patch looks good.

@hebasto
hebasto merged commit be1c512 into bitcoin-core:master May 29, 2021
@hebasto
hebasto deleted the 210522-ppd branch May 29, 2021 14:16
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 29, 2021
…ess dialogs are used

4935ac5 qt: Improve GUI responsiveness (Hennadii Stepanov)
7585010 qt, macos: Fix GUIUtil::PolishProgressDialog bug (Hennadii Stepanov)

Pull request description:

  [`QProgressDialog`](https://doc.qt.io/qt-5/qprogressdialog.html) estimates the time the operation will take (based on time for steps), and only shows itself if that estimate is beyond [`minimumDuration`](https://doc.qt.io/qt-5/qprogressdialog.html#minimumDuration-prop).

  The default `minimumDuration` value is [4 seconds](https://doc.qt.io/qt-5/qprogressdialog.html#details), and it could make users think that the GUI is frozen.

  This PR sets `minimumDuration` to zero for all progress dialogs, that affects ones in the `WalletControllerActivity` class.

ACKs for top commit:
  ryanofsky:
    Code review ACK 4935ac5. I'm not very familiar with this API but all the changes and explanations make sense and are very clear, and this seems like it should be an improvement.
  promag:
    Code review ACK 4935ac5.
  jarolrod:
    ACK 4935ac5

Tree-SHA512: 2ddd74e7fd87894d341d2439dbaa544d031a350f7f57d4c7e9fbba977dc24080fe60fd7a80a542b1647f1de9091d7fd04a36eab695088d4d75fb836548e99b5f
gwillen pushed a commit to ElementsProject/elements that referenced this pull request Jun 1, 2022
@bitcoin-core bitcoin-core locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

UX All about "how to get things done" Wallet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants