wordpress-mobile / wordpress-mobile/GutenbergKit

warmup() runs the full dependency fetch and discards its own prewarm

Open Beginner friendly
#666 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

[Type] Bug [Type] Performance iOS
Dominant language
JavaScript
Stars
29
Forks
6
Avg merge
1d 9h
Merged PRs (30d)
41

Description

EditorViewController.warmup(configuration:) is documented as loading the editor HTML without dependencies to prewarm WebKit. It does that, then falls through and does the full dependency fetch as well — ending in a second navigation that discards the prewarm it just performed.

Detail

ios/Sources/GutenbergKit/Sources/EditorViewController.swift:297-299:

if isWarmupMode {
    self.loadEditorWithoutDependencies()
}

No return, no else. warmup() (:921) constructs with isWarmupMode: true and no dependencies, so the if let dependencies at :323 fails and execution continues into the ASYNC FLOW at :334. That runs prepareEditor() → a live authenticated REST fetch plus the asset-bundle download → loadEditor(dependencies:) → a second webView.loadFileURL at :422, superseding the navigation started at :298.

The file's own header diagram (:26-34) documents warmup as a mutually-exclusive third branch. The code contradicts it.

How it bites

A host follows docs/integration.md:107 and calls warmup(configuration:) at launch to "shave a couple of hundred milliseconds off the first load." What it gets instead is a full REST dependency fetch and asset download at launch, a progress view rendered into a view with no window, and a prewarm navigation cancelled by a second one — plus a second concurrent writer into the shared asset-bundle directory (#665).

warmup() retains the controller for 5 s via DispatchQueue.main.asyncAfter (:926-928), but the fetch task holds a strong self for as long as it runs, so the real lifetime is however long the fetch takes.

No caller in this repo, so it is latent rather than live.

Suggested fix

if isWarmupMode {
    self.loadEditorWithoutDependencies()
    return
}

Worth checking whether startUploadServer() should be reachable in warmup at all while there (it currently no-ops, since warmup sets neither handler).

Found while reviewing #651. Pre-existing and byte-identical in that PR's base; the removed cancellation never applied to warmup, since a warmup controller has no window and never receives viewDidDisappear.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in ios/Sources/GutenbergKit/Sources/EditorViewController.swift at the warmup branch around lines 297-299, then follow warmup(configuration:) around lines 921-928 and the dependency flow near lines 323-422. Confirm that warmup performs only the dependency-free editor load, without the REST fetch, asset download, progress view, or second navigation; check docs/integration.md:107 for the intended caller behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.