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

Performance MetaDataEditor Gallery Freezing when Starting to Drag Thumbnails #5116

Conversation

thomaslow
Copy link
Collaborator

@thomaslow thomaslow commented Apr 29, 2022

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:

  1. if the thumbnail was not yet selected, it is now selected, which triggers a synchronization between the structure panel and gallery panel, which is slow
  2. jquery-ui activates all droppable components (the little placeholder components that represent where a thumbnail can be dropped) and calculates position offsets to be able to detect where the thumbnail is dropped

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.

thomaslow and others added 2 commits May 4, 2022 11:36
@Kathrin-Huber Kathrin-Huber merged commit 8a61b00 into kitodo:master May 13, 2022
@thomaslow thomaslow deleted the performance-metadataeditor-drag-start-freezing branch May 19, 2022 10:01
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