The shim bound bare dynCall_* names to JS getWasmTableEntry() calls, bypassing the asyncify-instrumented dynCall_* wasm trampolines that -sDYNCALLS=1 provides. That broke Asyncify unwind/rewind through indirect calls -> "indirect call signature mismatch" (caught every frame in Firefox; fatal renderer crash in Chrome). Bind the bare names to wasmExports["dynCall_<sig>"] instead. Result: the PCBnew "select draw lines" e2e is green in Firefox (tool selects and draws, zero page errors). Dropped the fiber-stabilization block, the shipped diagnostic block, and the exportCallStack JS hack (all compensated for the wrong binding); shim shrank 521 -> ~250 lines. - scripts/common/inject-dyncall-shims.sh: orchestrator only; injected JS extracted to scripts/common/shims/ - scripts/common/shims/dyncall-binding.js.tmpl: per-signature binding template - scripts/common/shims/handlesleep.js: nested-Asyncify handleSleep fix (#9153) - scripts/common/shims/diagnostics.js: logging-only, opt-in via SHIM_DIAGNOSTICS=1 - tests/package.json: add test:kicad:firefox / test:kicad:chrome scripts Known issue (tracked separately): Chrome still renderer-crashes on the first coroutine resume. Asyncify.doRewind replays the deep main-context call stack and exceeds V8's execution-stack limit (Firefox tolerates the same wasm). Proper fix is JSPI. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
12 lines
649 B
Go Template
12 lines
649 B
Go Template
// Template for one dynCall_<sig> binding. Placeholders substituted per signature
|
|
// by inject-dyncall-shims.sh: @SIG@ = signature, @ARGS@ = "index, a0, a1, ...",
|
|
// @CALLARGS@ = "a0, a1, ..." (the args without the function-pointer index).
|
|
//
|
|
// Binds the bare name to the REAL asyncify-instrumented wasm export
|
|
// (wasmExports["dynCall_<sig>"], present because the build links -sDYNCALLS=1).
|
|
// Falls back to getWasmTableEntry only if no such export exists.
|
|
function dynCall_@SIG@(@ARGS@) {
|
|
var f = (typeof wasmExports !== 'undefined') && wasmExports["dynCall_@SIG@"];
|
|
if (f) return f(@ARGS@);
|
|
return getWasmTableEntry(index)(@CALLARGS@);
|
|
}
|