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

PLAT-109381: Reduce the ImageItem render time #461

Closed
wants to merge 35 commits into from

Conversation

ybsung
Copy link
Contributor

@ybsung ybsung commented Jun 15, 2020

Checklist

  • I have read and understand the contribution guide
  • A CHANGELOG entry is included
  • At least one test case is included for this feature or bug fix
  • Documentation was added or is not needed
  • This is an API breaking change

Issue Resolved / Feature Added

One of the major cause for the list scroll performance is the long JS execution time of the ImageItem. So we need to reduce the ImageItem render time.

Resolution

  1. Memoization of the kind computed values and some React elements.
  2. Pass children for caption, label for subcaption, imageIconComponent, imageIconSrc, and src not as props but thought a context so that we don't have to render several components again.
  3. Update the caption, subcaption, and data-index DOM elements directly instead of rendering components.

By doing it, the number of the React elements rendering could be reduced.

For example, with the develop branch without the PR
14 React elements are re-rendered to update the src from the sandstone/ImageItem (ImageItem in the diagram below) to the ui/Image (ui:Image in the diagram below).

image

With the PR
only some of those React elements are re-rendered to do it because the src will be passed through a context from the Context.Provider in the sandstone/Image to Context.Consumber before ui/Image.

image

As we do with the src, children for the caption, label for the subcaption, imageIconComponent, and imageIconSrc are also passed through a context. Those props are one being updated frequently while scrolling a VirtualList (or VirtualGridList) and swapping items.

Therefore we could enhance the list scroll performance by reducing the ImageItem rendering time. It's the major cause for the low performance.

Additional Considerations

Links

PLAT-109381
Related PR: enactjs/enact#2790
Previous branch: https://github.com/enyojs/sandstone/tree/PLAT-109381-useMemo2

Comments

Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])

Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
ybsung added 7 commits June 16, 2020 13:54
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
This reverts commit 8f471c6.
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
ImageItem/ImageItem.js Outdated Show resolved Hide resolved
ybsung added 19 commits June 17, 2020 16:28
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
ybsung added 3 commits June 18, 2020 10:57
This reverts commit 65fa755.
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
ImageItem/ImageItem.js Outdated Show resolved Hide resolved
ybsung added 3 commits June 18, 2020 15:25
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
Copy link
Contributor

@MikyungKim MikyungKim left a comment

Choose a reason for hiding this comment

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

LGTM!

ybsung added 2 commits June 18, 2020 18:25
Enact-DCO-1.0-Signed-off-by: YB Sung ([email protected])
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ybsung
Copy link
Contributor Author

ybsung commented Oct 29, 2021

Due to Contributor License Agreement, I'd like to close this PR.

@ybsung ybsung closed this Oct 29, 2021
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