Repository navigation
smoke: retry Electron launch to survive intermittent fontconfig startup crash - #323007
Closed
Alexandru Dima (alexdima) wants to merge 1 commit into
Closed
Alexandru Dima (alexdima) wants to merge 1 commit into
Alexandru Dima (alexdima) wants to merge 1 commit into
Conversation
…up crash
Linux CI runners intermittently SIGSEGV while launching Electron, before any
window appears. A frame-pointer backtrace of the crash dumps shows the fault is
in the system font stack on a glib worker thread, not in VS Code:
libpangoft2 -> libfontconfig (FcInit/parse) -> libexpat -> libc (NULL deref)
The crash is independent of the libexpat version (it reproduces identically on
both noble's 2.6.1 and a freshly installed 2.8.1, with the same libfontconfig
frames), so it is a nondeterministic startup race in the system
fontconfig/pango initialization rather than a fixable application bug.
Because the crash happens at launch and is rare per-launch, but a smoke run
performs ~25 launches, it surfaces as a high per-run failure rate. Retry the
launch a few times in Application#start(): a fresh relaunch almost always
succeeds, which collapses the per-run failure rate to near zero while adding
effectively zero overhead on the common (no-crash) path.
- Application#start(): retry launch + window-ready up to 3 times, tearing down
the crashed instance between attempts.
- playwrightElectron: close the Electron app if it produced no window, so a
retried launch does not leak a stray process.
- smoke installAppBeforeHandler: widen the before-hook timeout to accommodate
the retries.
Pairs with the fail-fast launch error added earlier (a crashed launch now fails
in ~60s instead of hanging to the 120s hook timeout), which makes the retries
affordable.
Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces flaky CI failures in the VS Code smoke-test harness by retrying Electron launches when startup intermittently crashes (before any window appears), and by improving cleanup so repeated launches don’t leak processes.
Changes:
- Retry
Application#start()(launch + window-ready) up to 3 times, stopping the prior instance between attempts. - In Playwright Electron launch, close the Electron app if it fails to produce a window, to avoid leaving stray processes before a retry.
- Increase smoke-suite
beforehook timeout to allow for the added retry behavior.
Show a summary per file
| File | Description |
|---|---|
| test/smoke/src/utils.ts | Extends suite before timeout to accommodate launch retries. |
| test/automation/src/playwrightElectron.ts | Best-effort closes Electron when no window appears before rethrowing launch failure. |
| test/automation/src/application.ts | Adds retry loop around app launch + window readiness, with teardown between attempts. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 2
Comment on lines
+91
to
+94
| // Allow enough time for the application launch to be retried a few times in | ||
| // case of an intermittent Electron startup crash (see Application#start()). | ||
| this.timeout(5 * 60 * 1000); | ||
|
|
Comment on lines
+107
to
+111
| } catch (error) { | ||
| this.logger.log(`Application#start(): attempt ${attempt} of ${maxAttempts} to launch the application failed: ${error}`); | ||
|
|
||
| // ...and make sure the window is ready to interact | ||
| await measureAndLog(() => this.checkWindowReady(code), 'Application#checkWindowReady()', this.logger); | ||
| // Tear down the crashed/half-started instance before retrying | ||
| await this.stop(); |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
The expat upgrade did not work — here's why, and the fix that will
PR #323001 installed libexpat 2.8.1 and it still crashed (run 28192795744). I pulled the new crash dumps and walked the frame-pointer (RBP) stack:
The expat offsets moved (proving 2.8.1 was actually loaded in the crashing process), but the crash is unchanged. expat is exonerated. The constant factors are libfontconfig + libc + the pango worker-thread init (
pango init_in_thread → FcInit). fontconfig hands expat a bad/NULL pointer (or a race corrupts it) and any expat version faithfully derefs it. This is a nondeterministic startup race in the system font stack, not an application bug and not fixable by swapping expat. (It also explains the earlier "less XML made it worse" result — timing, not content.)Fix: retry the launch
The crash happens at launch, before any window, and is rare per launch (~0.8%). But a smoke run does ~25 launches, so it compounds into the ~8–19% per-run failure we've been seeing. Retrying the launch collapses that to near-zero with effectively zero overhead on the normal path (retries almost never trigger).
Application#start(): retry launch + window-ready up to 3×, tearing down the crashed instance between attempts.playwrightElectron: close the Electron app if it produced no window, so a retried launch doesn't leak a stray process.installAppBeforeHandler: widen the before-hook timeout to accommodate retries.This pairs with the already-merged fail-fast launch error (#322905): a crashed launch now fails in ~60s instead of hanging to the 120s hook timeout, which is what makes the retries affordable.
Why retry instead of "fix the crash"
The fault is in system libraries (fontconfig/pango/glib) during Electron startup on the CI image — an environment/infra flake, not VS Code code. Retrying a known-infra-flaky startup is standard practice and idiomatic here (the harness already retries the Electron download, app exit, etc.). The underlying fontconfig/pango race can be chased separately (e.g. a newer libfontconfig), but retry makes CI green regardless of root cause.
Supersedes / related
Co-authored-by: Copilot [email protected]