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

XWIKI-22540: Slow loading time when changing the icons theme to Silk in the Icon picker #3537

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Sereza7
Copy link
Contributor

@Sereza7 Sereza7 commented Oct 4, 2024

Jira URL

https://jira.xwiki.org/browse/XWIKI-22540

Changes

Description

  • Added a flag on the data_icons action to only retrieve metadata when necessary. This shaves off half of the time for the request and reduces significantly the size of the payload
  • Updated slightly the IconPicker javascript to improve readability

Clarifications

  • This PR is not enough to close the ticket, this represents a 50% reduction in the waiting time but it's still too high. Closing it will happen only when we can figure out a way to speed up loading icons, with https://jira.xwiki.org/browse/XWIKI-11112 for example.

Screenshots & Video

N/A, performance issue only

Executed Tests

Manual tests, time to display was reduced by half. Locally, the request before the changes would take about 5 seconds. This was most of the waiting time. After the PR, this request was only half as long (2 to 2.5s).

Expected merging strategy

…in the Icon picker

* Added a flag on the data_icons action to only retrieve metadata when necessary. This shaves off half of the time for the request and reduces significantly the size of the payload
…in the Icon picker

* Refactored the IconPicker javascript to improve readability
…in the Icon picker

* Removed unwanted changes
Copy link
Member

@mflorea mflorea left a comment

Choose a reason for hiding this comment

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

Adding a flag for the metadata is a good idea, but I think the real fix is to add pagination to the icon picker. Loading more icons could be triggered by scroll or by clicking on a "Load more..." link. Also, the icon filtering could be done server side (I already added support for this on d80394a).

@@ -52,6 +52,7 @@ define('xwiki-iconService', [
iconsPromise = iconsPromisesPerTheme[query] = $.getJSON(getResourceURL('data_icons', {
iconTheme,
query,
'metadata': 'true'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'metadata': 'true'
metadata: true

I'm wondering if this can't be considered a breaking change by those (extensions) that use the icon picker data_icons URL as an API. Sure, it's not as public / advertised as the icon REST API, but wouldn't it be safer to return the icon metadata by default (i.e. keep the current behavior) and to pass metadata: false when you don't need it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those metadatas were added in 15.7, with https://jira.xwiki.org/browse/XWIKI-20979.

It's likely that most uses of this API in the extensions/user customizations do not need or want those metadatas and got significantly slower when we added them by default. IMO the default should still be without it: in our use cases it has been reported as a performance regression, and I think it would end up similarly for most customizations.

At the end of the day, we need to choose one:

  • Break extensions made between 15.7 and 16.10 that rely on the metadata.
  • Have all extensions relying on this rest API being twice as slow as they were before 15.7

Note that if we chose the first one, we can add a note about it in the release notes, and with the appropriate documentation update, it should be quite straightforward to fix for the impacted extension maintainers.


I'm keeping the PR as is for now, let me know if you think my argumentation and choice is not correct and I'll update it :)

Copy link
Member

Choose a reason for hiding this comment

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

OK, let's keep it like this then, and add a note in the RN.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should cache the icon metadata, and make it fast through the cache, not by excluding the metadata by default.

Copy link
Member

Choose a reason for hiding this comment

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

For me the priority should be to add some kind of pagination to the icon picker because it doesn't scale currently. Adding the icon metadata cache is nice, but I'm not sure if it will solve the slowness (for an image-based icon theme like Silk where the icon picker needs to fetch and display 1k+ image icons).

Sereza7 and others added 2 commits December 9, 2024 17:43
…in the Icon picker


* Fix codestyle

Co-authored-by: Marius Dumitru Florea <[email protected]>
…in the Icon picker


* Fixed codestyle

I didn't rerun all the tests.

Co-authored-by: Marius Dumitru Florea <[email protected]>
@@ -243,8 +243,7 @@ require(['jquery', 'xwiki-icon-picker'], function($) {
selectedIconName = currentInput[0].value.replace(currentInput.data('xwikiIconPickerSettings').prefix, '');
}
// For each icon
for (var i=0; i &lt; iconList.length; ++i) {
let icon = iconList[i];
iconList.forEach(icon => {
Copy link
Member

Choose a reason for hiding this comment

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

You need a closing ) at the end (I couldn't add it as a code suggestion :) ).

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.

3 participants