Repository navigation
why are chromium browsers so slow #11849
|
This is in a container running ubuntu 24.04LTS under WSL on windows11. Full mode for msedge,chromium and chrome are very slow on setup, the browser pops up but it stand for 20sec before anything happens, same on shutdown: sqlite> SELECT *,
unixepoch(endTime) - unixepoch(startTime) AS duration_seconds
FROM testconfig
ORDER BY duration_seconds DESC;
+----+---------------------+---------------------+--------+----------+---------------+----------+--------+------------------+
| id | startTime | endTime | ng | browser | version | runtype | branch | duration_seconds |
+----+---------------------+---------------------+--------+----------+---------------+----------+--------+------------------+
| 3 | 2026-11-03 12:30:13 | 2026-11-03 12:38:29 | 22.2.4 | chrome | 156.0.8078.47 | full | main | 496 |
| 2 | 2026-11-03 12:19:40 | 2026-11-03 12:27:54 | 22.2.4 | msedge | 156.0.4314.58 | full | main | 494 |
| 7 | 2026-11-03 13:06:36 | 2026-11-03 13:14:46 | 22.2.4 | chromium | 156.0.8078.4 | full | main | 490 |
| 5 | 2026-11-03 12:42:13 | 2026-11-03 12:44:07 | 22.2.4 | firefox | 157.0 | full | main | 114 |
| 6 | 2026-11-03 12:46:14 | 2026-11-03 12:48:05 | 22.2.4 | firefox | 157.0 | headless | main | 111 |
| 4 | 2026-11-03 12:40:06 | 2026-11-03 12:41:40 | 22.2.4 | chrome | 156.0.8078.47 | headless | main | 94 |
| 1 | 2026-11-03 12:17:59 | 2026-11-03 12:19:29 | 22.2.4 | msedge | 156.0.4314.58 | headless | main | 90 |
| 8 | 2026-11-03 13:15:09 | 2026-11-03 13:16:34 | 22.2.4 | chromium | 156.0.8078.4 | headless | main | 85 |
+----+---------------------+---------------------+--------+----------+---------------+----------+--------+------------------+Any idea how to debug this? |
Replies: 2 comments 1 reply
|
Interesting that Firefox is basically the same headed or headless while all 3 Chromium builds go from 90s to 490s. That makes me think it's Chromium + WSLg in the container rather than Vitest. First thing I'd do is run with DEBUG=pw:browser npx vitest --browser.headless=falseIf the pause is right after something like dbus-run-session -- npx vitest --browser.headless=falseIf it's not that, I'd try provider: playwright({
launchOptions: { args: ['--disable-gpu'] },
}),Also worth knowing: Vitest creates a new context per test file, and headed Chromium opens a window for each one. So if window creation is slow under WSLg you pay it once per file, not just at start/end. That's probably why the difference is 400s and not 40s. |
|
Two details in your own data already point where to look, before touching Vitest at all. What your table is telling you
25s is the default D-Bus method-call timeout in libbus/libdbus, and amys94fr's D-Bus theory matches that number suspiciously well: a chromium family build that can't reach a session bus stalls right around 20-25s at startup and again at teardown. Firefox apparently doesn't hard-stall on a broken/absent session bus, which is why it's flat between headed and headless in your table. So: Chromium + container without a usable D-Bus session is the leading suspect — not Vitest, and not the browser itself. Bisect it in two minutes (outside Vitest)Before any config changes, isolate launch/shutdown from Vitest entirely. I've written and syntax-checked a tiny timing script (playwright-core only, let it use the same browsers the provider already downloads): // bisect-launch.mjs — npm i playwright-core (no browser download needed)
import { chromium, firefox } from 'playwright-core';
import { performance } from 'node:perf_hooks';
const round = async (name, launch) => {
const t0 = performance.now();
const b = await launch(); const t1 = performance.now();
await b.close(); const t2 = performance.now();
console.log(`${name.padEnd(10)} launch=${((t1-t0)/1000).toFixed(1)}s shutdown=${((t2-t1)/1000).toFixed(1)}s`);
};
const args = process.argv[2] ? process.argv[2].split(' ') : [];
await round('chromium', () => chromium.launch({ headless: false, args }));
await round('firefox', () => firefox.launch({ headless: false, args }));Run it three ways: node bisect-launch.mjs # baseline inside WSLg
dbus-run-session -- node bisect-launch.mjs # fresh, private session bus (apt install dbus)
Xvfb :99 & DISPLAY=:99 node bisect-launch.mjs # No WSLg window at allIf plain shows Fixes, in order of least effort
dbus-run-session -- npx vitest --browser.headless=falseChromium only needs a bus; it doesn't care that nothing is listening on it.
Xvfb :99 -screen 0 1920x1080x24 & DISPLAY=:99 npx vitest --browser.headless=falseYou keep full mode (identical semantics to headed for Vitest's purposes) with none of the WSLg per-window penalty. This is also the standard trick for CI "headed" parity on Linux.
Full credit to amys94fr for the D-Bus pointer; this reply just adds the numbers off your table (≈20s × 22 files ≈ your 400s), the 25s default D-Bus timeout that matches your observed stall, and the two bisect commands that tell you in two minutes whether it's the bus or WSLg. If the |
Two details in your own data already point where to look, before touching Vitest at all.
What your table is telling you
25s is the default D-Bus method-call timeout in libbus/libdbus, and amys94fr's D-Bus theory matches that number suspiciously well: a chromium family build that can't reach a session bus stalls right around 20-25s at startup and again a…