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

Tiled Galllery Block: update Platform implementation to avoid pulling too many dependencies #22445

Closed
jeherve opened this issue Jan 21, 2022 · 6 comments · Fixed by #22547
Closed
Assignees
Labels
[Block] Tiled Gallery [Focus] Performance [Pri] Normal [Type] Bug When a feature is broken and / or not performing as intended

Comments

@jeherve
Copy link
Member

jeherve commented Jan 21, 2022

This is a follow-up from #21849.

The block update pulls Platform, from @wordpress/element. That is problematic as the whole package (and its dependencies, React, React Dom, and lodash) is then added as a dependency and then enqueued in the editor as well as on the frontend to render the gallery.

It would be nice to refactor this so we only add what we need. While we do try to use WordPress packages whenever possible, we aim to be as frugal as possible for frontend dependencies.


cc @illusaen, @guarani, and @SiobhyB who worked on the original PR. Do you think you could take a look?

Thank you!

@jeherve jeherve added [Type] Bug When a feature is broken and / or not performing as intended [Focus] Performance [Pri] Normal [Block] Tiled Gallery labels Jan 21, 2022
@guarani
Copy link
Contributor

guarani commented Jan 21, 2022

Hi @jeherve, thanks for reporting this, I'll take a look.

@sgomes
Copy link
Contributor

sgomes commented Jan 26, 2022

Hey @guarani, please let me know if you need any help looking into this!

@guarani
Copy link
Contributor

guarani commented Jan 26, 2022

👋 Hi @sgomes, thanks for reaching out.

A likely solution would be to split mosaic/resize.js into a resize.js file and resize.native.js file. The latter would then import Platform and the former would not import from @wordpress/element at all.

My understanding of the issue is that #21849 (the port of Tiled Gallery to native mobile) imported Platform from @wordpress/element and this caused performance issues on the web. These performance issues are present in both the editor (via edit.js) and on the frontend (via the serialized output of save.js).

Could you please confirm if this is your understanding as well?


If so, the next step is identifying the places where Platform is now imported and seeing where this is in-turn used by the editor and front-end:


I want to reproduce this to make sure I have a good understanding of the issue and to be able to test a fix, but I had some issues this week with my Jetpack setup. I think I've been able to resolve these, so my next steps (likely tomorrow) will be to reproduce this in the browser using a local dev env. Alternatively I'll try reproducing in production (it's my understanding this issue is also affecting production).

@sgomes
Copy link
Contributor

sgomes commented Jan 28, 2022

Hey @guarani! I'm currently AFK but I'd be happy to help out on Monday, yes!

My understanding of the issue is that #21849 (the port of Tiled Gallery to native mobile) imported Platform from @wordpress/element and this caused performance issues on the web. These performance issues are present in both the editor (via edit.js) and on the frontend (via the serialized output of save.js).

Could you please confirm if this is your understanding as well?

Yes, that's the issue I able to identify, although it only applies to the frontend; the editor is able to make use of @wordpress/element without any performance concerns, since it's part of the core Gutenberg functionality.

Not the frontend, though. Loading @wordpress/element (and consequently, lodash and react) is a large performance regression that's currently affecting all page views that use the tiled gallery.

@guarani
Copy link
Contributor

guarani commented Jan 28, 2022

Loading @wordpress/element (and consequently, lodash and react) is a large performance regression that's currently affecting all page views that use the tiled gallery.

I'll go ahead and create a PR to split mosaic/resize.js into a resize.js file and resize.native.js file, and removing the import of Platform from the former. I'll submit that PR for review from Jetpack Crew even if I can't test the change myself (since I don't want to delay this further due to any issues with my local Jetpack development setup.)

guarani added a commit that referenced this issue Jan 28, 2022
#22445 reports a performance regression affecting page views where the Tiled Gallery is used.
This PR simply reverts the change to `tiled-gallery/layout/mosaic/resize.js` and creates a native-specific file, `resize.native.js`, containing the previous implementation.
Later work could remove web-specific code from `resize.native.js`, but that is lower priority, so is not addressed here.
@guarani
Copy link
Contributor

guarani commented Jan 28, 2022

I've created #22547 to fix this by reverting the changes to resize.js. If this is urgent and someone else can test the PR and approve it, I'd be grateful! I'm having a few issues with the local environment that I'll summarize below.


I think I've been able to reproduce the original issue on Jetpack master:
Screen Shot 2022-01-28 at 14 11 11

When testing the PR locally, Jetpack seems to install fine (jetpack install plugins/jetpack) and the plugin appears activated, but I don't see the Tiled Gallery in the block picker. Other times I get the "Your installation of Jetpack is incomplete." error in the WordPress dashboard. I won't be able to continue looking into this today, but will be back Monday to continue testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Tiled Gallery [Focus] Performance [Pri] Normal [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants