Skip to content

Conversation

@dcalhoun
Copy link
Member

@dcalhoun dcalhoun commented Jan 27, 2026

What?

Prevents crashes when the editor requests assets that aren't in the local cache and adds a fallback to fetch them from the original server.

Why?

Inserting certain plugin blocks (e.g., the Writing Prompt block) causes a crash because:

  1. The block's CSS references relative assets like url(/icon.svg)
  2. All manifest URLs are rewritten to use the gbk-cache-https scheme
  3. The browser resolves the SVG URL against the cached CSS URL
  4. The scheme handler receives a request for an SVG that was never downloaded (only .js/.css files are cached)
  5. The assetDataPath(for:) method's precondition fails when the path escapes the bundle root, causing a crash

Fix CMM-1176. Fix JETPACK-IOS-1JFR.

How?

Two changes:

  1. Added isValidAssetPath(for:) - A safe method to check if a URL resolves to a valid path within the bundle root, without triggering the precondition crash

  2. Added remote fetching fallback - When an asset isn't in the local cache (invalid path or missing file), the provider now fetches it from the original HTTPS URL and serves it to the WebView

Testing Instructions

  1. Open the editor for a site with block assets support.
  2. Insert the "Writing Prompt" block (from Jetpack)
  3. Verify the block loads without crashing1
  4. Verify the block's icon appears correctly (fetched from remote)

Accessibility Testing Instructions

N/A - No UI changes

Screenshots or screencast

N/A

Footnotes

  1. I was unable to reproduce the crash locally, only in the TestFlight build.

Check for valid asset paths before attempting to access them.
Ensure assets not cached locally still load in the editor. E.g., we do
not download and cache images loaded within CSS files.
@dcalhoun dcalhoun added the [Type] Bug An existing feature does not function as intended label Jan 27, 2026
@dcalhoun dcalhoun marked this pull request as ready for review January 27, 2026 21:50
@dcalhoun dcalhoun requested a review from jkmassel January 27, 2026 21:51
@jkmassel jkmassel mentioned this pull request Jan 27, 2026
* Suggestions

* docs: Fix inline comment typo

---------

Co-authored-by: David Calhoun <[email protected]>
@dcalhoun
Copy link
Member Author

@jkmassel I reviewed and merged #302. Will you please review this again at your convenience? 🙇🏻‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants