-
Notifications
You must be signed in to change notification settings - Fork 635
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
DYN-8045: Fix hanged node search when the user types faster than search #15733
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-8045
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. But I would like to know what @QilongTang thinks about it.
Failed on test |
@QilongTang this seems to overlap with #15726 am I getting that right? How do you want to proceed with these two prs? |
@QilongTang after taking a look at this I think I prefer the approach in #15726 - it's behind a feature flag, has tests, avoids locks, and I think is more idiomatic. I don't know if it solves the issue of the hanging search though - @bendikberg can you verify if it fixes this issue? |
Improvements in last commit:
|
UI Smoke TestsTest: success. 11 passed, 0 failed. |
Added unit tests for debouncing. |
@mjkkirschner Since @chubakueno 's solution doesn't rely on timeouts and the searches run asynchronously it probably feels even more responsive than mine, which I think is great. Maybe there is a way to combine the approaches? |
|
||
namespace Dynamo.Wpf.Utilities | ||
{ | ||
public static class JobDebouncer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
can you add some more description to this utility, as to when this should be used? I understand we all know that answer already, but would like to document so everyone and new developers on team also learn to use it.
-
There are also a few other instances using deboucer in our code, can you unify the usage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a class summary description. The PR as currently is already unifies both library (sidebar) and incontext node search into using the debouncer, but I can't find more instances of a debouncer being used in c# code (there are some in html/js webview code though).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, looks solid. The things worries me most are that we have a couple instances in Dynamo leveraging debouncer differently in Dynamo (mostly around search), it would be good to unify the usage. Off course, the change in this PR to have a utility class for deboucer is a great start!
Yeah I noticed, do we want to test both in build and pick or combine the approach somehow? I do like the fact the debouncer becomes utility in this PR |
|
||
if (luceneSearchUtility != null) | ||
if (luceneSearchUtility == null) return null; | ||
lock (luceneSearchUtility) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this still required in addition to the search operations taking a lock out on the queue token?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lock is in case Search is used in parallel. As of now that could only happen if the user searches in the library and workspace simultaneously, since both have independent serial queues. We could mandate a unified search queue (for library, inCanvasSearch, and in the future) or have this lock to allow several search queues in parallel.
@@ -0,0 +1,80 @@ | |||
//https://github.com/gentlee/SerialQueue/blob/master/SerialQueue/SerialQueue.cs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@QilongTang do we need to update the about box for this?
yeah, I'm not sure. I still think that anything that introduces locks, or await etc should be behind a feature flag because Dynamo is not thread safe makes all sorts of assumptions, and runs in different threading contexts (Revit, sandbox etc) and I would want a way to turn this (or the other PR) off in released code. That might be overkill but it's not that hard to do in the other PR, it might be harder here. A single denouncer utility is useful, I definitely appreciate having less ways of doing things, not more. The serial queue code seems small enough to take on, but I'd be curious about built in types that could do the same. |
Closest built in type that i have evaluated is |
@chubakueno based in this comment, if the search is being executed asynchronously, is there a guarantee that the search results are always from the last character typed (I mean all the characters that you already typed )? |
Yes the last search is always from the last character typed. It may have to wait for a single pending search to execute (without blocking the UI thread), but last character typed is always last search. |
Purpose
Currently the node search hangs when the user types faster than the time it takes Lucene to provide results because it is searching in the main UI thread. This PR provides a debouncing algorithm and performs searches sequentially outside of the main UI thread for a smoother search experience. Currently there is no support for cancelling previous search tasks in lucenenet so this is a fix around that limitation
Before fix:
After fix:
Declarations
Check these if you believe they are true
*.resx
filesRelease Notes
Prevent node search from hanging during fast typing.
Reviewers
@RobertGlobant20
@QilongTang
@sm6srw
FYIs
@avidit