Performance MetaDataEditor Gallery Freezing when Starting to Drag Thumbnails #5116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Issues:
When dragging thumbnails in the gallery panel of the meta data editor, the browser freezes for a short while before the actual dragging starts. This freezing is related to two things:
This pull request deals with the second part only. You can test it by dragging an already selected thumbnail like so:
simplescreenrecorder-2022-04-29_13.14.00.mp4
The problem is related to the jquery-ui implementation itself. Apparently, the large number of droppable components inside the gallery panel causes a problem in the
prepareOffsets
method of jquery-ui. The main loop "droppablesLoop" contains statements that both adapt the DOM layout and measure the DOM layout for element positions (offsets). Because of that, the browser needs to re-calculate the current layout of the page multiple times while this loop is processed, which is very computationally expensive for large pages and causes a freeze of the browser.This pull request injects a slight adaptation of this method into jquery-ui, such that the method is executed much more efficiently, and dragging thumbnails starts almost immediately.
simplescreenrecorder-2022-04-29_13.21.53.mp4
Drawbacks
Any updates to jquery-ui might break the adapted implementation of
prepareOffsets
. Of course, ideally, this change should be made upstream.