Improve the GUI responsiveness when progress dialogs are used #343

pull hebasto wants to merge 2 commits into bitcoin-core:master from hebasto:210522-ppd changing 4 files +8 −5
  1. hebasto commented at 6:48 pm on May 22, 2021: 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.

  2. qt, macos: Fix GUIUtil::PolishProgressDialog bug
    QProgressDialog shows itself if the estimated time an operation will
    take is beyond the minimumDuration value.
    
    Direct call show() breaks that behavior on macos.
    75850106ae
  3. qt: Improve GUI responsiveness
    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.
    4935ac583b
  4. hebasto force-pushed on May 22, 2021
  5. hebasto added the label UX on May 22, 2021
  6. hebasto added the label Wallet on May 22, 2021
  7. in src/qt/walletcontroller.cpp:211 in 4935ac583b
    206@@ -207,6 +207,9 @@ void WalletControllerActivity::showProgressDialog(const QString& label_text)
    207     m_progress_dialog->setCancelButton(nullptr);
    208     m_progress_dialog->setWindowModality(Qt::ApplicationModal);
    209     GUIUtil::PolishProgressDialog(m_progress_dialog);
    210+    // The setValue call forces QProgressDialog to start the internal duration estimation.
    211+    // See details in https://bugreports.qt.io/browse/QTBUG-47042.
    


    ryanofsky commented at 10:39 pm on May 25, 2021:

    In commit “qt: Improve GUI responsiveness” (4935ac583bbdc289dd31a1caae3d711edef742b6)

    It could be useful to also add this comment other places we’re relying on this behavior (or maybe dedup the code more generally):

    https://github.com/bitcoin/bitcoin/blob/860093401840d7aad7b439aeba0d1598933bc9c6/src/qt/bitcoingui.cpp#L1380 https://github.com/bitcoin/bitcoin/blob/860093401840d7aad7b439aeba0d1598933bc9c6/src/qt/walletview.cpp#L335


    hebasto commented at 10:38 pm on May 26, 2021:

    @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.


    promag commented at 11:23 pm on May 26, 2021:
    Right, the progress here is [0,0].
  8. ryanofsky approved
  9. ryanofsky commented at 10:46 pm on May 25, 2021: contributor
    Code review ACK 4935ac583bbdc289dd31a1caae3d711edef742b6. 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.
  10. in src/qt/guiutil.cpp:826 in 4935ac583b
    824 #endif
    825+    // QProgressDialog estimates the time the operation will take (based on time
    826+    // for steps), and only shows itself if that estimate is beyond minimumDuration.
    827+    // The default minimumDuration value is 4 seconds, and it could make users
    828+    // think that the GUI is frozen.
    829+    dialog->setMinimumDuration(0);
    


    promag commented at 7:50 am on May 26, 2021:
    Why not just show()?

    hebasto commented at 10:27 pm on May 26, 2021:

    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).

  11. promag commented at 7:51 am on May 26, 2021: contributor
    Concept ACK.
  12. promag commented at 11:24 pm on May 26, 2021: contributor
    Code review ACK 4935ac583bbdc289dd31a1caae3d711edef742b6.
  13. jarolrod commented at 0:54 am on May 28, 2021: member

    ACK 4935ac583bbdc289dd31a1caae3d711edef742b6

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

  14. hebasto merged this on May 29, 2021
  15. hebasto closed this on May 29, 2021

  16. hebasto deleted the branch on May 29, 2021
  17. sidhujag referenced this in commit d4b2be303e on May 29, 2021
  18. gwillen referenced this in commit ed3f083e18 on Jun 1, 2022
  19. bitcoin-core locked this on Aug 16, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-10-23 00:20 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me