PLAT-109381: Reduce the ImageItem render time#2790
Conversation
Enact-DCO-1.0-Signed-off-by: YB Sung (yb.sung@lge.com)
Enact-DCO-1.0-Signed-off-by: YB Sung (yb.sung@lge.com)
Enact-DCO-1.0-Signed-off-by: YB Sung (yb.sung@lge.com)
Codecov Report
@@ Coverage Diff @@
## develop #2790 +/- ##
===========================================
+ Coverage 44.61% 44.80% +0.18%
===========================================
Files 163 164 +1
Lines 8158 8187 +29
Branches 1991 1994 +3
===========================================
+ Hits 3640 3668 +28
- Misses 3391 3392 +1
Partials 1127 1127
Continue to review full report at Codecov.
|
Enact-DCO-1.0-Signed-off-by: YB Sung (yb.sung@lge.com)
Enact-DCO-1.0-Signed-off-by: YB Sung (yb.sung@lge.com)
Enact-DCO-1.0-Signed-off-by: YB Sung (yb.sung@lge.com)
Enact-DCO-1.0-Signed-off-by: YB Sung (yb.sung@lge.com)
Enact-DCO-1.0-Signed-off-by: YB Sung (yb.sung@lge.com)
Enact-DCO-1.0-Signed-off-by: YB Sung (yb.sung@lge.com)
This reverts commit e3b81ca.
Enact-DCO-1.0-Signed-off-by: YB Sung (yb.sung@lge.com)
Enact-DCO-1.0-Signed-off-by: YB Sung (yb.sung@lge.com)
Enact-DCO-1.0-Signed-off-by: YB Sung (yb.sung@lge.com)
Enact-DCO-1.0-Signed-off-by: YB Sung (yb.sung@lge.com)
Enact-DCO-1.0-Signed-off-by: YB Sung (yb.sung@lge.com)
MikyungKim
left a comment
There was a problem hiding this comment.
Much better shape! Thank you for your efforts.
LGTM!
There was a problem hiding this comment.
It's not completely clear to me that each of these changes is required to get the performance necessary. In fact, there may be performance and memory regressions from this. Certainly this is much more complicated and it may not be a general solution that could be applied to different components. I'm also not certain that many of the issues might not be resolved by making portions of the components Pure or by taking other approaches other than using context.
There's not a clear breakdown by how much improvement each piece of this gives to the overall performance. Because of the complexity, I don't think we can move forward with this solution right now.
If we really need to go further, then it seems like we might want to just directly mutate the DOM in these special instances. At least, we'd know the trade-offs we're making in terms of performance for this (and other) components.
|
|
||
| render: ({children, css, imageComponent, orientation, placeholder, src, ...rest}) => { | ||
| render: ({className, memoizedChildrenCell, memoizedImageCell, orientation, ...rest}) => { | ||
| delete rest.css; |
There was a problem hiding this comment.
You don't need to delete css, I believe it's non-enumerable.
| const omitted = omit(filter, props) || {}; | ||
|
|
||
| return ( | ||
| <MemoPropsContext.Provider value={picked}> |
There was a problem hiding this comment.
This will force the component to update every time it receives props, even if the values are exactly the same, because the object has changed and context will force the update. Some form of memoization should be done if this truly is the desired solution.
|
|
Checklist
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
childrenfor caption,labelfor subcaption,imageIconComponent,imageIconSrc, andsrcnot as props but thought a context so that we don't have to render several components again.Update the caption, subcaption, and data-index DOM elements directly instead of rendering components.Additional Considerations
Links
PLAT-109381
Related PR: enactjs/sandstone#461
Previous Branch: https://github.com/enactjs/enact/tree/PLAT-109381-useMemo2
Comments
Enact-DCO-1.0-Signed-off-by: YB Sung (yb.sung@lge.com)