fix: destroy leaked fragment-capture window on failed loadURL - #14
Open
murich wants to merge 1 commit into
Open
Conversation
captureStart() registered the offscreen capture BrowserWindow in the captures map before awaiting win.loadURL(url). If the load rejected (e.g. the fragment dev server was momentarily unavailable), the window was never destroyed or removed, and captureStart's own captures.has(id) early-return then permanently blocked any future retry for that fragment id. The leaked window keeps compositing on the GPU indefinitely. Enough of them accumulating (repeated capture attempts against a flaky dev server) can starve the single shared GPU process, which manifests as the preview going solid black with no exception and no crash — the existing webglcontextlost/webglcontextrestored recovery in player.ts never fires because the GPU process is starved, not reset. Wrap the loadURL await in try/catch and destroy+unregister the window on failure before rethrowing, so a failed load is fully cleaned up and can be retried.
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.
Summary
captureStart()inelectron/fragments.tsregistered the offscreen fragment-captureBrowserWindowin thecapturesmap before awaitingwin.loadURL(url). A rejected load (e.g. the fragment dev server briefly unavailable) left the window alive and untracked, and thecaptures.has(id)early-return then permanently blocked any retry for that fragment id.webglcontextlost/webglcontextrestoredrecovery inplayer.tsonly fires on an actual context reset, not GPU-process starvation.loadURLawait in try/catch, destroy and unregister the window on failure, then rethrow so the caller still sees the error.Test plan
npx tsc --noEmit -p tsconfig.node.jsonpassescaptureStartat an unreachable URL and confirming the window is destroyed and a retry succeeds