test(wasm): coroutine crash reproduction harness + per-engine runner
Investigation scaffolding for the Chrome-only KiCad coroutine renderer crash.
Adds isolated reproduction probes exercising the coroutine/Asyncify/fiber layer
under KiCad-like conditions, runnable in BOTH Firefox and system Chrome.
- tests/playwright-coroutine.config.ts + test:coroutine:firefox|chrome npm
scripts: run the coroutine specs in Firefox AND system Chrome (the old e2e
config only used bundled Chromium, which never reproduced the crash).
- tests/apps/standalone/coroutine-pthread/: no-wx + pthreads reproduction probes
(fiber-in-main, nested invoke_/dynCall boundaries, RunMainStack, embind,
main-loop/rAF activation) + worker_dom_stub.js for wx+pthreads builds.
- tests/apps/Makefile.wasm: coroutine-pthread{,-main,-nested,-nested-ex,-wx,
-embind,-mainloop} targets.
- scripts/common/shims/diagnostics.js: add EM_ASYNC_JS handleSleep enter/wake
tracking (DIAG_SLEEP) to detect nested-async at the crash.
Findings (details in research notes): every isolated factor so far — direct /
nested / RunMainStack fiber, wx event loop + all 13 scenarios incl EM_ASYNC_JS,
pthreads, and main-loop/rAF activation — runs CLEAN in system Chrome. The
coroutine/Asyncify layer is exonerated; GL/WebGL is the remaining untested factor
(next). The reliable FF-pass/Chrome-fail repro is still the KiCad pcbnew e2e.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 18:44:12 +02:00
|
|
|
import { defineConfig, devices } from '@playwright/test';
|
|
|
|
|
import { execSync } from 'child_process';
|
|
|
|
|
import * as fs from 'fs';
|
|
|
|
|
import * as path from 'path';
|
|
|
|
|
|
|
|
|
|
// Runs the standalone coroutine harness specs (tests/e2e/coroutine*.spec.ts) in BOTH
|
|
|
|
|
// Firefox and system Chrome — the same engines as the KiCad app. The old default
|
|
|
|
|
// (tests/playwright.config.ts) only ran them in bundled Chromium with SwiftShader,
|
|
|
|
|
// which is NOT where the real KiCad coroutine crash manifests. Mirrors
|
|
|
|
|
// playwright-kicad.config.ts (Chrome must be --headed on ARM Mac; Firefox headless OK).
|
|
|
|
|
|
|
|
|
|
const PORT_FILE = path.join(__dirname, '.test-port-coroutine');
|
|
|
|
|
|
|
|
|
|
function findFreePort(): number {
|
|
|
|
|
try {
|
|
|
|
|
const result = execSync(
|
|
|
|
|
'python3 -c "import socket; s=socket.socket(); s.bind((\'\',0)); print(s.getsockname()[1]); s.close()"',
|
2026-07-03 11:37:36 +02:00
|
|
|
{ encoding: 'utf-8', timeout: 5000 }
|
test(wasm): coroutine crash reproduction harness + per-engine runner
Investigation scaffolding for the Chrome-only KiCad coroutine renderer crash.
Adds isolated reproduction probes exercising the coroutine/Asyncify/fiber layer
under KiCad-like conditions, runnable in BOTH Firefox and system Chrome.
- tests/playwright-coroutine.config.ts + test:coroutine:firefox|chrome npm
scripts: run the coroutine specs in Firefox AND system Chrome (the old e2e
config only used bundled Chromium, which never reproduced the crash).
- tests/apps/standalone/coroutine-pthread/: no-wx + pthreads reproduction probes
(fiber-in-main, nested invoke_/dynCall boundaries, RunMainStack, embind,
main-loop/rAF activation) + worker_dom_stub.js for wx+pthreads builds.
- tests/apps/Makefile.wasm: coroutine-pthread{,-main,-nested,-nested-ex,-wx,
-embind,-mainloop} targets.
- scripts/common/shims/diagnostics.js: add EM_ASYNC_JS handleSleep enter/wake
tracking (DIAG_SLEEP) to detect nested-async at the crash.
Findings (details in research notes): every isolated factor so far — direct /
nested / RunMainStack fiber, wx event loop + all 13 scenarios incl EM_ASYNC_JS,
pthreads, and main-loop/rAF activation — runs CLEAN in system Chrome. The
coroutine/Asyncify layer is exonerated; GL/WebGL is the remaining untested factor
(next). The reliable FF-pass/Chrome-fail repro is still the KiCad pcbnew e2e.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 18:44:12 +02:00
|
|
|
);
|
|
|
|
|
return parseInt(result.trim());
|
|
|
|
|
} catch {
|
|
|
|
|
return 9100 + Math.floor(Math.random() * 800);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-10 13:40:00 +02:00
|
|
|
// Same port-pinning scheme as playwright-kicad.config.ts: the main runner (argv
|
|
|
|
|
// contains `test`) always picks a fresh port and writes the file before workers
|
|
|
|
|
// spawn; workers — including ones recreated mid-run after a failure — always
|
|
|
|
|
// reuse it. No freshness window, so a recreated worker can never rotate to a
|
|
|
|
|
// dead port (ERR_CONNECTION_REFUSED cascade).
|
|
|
|
|
function resolvePort(): number {
|
|
|
|
|
const isMainRunner = process.argv.slice(2).includes('test');
|
|
|
|
|
if (!isMainRunner) {
|
|
|
|
|
try {
|
|
|
|
|
const existing = parseInt(fs.readFileSync(PORT_FILE, 'utf-8').trim(), 10);
|
|
|
|
|
if (existing > 0 && existing < 65536) return existing;
|
|
|
|
|
} catch { /* fall through */ }
|
|
|
|
|
}
|
test(wasm): coroutine crash reproduction harness + per-engine runner
Investigation scaffolding for the Chrome-only KiCad coroutine renderer crash.
Adds isolated reproduction probes exercising the coroutine/Asyncify/fiber layer
under KiCad-like conditions, runnable in BOTH Firefox and system Chrome.
- tests/playwright-coroutine.config.ts + test:coroutine:firefox|chrome npm
scripts: run the coroutine specs in Firefox AND system Chrome (the old e2e
config only used bundled Chromium, which never reproduced the crash).
- tests/apps/standalone/coroutine-pthread/: no-wx + pthreads reproduction probes
(fiber-in-main, nested invoke_/dynCall boundaries, RunMainStack, embind,
main-loop/rAF activation) + worker_dom_stub.js for wx+pthreads builds.
- tests/apps/Makefile.wasm: coroutine-pthread{,-main,-nested,-nested-ex,-wx,
-embind,-mainloop} targets.
- scripts/common/shims/diagnostics.js: add EM_ASYNC_JS handleSleep enter/wake
tracking (DIAG_SLEEP) to detect nested-async at the crash.
Findings (details in research notes): every isolated factor so far — direct /
nested / RunMainStack fiber, wx event loop + all 13 scenarios incl EM_ASYNC_JS,
pthreads, and main-loop/rAF activation — runs CLEAN in system Chrome. The
coroutine/Asyncify layer is exonerated; GL/WebGL is the remaining untested factor
(next). The reliable FF-pass/Chrome-fail repro is still the KiCad pcbnew e2e.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 18:44:12 +02:00
|
|
|
const port = findFreePort();
|
|
|
|
|
fs.writeFileSync(PORT_FILE, port.toString());
|
|
|
|
|
return port;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-10 13:40:00 +02:00
|
|
|
const port = resolvePort();
|
test(wasm): coroutine crash reproduction harness + per-engine runner
Investigation scaffolding for the Chrome-only KiCad coroutine renderer crash.
Adds isolated reproduction probes exercising the coroutine/Asyncify/fiber layer
under KiCad-like conditions, runnable in BOTH Firefox and system Chrome.
- tests/playwright-coroutine.config.ts + test:coroutine:firefox|chrome npm
scripts: run the coroutine specs in Firefox AND system Chrome (the old e2e
config only used bundled Chromium, which never reproduced the crash).
- tests/apps/standalone/coroutine-pthread/: no-wx + pthreads reproduction probes
(fiber-in-main, nested invoke_/dynCall boundaries, RunMainStack, embind,
main-loop/rAF activation) + worker_dom_stub.js for wx+pthreads builds.
- tests/apps/Makefile.wasm: coroutine-pthread{,-main,-nested,-nested-ex,-wx,
-embind,-mainloop} targets.
- scripts/common/shims/diagnostics.js: add EM_ASYNC_JS handleSleep enter/wake
tracking (DIAG_SLEEP) to detect nested-async at the crash.
Findings (details in research notes): every isolated factor so far — direct /
nested / RunMainStack fiber, wx event loop + all 13 scenarios incl EM_ASYNC_JS,
pthreads, and main-loop/rAF activation — runs CLEAN in system Chrome. The
coroutine/Asyncify layer is exonerated; GL/WebGL is the remaining untested factor
(next). The reliable FF-pass/Chrome-fail repro is still the KiCad pcbnew e2e.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 18:44:12 +02:00
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
globalSetup: './global-setup.ts',
|
|
|
|
|
testDir: './e2e',
|
|
|
|
|
testMatch: /coroutine.*\.spec\.ts$/,
|
|
|
|
|
fullyParallel: false, // one heavy WASM app at a time
|
|
|
|
|
forbidOnly: !!process.env.CI,
|
|
|
|
|
retries: 0,
|
|
|
|
|
workers: 1,
|
|
|
|
|
reporter: 'html',
|
|
|
|
|
timeout: 120000,
|
|
|
|
|
|
|
|
|
|
use: {
|
|
|
|
|
baseURL: `http://localhost:${port}`,
|
|
|
|
|
trace: 'retain-on-failure',
|
|
|
|
|
screenshot: 'only-on-failure',
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
projects: [
|
|
|
|
|
{
|
|
|
|
|
// Firefox: headless, reliable on ARM Mac. (No clipboard perms — Firefox rejects them.)
|
|
|
|
|
name: 'firefox',
|
|
|
|
|
use: { ...devices['Desktop Firefox'], viewport: { width: 1280, height: 720 } },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
// System Chrome (real V8/GPU) — the engine where the KiCad coroutine crash
|
|
|
|
|
// manifests. Run via: npm run test:coroutine:chrome (must be --headed).
|
|
|
|
|
name: 'chromium',
|
|
|
|
|
use: {
|
|
|
|
|
channel: 'chrome',
|
|
|
|
|
viewport: { width: 1280, height: 720 },
|
|
|
|
|
permissions: ['clipboard-read', 'clipboard-write', 'local-fonts'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
webServer: {
|
|
|
|
|
command: `npx serve apps -p ${port} -c ../serve.json`,
|
|
|
|
|
port: port,
|
|
|
|
|
reuseExistingServer: !process.env.CI,
|
|
|
|
|
},
|
|
|
|
|
});
|