-
Notifications
You must be signed in to change notification settings - Fork 384
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
Lag when dragging elements #3458
Comments
Also having some mega lag issues. Created a video that shows the lags. |
Starting looking into this (Implementation Brief). |
I'm looking into this and when I disable Snapping then the lagging does not happen. So it still seems to me as if this is related to Snapping. @barklund You mentioned that you had seen the lagging for a while already, already pre-snapping. Do you happen to remember if you saw this with dragging or somewhere else as well? |
Looks like Q: Perhaps we could detect if the cursor is moving slowly or has stopped, and only then do the snapping thing? It's likely that the cursor (user) would slow down when trying to position, or WDYT? It might make the user experience better as well, right now there are so many lines moving around that it's quite confusing (to me at least). Thoughts? |
Additionally, I'm trying to think of a reasonable way to call Not sure what could be a reasonable logic for setting the state less frequently. Perhaps even do it every X Any ideas/thoughts are welcome! |
If think that here were no problems with this early on, when the components actually used this property? |
Also reported in #3462. If it's not needed, removing sounds good to me. |
@barklund If I understood correctly then you meant removing this, is that correct?
If that's correct, then I tried removing this, it doesn't seem to make any change, still lagging. Q: Is it generally a "normal" use-case to use |
I have updated the PR at #3484 so that the fix suggested by Miina. As noted, this change doesn't improve performance noticeably. But it is still a valid change, as does fix the notice error. |
I would say no. Calling the store should be seen as slow / unreliable, depending the size of the store. Is there anyway to limit the number of calls to store? Either with batching or a simple timeout? |
Also had a similar and some additional ideas, in this and this comment. Would like to know first if calling the @barklund Since you probably have more experience with hooks, then .. Based on your experience, do you think that just calling |
In the initial implementation I made, there was the same updating of the local state inside the context on every mouse move and it had no noticeable lag. Updating an internal state locally in a component is cheap. Updating the global registry is expensive, but I don't think it's doing that. Have you tried using the built-in profiler to hunt for the problematic functions? |
No, I haven't, I've so far hunted the problematic functions manually and detected that
So, from that, I concluded that Not sure what else (in the plugin) might influence this.
Do you mean the Chrome Profiler for example? Will check now |
I think he meant the one in React dev tools |
I figured it out. Debounce helped a lot, but I also recommend making less potential snap lines as described above. Please review @swissspidy (you probably understand the current code the best). |
Why 10ms? Just interested how you came to that number. Why not 15 or 20? |
IB looks good to me. The |
Fair enough. I trust you picked the best value. Just wondered. |
See #2992 for general snapping screencast. |
still lagging video - https://drive.google.com/file/d/1Nlj9UzKYckZNIKoqRIsj4zbhXbPKTglE/view |
@csossi Could you test this again just in case? Not seeing the issue, tried both locally and in the test environment. If you're still seeing the issue, could you please link the Story you were testing with as well? Thank you! |
Also interesting would be if the lagging continues when holding down the alt/option key while dragging. |
Verified in QA |
Bug Description
In #3060 it was mentioned:
The last part might be covered by #3455, not sure though.
Expected Behaviour
Consistently smooth interactions without lagging. No issues with selecting and dragging blocks.
Steps to reproduce
Screenshots
Additional context
develop
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation brief
Two optimizations are recommended for getting smoother snap line display:
setSnapLines
by 10 ms.horizontalSnaps
inhorizontalEdgeSnaps
andhorizontalCenterSnaps
inwith-snap-target.js
. And consequently use these separately for calculations when finding optimal snap lines ingetBestSnapLines
.QA testing instructions
Verify smooth drag without lagging:
Verify proper snap lines between element and page:
Verify proper snap lines between two elements:
Demo
Addressed by
Changelog entry
The text was updated successfully, but these errors were encountered: