-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Batch container block settings action calls #43958
Batch container block settings action calls #43958
Conversation
Size Change: +194 B (0%) Total Size: 1.26 MB
ℹ️ View Unchanged
|
Here's the result of the PR so far. The numbers improve a lot but we're not back entirely to the previous results (before list block). It's important to note that now the test post contains 1400 blocks where previously it was 1000. The reason is because when the post is loaded the content is migrated and list blocks with inner blocks are created. That difference in the number of blocks mean there are more components to render causing an impact as well on the numbers. It also looks like there are some e2e test failures due to my optimizations, which I'll have to figure out before merging this. |
@@ -98,7 +101,29 @@ export default function useNestedSettingsUpdate( | |||
} | |||
|
|||
if ( ! isShallowEqual( blockListSettings, newSettings ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What setting causes isShallowEqual
to be false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
none, it's just the first time this gets called, it needs to be batched across the 500 blocks that call it in the same render commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, ok. Why is that not initialised/preloaded in the store though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, am bit slow today. Because the information is in a React component of course.
@@ -68,19 +68,26 @@ export default function useInnerBlockTemplateSync( | |||
innerBlocks, | |||
template | |||
); | |||
|
|||
if ( ! isEqual( nextBlocks, innerBlocks ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come isEqual
returns false so much here? Blocks shouldn't change during load?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't, the change here was a consequence of the change above to fix ctrl + click
in the inserter.
5ea4352
to
4930cc5
Compare
Hey @geriux This PR improves the performance of container blocks drastically but it seems I have a failing mobile unit test. Would you have time to help me understand and fix this failure? Thank you. |
Hey there 👋 I'll check it out 👍 |
@youknowriad I have a fix for the tests that are failing, I also tested and the list block works correctly with these new changes 🎉 . Do you want me to push those to your branch or should I create a PR using this branch as base? Let me know 😃 Thanks! |
Go push here. Thanks @geriux |
Mobile unit tests are passing now 🚀 let us know if you have any other issues. Thanks! |
@geriux Looks like there's a new failure (group block) this time. 😬 |
It is now merged ✅ |
- Remove V1 List block tests - Updates the insertion test to add triggering of the onLayout event for the block list
bca027b
to
1c4aa64
Compare
packages/block-editor/src/components/inner-blocks/use-nested-settings-update.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Matias Ventura <[email protected]>
fb834f1
to
04814d9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Riad!
packages/block-editor/src/components/inner-blocks/use-inner-block-template-sync.js
Outdated
Show resolved
Hide resolved
return state; | ||
} | ||
|
||
// TODO: This is a source of bug, as each time there's a change in timing, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to add more info here about what the bug actually is, for future reference. Maybe the link to the PR? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no identified bug, it's just a bad pattern (returning undefined from a reducer) that can cause bugs quickly and these bugs are very hard to track.
Co-authored-by: Nik Tsekouras <[email protected]>
Co-authored-by: Nik Tsekouras <[email protected]> Co-authored-by: Gerardo <[email protected]> Co-authored-by: Matias Ventura <[email protected]>
I just cherry-picked this PR to the wp/6.1 branch to get it included in the next release: c21b626 |
What?
It seems that the introduction of the list block with inner blocks highlighted an issue with the initial rendering of container blocks. (You can see that the loading metric increased by 200%).
The issue is that each time a container block is rendered a
updateBlockListSettings
action is triggered calling a potential attempt to re-render the components on the page. So if you load a post with 50 container blocks, it will try to re-rendered the components on the page 50 times.How?
This PR attempts to solve that by batching the calls to
updateBlockListSettings
to ensure they only trigger a single re-render.Testing Instructions
The performance job should tell us whether this PR solves the issue or not.