Replace the legacy Emscripten JS-exceptions model with native wasm-EH (legacy encoding) across the whole build, keeping Asyncify coroutines working via a from-source Binaryen --hoist-cpp-catches pre-pass. Net result: native-EH is the only build mode, the 3D viewer is on by default, and pcbnew shrinks substantially. Highlights: - Binaryen submodule everywhere + --hoist-cpp-catches integration in apply-asyncify; post-link Asyncify covers every app wasm (not just standalone test wasm). - Build deps (incl. OpenCASCADE without OCC_CONVERT_SIGNALS) and all KiCad apps with -fwasm-exceptions; emscripten_sleep added to the post-link asyncify-imports. - libcontext fiber entry wired under native exceptions; while-loop main loop + currData shim injected into all wx apps. - Native-EH collab apply fixed: DEBUG-define the embind TU + match all out-of-CMake C++ TUs' ABI flags to the core, fixing the vtable-layout skew / mis-dispatch. - 3D viewer enabled by default (real raytracer linked, not the stub). - Retire the EH-spike scaffolding; flip the asyncify-races ablation pins to shim-redundancy pins (native-EH stays clean with the legacy shims ablated). - Fix the asyncify-races quiescence check to not require Asyncify.currData==0: under the native-EH per-frame-yield top loop the main stack is asyncify-suspended every frame, so currData legitimately churns (a freed-but-not-yet-nulled buffer, not a leak). Refresh the pcbnew toolbar screenshot baseline for the new kicad. - CI: drop the obsolete binaryen_version input/env (the build uses the binaryen submodule fork's wasm-opt, not a version download); key the wasm-output cache on the binaryen submodule SHA instead. Bumps the wxwidgets + binaryen submodules to their squashed feature commits. Validated green: all 7 apps native-EH (real 3D in pcbnew); KiCad e2e 63/63 Firefox + Chromium (3D viewer renders); wx 336; coroutine 34/34 both engines; asyncify 7/7 both engines. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
46 lines
2.5 KiB
TypeScript
46 lines
2.5 KiB
TypeScript
import { test, expect } from './utils/fixtures';
|
|
|
|
// Phase 2: on-demand (NON-warm) pthread Worker creation WITHOUT modifying KiCad.
|
|
//
|
|
// The real KiCad pool (compiled-in kicad/common/thread_pool.cpp, via GetKiCadThreadPool())
|
|
// consumes ALL the pre-warmed Workers at construction; raw fly-threads beyond that count
|
|
// must then be created ON DEMAND, whose 'loaded'->'run' handshake needs the main event loop.
|
|
// The fix is wasm/shims/nanosleep_yield.c (a strong nanosleep override): the main-thread sleep_for
|
|
// join Asyncify-yields so the loop services the handshake and the on-demand Workers boot.
|
|
//
|
|
// Named coroutine-* so playwright-coroutine.config.ts runs it in real Chrome + Firefox.
|
|
// WebKit is skipped for pthread apps (COEP worker-load limitation; doc 10 §2a).
|
|
|
|
const APP = '/standalone/pthread-ondemand/pthread_ondemand_test.html';
|
|
|
|
function parse( logs: string[], mode: number ) {
|
|
const line = logs.find( l => l.includes( `[ONDEMAND] SUCCESS m=${mode}` ) );
|
|
if( !line ) return null;
|
|
const w = line.match( /workersRan=(\d+)/ );
|
|
return { workersRan: w ? +w[1] : -1 };
|
|
}
|
|
|
|
async function waitForLog( testLogger: { consoleLogs: string[] }, needle: string, timeout = 60000 ) {
|
|
await expect.poll( () => testLogger.consoleLogs.some( l => l.includes( needle ) ), { timeout } ).toBe( true );
|
|
}
|
|
|
|
test.describe( 'On-demand non-warm pthread Worker (real pool drains the pre-warmed pool)', () => {
|
|
|
|
test( 'fix: nanosleep override yields → on-demand Workers boot → multi-core', async ( { page, testLogger } ) => {
|
|
await page.goto( `${APP}#m=1` );
|
|
await waitForLog( testLogger, '[ONDEMAND] SUCCESS m=1' );
|
|
const r = parse( testLogger.consoleLogs, 1 )!;
|
|
expect( r.workersRan, 'on-demand Workers boot and run via the yielding join' ).toBeGreaterThan( 1 );
|
|
} );
|
|
|
|
// Negative control: a busy-wait join that never calls nanosleep → never yields → the
|
|
// on-demand Workers never boot. Held to the SAME bar (workersRan>1), expected to miss it,
|
|
// so it is reported as an EXPECTED failure. If it ever passes, on-demand got fixed another way.
|
|
test( 'control: busy-wait (no nanosleep) CANNOT boot on-demand Workers', async ( { page, testLogger } ) => {
|
|
test.fail();
|
|
await page.goto( `${APP}#m=0`, { waitUntil: 'domcontentloaded' } );
|
|
await waitForLog( testLogger, '[ONDEMAND] SUCCESS m=0', 20000 );
|
|
const r = parse( testLogger.consoleLogs, 0 )!;
|
|
expect( r.workersRan, 'a non-yielding busy-wait cannot create on-demand Workers' ).toBeGreaterThan( 1 );
|
|
} );
|
|
} );
|