Repository navigation
Conversation
The first window now loads its document the moment Electron is ready: the same index.html without its module scripts, plus a sanitized copy of the shell captured at the end of the previous run. The renderer process, the stylesheet and the fonts are ready while the main bundle and the layers load, and the scripts are added when the window is adopted. The renderer asks for its RPC MessagePort instead of receiving one on did-finish-load, since that event fires before the scripts exist. The startup splash and its 300 ms fade are skipped when a snapshot is present; the snapshot is removed when the interface would have been revealed, and re-captured once idle and after route changes.
Contributor
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
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.
Draft, for analysis. Item 4 of the restructure: the first window shows the shell from the previous run while the renderer boots.
sequenceDiagram participant M as main (entry) participant W as window participant R as renderer participant B as main (bundle + layers) M->>W: create + show (195 ms) M->>R: load index.html?early=<id> — no scripts, snapshot in #oc-prepaint M->>B: import("./desktop") R-->>R: CSS, fonts, snapshot DOM ready (~320 ms) B->>R: releaseRenderer: append the module scripts, drop the query R->>R: app boots, mounts under the snapshot R->>R: readyToReveal → remove #oc-prepaint (no splash, no fade) R->>B: WindowSavePrepaint(sanitized #root) once idlewindows/serve.tsservesoc://without Effect so the entry module can register it before the bundle;index.html?early=<id>is the same document minus its<script type=module>tags, withprepaint-<id>.html(version-tagged, next to the window-state JSON) injected inert after#root.windows/serve.ts#releaseRendererappends the scripts withasync = false(runtime chunk stays first) andhistory.replaceStatedrops the query so a reload gets the full document.MessagePortis now pulled by the renderer (window.electron.requestRpcPort()) instead of pushed ondid-finish-load, which for this document fires before the scripts and the IPC layer exist.renderer/startup/prepaint.tscaptures#root: strips scripts, dialogs, menus, editors, ids, hrefs and handlers, blanks inputs, copies only the<symbol>s the shell uses; ≤ 1 MB.Expected vs actual (warm, restored draft tab, interleaved, 5 runs, medians)
Expected: the user's UI on screen at ~350 ms instead of a colour at 195 and a splash at ~650; everything else unchanged.
screenPainted)screenSettled)Actual, honestly: the snapshot itself is never on screen. Its DOM is ready at ~380 ms but its first frame is not presented before the real UI replaces it. The UI still reaches the screen 270 ms earlier because the splash fade is gone and the shell's GPU shaders compile earlier. The early renderer costs the main thread ~200 ms (bundle evaluation 114 → 349 ms with a renderer competing for the UI thread).
Two things found on the way (bench harness now measures them)
shellVisiblewas never what the user sees. The DOM says 872–1081 ms; the screen shows the interface at ~1300–1530 ms. Two reasons: the 300 ms splash fade, and ~30 Skia shader programs compiled through ANGLE/D3D on the GPU main thread (~15 ms each, serialised) the first time the shell rasterizes — the GPU thread is blocked for ~480 ms and no frame is presented meanwhile.GPUCache/indexhas 0 entries after 40 s runs and graceful exits in the bench profile; every launch recompiles (GrShaderCache::loadmisses =stores, every run). If that cache worked, the shell would be on screen ~450 ms earlier on every launch, with or without this PR. Worth its own investigation.Measured with the screen-sampling harness from #49894.