Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lp1783392: Configurable debouncing timeout for WSearchLineEdit #1762

Merged
merged 3 commits into from
Dec 9, 2018
Merged

lp1783392: Configurable debouncing timeout for WSearchLineEdit #1762

merged 3 commits into from
Dec 9, 2018

Conversation

uklotzde
Copy link
Contributor

@uklotzde uklotzde commented Jul 24, 2018

Add a configurable debouncing timeout for the search edit field. Depending on the size of their library users are now able to adjust this to mitigate the issues caused by locking the UI thread while searching.

Another user now has exactly reported the same issues that I am experiencing, i.e. Mixxx is almost unusable with bigger libraries and the default settings: https://bugs.launchpad.net/mixxx/+bug/1783392

@uklotzde uklotzde added this to the 2.2.0 milestone Jul 25, 2018
@uklotzde
Copy link
Contributor Author

After reverting the change of the debouncing timeout this PR actually fixes ...nothing.

Actual changes:

  • Simpler state management with less redundant code
  • Type-safe Qt 5 signal/slot connections
  • New signal for disabling the widget instead of using an implicit parameter with scattered code comments

@uklotzde
Copy link
Contributor Author

The setting is now configurable, which might disqualify it from being included in the 2.2 beta.


#define MIXXX_ADDONS_URL "http://www.mixxx.org/wiki/doku.php/add-ons"
Copy link
Member

Choose a reason for hiding this comment

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

This macro is still in use. Is this an unrelated change, slipped in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Slipped in. I didn't notice, because I'm already using a version without plugins for development. I've removed this obsolete #define now from master to prevent such mistakes in the future.

<property name="text">
<string>Edit metadata after clicking selected track</string>
<string>Incremental Search Delay:</string>
Copy link
Member

Choose a reason for hiding this comment

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

This might be misleading for me since "Incremental Search" for me is more an algorithm that works all the time in background guessing the final user result. Google has it in the search bar if the network bandwidth is good enough.
That would be great for Mixxx, but we are not there.

"Search after edit"
"Search As You Type Delay"
Or inverse
"Search inhibit time"

"Zero disables the feature" ??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I will revert back to the debouncing terminology also for the configuration setting for consistency.

For the text on the label we can use one of the proposed variants. Feedback by native speakers and especially non-developers welcome ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want to allow a configurable timeout of 0 to disable this feature entirely. A maximum delay of almost 10 sec should be ok. But I've fixed the code to handle empty or invalid timeouts by not starting the timer.

@uklotzde
Copy link
Contributor Author

The configurable timeout has proven to be very useful to me, because the optimal setting depends on both the size of your library as well as your personal typing speed and habits.

We have a similar fixed timeout for navigation within the side bar that is currently set to kPressedUntilClickedTimeoutMillis = 300. But this is not so sensitive, because when repeatedly clicking a button or turning an encoder you don't have to account for the delays while looking up different keys or thinking about how to finish your search.

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

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

The timeout is bypassed if you delete the last character in the search box.
This also happens also in 2.1.
Can we have a minimal fix it there as well?

If I put the settingsPath on a USB HDD, I can reproduce the leaks. But they only happens if many tracks are shown or hidden due the search.
We may be able to explain it if all tracks are shown again, but why is this happening when tracks are hidden? Do we have a caching issue?

Disabling some columns doe does not change the issue by the way.

.clang-format Outdated
@@ -0,0 +1,108 @@
---
Copy link
Member

Choose a reason for hiding this comment

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

this file addition is unrelated to this PR.

@@ -118,7 +118,7 @@ void DlgDeveloperTools::timerEvent(QTimerEvent* pEvent) {
}
}

void DlgDeveloperTools::slotControlSearch(const QString& search) {
void DlgDeveloperTools::slotControlSearch(QString search) {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this change required? I think we should prefer passing strings by references, to avoid shared counting.o
In the queued connection case Qt makes the copy for us:
https://www.embeddeduse.com/2013/06/29/copied-or-not-copied-arguments-signals-slots/

@@ -325,8 +325,8 @@ void Library::slotLoadTrackToPlayer(TrackPointer pTrack, QString group, bool pla
emit(loadTrackToPlayer(pTrack, group, play));
}

void Library::slotRestoreSearch(const QString& text) {
emit(restoreSearch(text));
void Library::slotRestoreSearch(QString text) {
Copy link
Member

Choose a reason for hiding this comment

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

Please keep passing by const reference here as well, if possible.

@@ -68,7 +68,7 @@ void WLibrary::switchToView(const QString& name) {
}
}

void WLibrary::search(const QString& name) {
void WLibrary::search(QString name) {
Copy link
Member

Choose a reason for hiding this comment

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

Please keep passing by const reference here as well, if possible.

}

void WSearchLineEdit::slotTextChanged(const QString& text) {
// slot
void WSearchLineEdit::updateText(QString text) {
Copy link
Member

Choose a reason for hiding this comment

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

Please keep passing by const reference here as well, if possible.

src/widget/wsearchlineedit.cpp Outdated Show resolved Hide resolved
setAttribute(Qt::WA_MacShowFocusRect, false);
}

void WSearchLineEdit::updatePlaceholder(QString text) {
Copy link
Member

Choose a reason for hiding this comment

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

updatePlaceholder -> updateTextBox()
This function is hard to understand anyway. I would prefer to inline it.
Alternative it may call getSearchText() itselves.

@daschuer
Copy link
Member

The setting is now configurable, which might disqualify it from being included in the 2.2 beta.

Unfortunately yes. Maybe the major issue can be fixed via solving the bypass issue.
A slightly longer delay may also fix some of the issues.

@uklotzde
Copy link
Contributor Author

All intermediate, unwanted, or controversial changes have been reverted and the branch rebased on 2.2.

@uklotzde
Copy link
Contributor Author

uklotzde commented Oct 15, 2018

I cannot confirm that the timeout and timer is bypassed when deleting single characters. Deleting the last character with backspace triggers text changed events and the timer is reset as expected.

@uklotzde
Copy link
Contributor Author

Target branch: One option would be to split the UI changes off from this PR and merge them separately into master. The new configuration remains undocumented, but could already be used by editing a single line in the config file manually.

We might need this configuration option to help fixing issues of users with big libraries. I expect at least some complaints once the new version has been released to a broader audience.

@daschuer
Copy link
Member

If you think this option can be essential for 2.2 I think it is better to merge it including the GUI changes. A non translated essential feature is better than a hidden essentially feature. Both share the same regression risk.

Is this search bar issue a regression from 2.1? If yes, let's include it.

@daschuer
Copy link
Member

daschuer commented Oct 15, 2018

Are you able to reproduce the deleting the last character GUI freezing?

@uklotzde
Copy link
Contributor Author

Deleting the last characters works as like any other editing operation and restarts the timer as expected.

@uklotzde
Copy link
Contributor Author

With Qt4 I was able to continue typing while the UI was frozen and ended up with the search phrase I typed. With Qt5 the characters typed while the UI is frozen are reordered in unforeseeable ways.

@daschuer
Copy link
Member

The issue with the last character is "emit searchCleared();" during typing.
Can't we remove this signal completely and check for empty in onSearch?

I am also still unsure about the target branch.
Do we have other users suffering the character mix up issue?

@uklotzde
Copy link
Contributor Author

I misunderstood your description "last character"! Ok, now I got it. Deleting the last character before the edit field becomes empty ;)

@uklotzde uklotzde changed the title lp1783392: Improve debouncing for WSearchLineEdit [WiP] lp1783392: Improve debouncing for WSearchLineEdit Oct 16, 2018
@uklotzde uklotzde changed the title [WiP] lp1783392: Improve debouncing for WSearchLineEdit lp1783392: Improve debouncing for WSearchLineEdit Oct 16, 2018
@uklotzde
Copy link
Contributor Author

  • Another rebase to restore the lost disabledSearch() signal from the previous rebase
  • Activate timer upon deletion of last character in field
  • Simpler and more robust state handling

It still doesn't feel right, but I'm tired of improving this even more. I will only fix outstanding bugs. No backport to 2.1, this has already cost me much more time then planned.

@daschuer
Copy link
Member

Thank you.
What do you mean by:

It still doesn't feel right?

We also don't have a conclusion if this as suits for 2.2. Do we know if this a Wayland issue?

I have tried to find something about the key stroke reordering on the web, but I haven't found anything.
Does it mean that this is induvidual an issue of your setup? Or is it sn issue that only happens with a certain Wayland and Qt version? Or is it a simple Mixxx bug?
What do you think?

@uklotzde
Copy link
Contributor Author

"still not right": The underlying state machine with its side effects is still complicated. I'm not able to guarantee that all possible states and transitions are covered and work as expected. Testing with a large library that causes ui freezes and by varying the timeout were hopefully sufficient to reveal and fix most issues.

@uklotzde uklotzde changed the title lp1783392: Improve debouncing for WSearchLineEdit [WiP] lp1783392: Improve debouncing for WSearchLineEdit Oct 20, 2018
@uklotzde uklotzde changed the base branch from 2.2 to master October 21, 2018 18:02
@uklotzde uklotzde modified the milestones: 2.2.0, 2.3.0 Oct 21, 2018
@uklotzde
Copy link
Contributor Author

I've update the target to master/2.3.0, but I will keep this branch aligned with 2.2 until we know if this is an issue that affects multiple users.

@uklotzde uklotzde changed the title [WiP] lp1783392: Improve debouncing for WSearchLineEdit lp1783392: Improve debouncing for WSearchLineEdit Oct 23, 2018
@uklotzde uklotzde changed the base branch from master to 2.2 November 13, 2018 18:18
@daschuer daschuer mentioned this pull request Nov 15, 2018
@uklotzde uklotzde changed the title lp1783392: Improve debouncing for WSearchLineEdit [REBASE NEEDED] lp1783392: Improve debouncing for WSearchLineEdit Nov 18, 2018
@uklotzde uklotzde changed the title [REBASE NEEDED] lp1783392: Improve debouncing for WSearchLineEdit lp1783392: Configurable debouncing timeout for WSearchLineEdit Dec 3, 2018
@daschuer
Copy link
Member

daschuer commented Dec 9, 2018

Let's merge this to 2.2 even if we have untranslated strings. Without it, Mixxx might be unusable for some users.

@daschuer
Copy link
Member

daschuer commented Dec 9, 2018

Thank you!

@daschuer daschuer merged commit 35602e5 into mixxxdj:2.2 Dec 9, 2018
@uklotzde uklotzde deleted the lp1783392_wsearchlineedit branch December 26, 2018 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants