mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
perf(electron): load the main-process startup wiring after the window starts loading (#1702)
Registering IPC handlers costs 0.4 ms; evaluating the modules behind them (axios, drizzle-orm, better-sqlite3, electron-updater, fix-path) before the window could load was the real cost. main.ts now keeps only the pre-paint wiring and loads the rest as the deferred-events.js chunk inside the main window's did-start-loading listener, where the import and its registrations complete before any renderer invoke can arrive. Interleaved A/B on the performance build: app.whenReady 323 -> 265 ms, did-finish-load 499 -> 447 ms; J1 journey spawnToDidFinishLoad ~405 -> ~365 ms with identical counters. Packaging ships the chunk explicitly, verify:package-layout requires it, and the benchmark build identity hashes it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
497b6076fa
commit
e39c854a41
13 files changed
+565
-138
No files matched your search
@@ -97,14 +97,24 @@ classifying a zero rendered-frame signal as an infrastructure flake.
|
||||
The process entry is `apps/electron-backend/src/main.entry.ts` (built to
|
||||
`dist/apps/electron-backend/main.js`): it enables the V8 compile cache under
|
||||
`userData/v8-compile-cache` and then requires the application bundle,
|
||||
`main.app.js`, built from `apps/electron-backend/src/main.ts`, which bootstraps
|
||||
the database, registers events and creates the main window. The cache is
|
||||
`main.app.js`, built from `apps/electron-backend/src/main.ts`. Before the window
|
||||
loads, `main.ts` registers only what the renderer can call before its first paint
|
||||
(window state, the close guard, playlist-open requests, request-header shims);
|
||||
everything else, including the database, portal, EPG, download, player,
|
||||
remote-control and update IPC, lives in
|
||||
`apps/electron-backend/src/app/startup/deferred-events.ts`, built as the
|
||||
`deferred-events.js` chunk and loaded inside the window's `did-start-loading`
|
||||
listener. That import and its registrations finish within the same task, so no
|
||||
renderer `invoke` can find a missing handler (`app/startup/deferred-bootstrap.ts`
|
||||
holds the scheduler and its test); the startup trace reports it as
|
||||
`deferred-events:start` and `deferred-events:done`. The cache is
|
||||
disposable; `IPTVNATOR_DISABLE_COMPILE_CACHE=1` turns it off and
|
||||
`IPTVNATOR_COMPILE_CACHE_DIR` relocates it (E2E runs keep it inside
|
||||
`IPTVNATOR_E2E_DATA_DIR`). nx-electron packages the backend through an
|
||||
allowlist, so `apps/electron-backend/project.json` lists `main.app.js` under the
|
||||
`files` option of the `package` and `make` targets, and `verify:package-layout`
|
||||
fails when either entry file is missing from `app.asar`. The preload is
|
||||
allowlist, so `apps/electron-backend/project.json` lists `main.app.js` and
|
||||
`deferred-events.js` under the `files` option of the `package` and `make`
|
||||
targets, and `verify:package-layout` fails when any of the entry files is missing
|
||||
from `app.asar`. The preload is
|
||||
`apps/electron-backend/src/app/api/main.preload.ts`, with handlers under
|
||||
`apps/electron-backend/src/app/events/`. The window follows the saved startup mode
|
||||
(normal/maximized/fullscreen); `--fullscreen` overrides a single launch. Use
|
||||
|
||||
Reference in new issue
Block a user