fix(render): lazy playwright-core — static import cost ~20s per omp startup - #22
Merged
Conversation
…tartup omp's guarded extension loader preloads every statically resolvable import of an extension module at host startup — including import() literals — and pays ~20s for playwright-core's ~9MB graph (native bun import: 0.57s). chromium is only needed when a render executes. The specifier is assembled at runtime (['playwright','-core'].join()) so no static analysis can pull it into the preload set; it loads once, memoized, on first actual render. Verified under bun: full render (screenshot + computed styles + dom snapshot) works with the indirected import; omp startup 27.7s -> 5.2s. Fixes #21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes #21.
extensions/render.tsstatically imported playwright-core. omp's guarded extension loader preloads every statically resolvable import of an extension module at host startup — measured ~20s for playwright-core's ~9MB graph (a nativebunimport of the same package: 0.57s).chromiumis used only inside the execute path, so every omp start paid 20s for a browser driver that almost never launches.Attribution (omp 18.1.12, Apple M5)
loadExtensionswarnings at 10s/20simport type(type-only) insteadawait import("playwright-core")in fn bodyChange
Memoized (
cachedChromium), loads once on first actual render. Comment block in the file documents why the indirection exists and forbids reintroducing any static reference (includingimport type).Verification
pnpm typecheckclean; full suite green: engine 162, lint 103, render 4 (real chromium launches through the lazy path), examples 1.-pstartup timing: 27.7s → 5.2s, noStill startingwarning.Follow-up (out of scope here)
The omp-side loader behavior is the deeper bug: preloading extension import graphs (even type-only/dynamic) costs ~35× native import. Will report upstream to omp (can1357/tap, omp.sh).