Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix: serialize binaryen optimization on windows

yhh141fcf2fae40
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index bc5fc0567..5306efc1d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -69,8 +69,8 @@ cd desktop && npm run dev
### Windows WASM optimizer workers
-The build tools default to `BINARYEN_CORES=4` on Windows to avoid crashes in the
-bundled Binaryen optimizer's default all-CPU worker pool. Release optimization
+The build tools default to `BINARYEN_CORES=1` on Windows to avoid crashes in the
+bundled Binaryen optimizer's multi-worker execution. Release optimization
flags, including `-O3`, remain unchanged. Explicit `BINARYEN_CORES` values take
precedence; other platforms keep Binaryen's default behavior.
@@ -78,7 +78,7 @@ When invoking Emscripten or CMake directly outside the build tools, set the same
environment variable in PowerShell before building:
```powershell
-$env:BINARYEN_CORES = '4'
+$env:BINARYEN_CORES = '1'
```
### Branch Naming
diff --git a/build-tools/utils/emscripten.js b/build-tools/utils/emscripten.js
index 53fd3f773..fe2085dee 100644
--- a/build-tools/utils/emscripten.js
+++ b/build-tools/utils/emscripten.js
@@ -107,7 +107,7 @@ let emsdkActivated = false;
export function withBinaryenWorkers(env, platform = process.platform) {
const result = { ...env };
if (platform === 'win32' && result.BINARYEN_CORES === undefined) {
- result.BINARYEN_CORES = '4';
+ result.BINARYEN_CORES = '1';
}
return result;
}
diff --git a/tools/tests/emscripten-workers.test.ts b/tools/tests/emscripten-workers.test.ts
index fab202368..a9b8a4ba2 100644
--- a/tools/tests/emscripten-workers.test.ts
+++ b/tools/tests/emscripten-workers.test.ts
@@ -5,7 +5,7 @@ import { runCommand, withBinaryenWorkers } from '../../build-tools/utils/emscrip
it('bounds Windows workers while preserving explicit settings and other platforms', () => {
const original = { PATH: 'toolchain' };
- expect(withBinaryenWorkers(original, 'win32')).toEqual({ ...original, BINARYEN_CORES: '4' });
+ expect(withBinaryenWorkers(original, 'win32')).toEqual({ ...original, BINARYEN_CORES: '1' });
expect(original).toEqual({ PATH: 'toolchain' });
for (const platform of ['win32', 'linux', 'darwin']) {
expect(withBinaryenWorkers({ BINARYEN_CORES: '1' }, platform).BINARYEN_CORES).toBe('1');
@@ -25,5 +25,5 @@ it('applies the platform default to the actual child process', async () => {
const result = await runCommand(process.execPath, [
'-p', 'process.env.BINARYEN_CORES',
], { silent: true, env: { BINARYEN_CORES: undefined } });
- expect(result.stdout.trim()).toBe(process.platform === 'win32' ? '4' : 'undefined');
+ expect(result.stdout.trim()).toBe(process.platform === 'win32' ? '1' : 'undefined');
});