Skip to content

Conversation

@dcalhoun
Copy link
Member

@dcalhoun dcalhoun commented Jan 26, 2026

Description

Fix CMM-1174.

This PR fixes an issue where block editor plugins fail to load on fresh app install when the gutenberg_kit_plugins feature flag is toggled after the editor dependencies have been prefetched.

Root cause: When the app launches, EditorDependencyManager prefetches editor dependencies including asset bundles. If the plugins flag is disabled at that time, an empty asset bundle is cached. When the user later enables the flag and opens the editor, the stale cached empty bundle is used, causing the "Loading plugins failed" notice.

Solution:

  1. Track the newGutenbergPlugins flag value when caching dependencies
  2. On each prefetch call, check if the flag value has changed since the last cache
  3. If changed, invalidate all cached entries and re-prefetch with the current flag state

Additionally, this PR consolidates editor warmup logic:

  • Moved warmUpEditorIfNeeded from MySiteViewController to BlogDashboardViewModel
  • Removed redundant prefetch call from PostListViewController
  • Ensured prefetchDependencies is always called (not guarded by blog change) so flag changes can be detected

Testing instructions

  1. Fresh install the app
  2. Enable the Experimental Block Editor feature flag
  3. Ensure gutenberg_kit_plugins feature flag is disabled via the debug menu
  4. Navigate to My Site (this triggers the prefetch with empty bundle)
  5. Enable the gutenberg_kit_plugins feature flag via debug menu
  6. Navigate away from and back to My Site (this triggers the prefetch with a populated bundle)
  7. Open the block editor
  8. Expected: Plugins load successfully (no "Loading plugins failed" notice)
  9. Previous behavior: "Loading plugins failed" notice appeared

@dcalhoun dcalhoun added Posting/Editing Gutenberg Editing and display of Gutenberg blocks. Bug labels Jan 26, 2026
@dangermattic
Copy link
Collaborator

1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

The preloading is unnecessary and also lead to confusing cache states.
The invalid cache states were addressed in a separate commit.
Warming and preloading the editor in both the MySiteViewController and
BlogDashboardViewModel is redundant. The former embeds the latter.
This is arguably duplicative of the preloading within
BlogDashboardViewModel.
When preloading GutenbergKit while plugins are disabled, an empty editor
bundle is cached. The editor continues using this this bundle until it
expires or the pull-to-refresh gesture is performed on the My Site view.
If the plugins feature is later enabled, the empty bundle is used and
leads to confusing plugin loading failed warnings.

To avoid unexpectedly empty bundles, we invalidate all bundles when the
plugins feature flag changes.
GutenbergKit's dependency prefetch manages its own cache and avoids
re-fetching dependencies.
@dcalhoun dcalhoun force-pushed the fix/mitigate-empty-editor-asset-bundles-errors branch from 9188217 to 17a8262 Compare January 26, 2026 23:08
@dcalhoun dcalhoun changed the base branch from trunk to release/26.6 January 26, 2026 23:08
@dcalhoun dcalhoun added this to the 26.6 ❄️ milestone Jan 26, 2026
@sonarqubecloud
Copy link

@wpmobilebot
Copy link
Contributor

App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number30614
VersionPR #25170
Bundle IDorg.wordpress.alpha
Commit17a8262
Installation URL1o8laergk0gu8
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number30614
VersionPR #25170
Bundle IDcom.jetpack.alpha
Commit17a8262
Installation URL7heudll6iv6j0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

Comment on lines +94 to +99
if let lastFlagValue, lastFlagValue != currentPluginsFlagValue {
// Flag changed - invalidate all cached entries
DDLogInfo("EditorDependencyManager: Plugins flag changed (\(lastFlagValue) -> \(currentPluginsFlagValue)), invalidating all cached dependencies")
cache.removeAll()
prefetchTasks.removeAll()
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the fix for the unexpected "Plugin loading failed, using default editor configuration" warning.

GutenbergKit's preloading logic returns an empty bundle if plugins is disabled. The app preloaded and cached an empty asset bundle, then continued utilizing it even after the plugins feature was enabled. Invalidating the cache ensure GutenbergKit preloads an appropriate bundle.


func viewWillAppear() {
EditorDependencyManager.shared.prefetchDependencies(for: self.blog)
warmUpEditorIfNeeded(for: self.blog)
Copy link
Member Author

Choose a reason for hiding this comment

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

Introduced to avoid unnecessary preloading if GutenbergKit is disabled.

Comment on lines -406 to -408
if RemoteFeatureFlag.newGutenberg.enabled() {
warmUpEditorIfNeeded(for: blog)
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Consolidated to BlogDashboardViewModel as it appears to be duplication to have this in both places.

Comment on lines -42 to -45

if let blog = self.blog {
EditorDependencyManager.shared.prefetchDependencies(for: blog)
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed as this feels duplicative of BlogDashboardViewModel. It's difficult (impossible?) to navigate to the post list without first navigating to My Site.

@dcalhoun dcalhoun marked this pull request as ready for review January 26, 2026 23:54
@dcalhoun dcalhoun requested a review from jkmassel January 26, 2026 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Gutenberg Editing and display of Gutenberg blocks. Posting/Editing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants