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

Widget Visibility: Disable in Block Editor #17413

Merged
merged 2 commits into from
Oct 9, 2020

Conversation

tyxla
Copy link
Member

@tyxla tyxla commented Oct 8, 2020

Currently, on widget_admin_setup, in the Widget Visibility module we'll run heavy operations to retrieve a bunch of entities, but we only really use those on the widgets page. Among those entities include all pages, categories, tags, custom taxonomy terms, all registered post types, users. For sites that don't leverage cache and have many pages with a lot of content, this can cause significant delays in TTFB and even end up in OOM errors.

The reason for this is that since Gutenberg 8.3 we call the widget_admin_setup hook on the block editor, too (see WordPress/gutenberg#22807), but never actually use this data in the block editor. This means that we can disable the heavy logic on the block editor pages. This is what this PR does.

Note that this intentionally touches WP.com files. We'd like this improvement to be done there, too.

Changes proposed in this Pull Request:

  • Widget Visibility: Disable in Block Editor

Jetpack product discussion

No related discussion. This is related to recent block editor perf improvements in p4TIVU-9uP-p2. See p7H4VZ-2KJ-p2 for more information.

Does this pull request change what data or activity we track or use?

Not at all.

Testing instructions:

  • Go to the Widgets screen.
  • Verify the Widget Visibility functionality still works well.

Proposed changelog entry for your changes:

  • Disable Widget Visibility admin setup in Block Editor

Currently, on `widget_admin_setup`, in the Widget Visibility module we'll run heavy operations to retrieve a bunch of entities, but we only really use those on the widgets page. Among those entities include all pages, categories, tags, custom taxonomy terms, all registered post types, users. For sites that don't leverage cache and have many pages with a lot of content, this can cause significant delays in TTFB and even end up in OOM errors.

The reason for this is that since Gutenberg 8.3 we'll call the `widget_admin_setup` hook on the block editor, too (see WordPress/gutenberg#22807), but never actually use this data in the block editor.

This means that we can disable the heavy logic on the block editor pages. This is what this PR does.
@tyxla tyxla added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Feature] Widget Visibility [Focus] Performance [Status] Needs Review To request a review from Crew. Label will be renamed soon. [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack labels Oct 8, 2020
@tyxla tyxla added this to the 9.1 milestone Oct 8, 2020
@tyxla tyxla requested review from a team October 8, 2020 08:19
@tyxla tyxla self-assigned this Oct 8, 2020
@tyxla tyxla requested review from mdbitz and removed request for a team October 8, 2020 08:19
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello tyxla! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer and confirm D50832-code works as expected before merging this PR. Once this PR is merged, please commit the changes to WP.com. Thank you!
This revision will be updated with each commit to this PR

Suggest future replacing with `wp_should_load_block_editor_scripts_and_styles()`
@jetpackbot
Copy link

Scheduled Jetpack release: November 3, 2020.
Scheduled code freeze: October 27, 2020

E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-17413

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Generated by 🚫 dangerJS against 570883f

@tyxla
Copy link
Member Author

tyxla commented Oct 8, 2020

Not sure why the wpcom check reports tests as failed, but they actually passed.

Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

This should do the trick for now. 👍

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! [Pri] Normal and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Oct 8, 2020
@simison
Copy link
Member

simison commented Oct 8, 2020

How does this behave with latest Gutenberg plugin and Block editor Widget screen enabled?

@tyxla
Copy link
Member Author

tyxla commented Oct 8, 2020

How does this behave with latest Gutenberg plugin and Block editor Widget screen enabled?

I don't think this screen is affected in any way. The new block editor widget screen is essentially a new page in the admin, and doesn't even call the widget_admin_setup hook or any other related hook that we run on the old-school widgets page.

@tyxla
Copy link
Member Author

tyxla commented Oct 8, 2020

@jeherve thanks a bunch for the review 🙌 would be really appreciated if you could take a look at the corresponding diff, too. Thanks!

@simison
Copy link
Member

simison commented Oct 8, 2020

FYI @adamziel in context of WordPress/gutenberg#25836

@jeherve jeherve added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Ready to Merge Go ahead, you can push that green button! [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Oct 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Widget Visibility [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Focus] Performance [Pri] Normal Touches WP.com Files [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants