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.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(minigame): no mini-game module needs BigInt64Array, so WeChat DevTools boots the game
yhh17b5eab5c28d
diff --git a/build-tools/build.config.js b/build-tools/build.config.jsindex 2cc05704d..4c93c38b0 100644--- a/build-tools/build.config.js+++ b/build-tools/build.config.js@@ -43,7 +43,7 @@ export default {'web-js': {buildDir: 'build/cmake/web-js',cmakeFlags: ['-DES_BUILD_WEB=ON', '-DES_BUILD_TESTS=OFF', '-DES_WASM2JS=ON',- '-DES_MAIN_DISABLE_SIMD=ON', '-DES_WASM_BIGINT=OFF'],+ '-DES_MAIN_DISABLE_SIMD=ON'],targets: ['esengine_sdk'],// Beside the wasm engine, so the editor's copy and every web export// carry both and the page picks at boot.@@ -87,12 +87,12 @@ export default {'sdk/esengine.wxgame.wasm': 'wasm/wechat-glx/esengine.wxgame.wasm',},},- // The mini-game engine for vivo's quick-game V8 (8.3), which refuses both a- // SIMD opcode ("Invalid opcode (enable with --experimental-wasm-simd)") and- // an i64 in a wasm↔JS signature ("wasm function signature contains illegal type").+ // The mini-game engine for vivo's quick-game V8 (8.3), which refuses a SIMD+ // opcode ("Invalid opcode (enable with --experimental-wasm-simd)"). What it also+ // refuses, an i64 in a wasm↔JS signature, no mini-game build carries.quickgame: {buildDir: 'build/cmake/qgame',- cmakeFlags: ['-DES_BUILD_WXGAME=ON', '-DES_BUILD_TESTS=OFF', '-DES_MAIN_DISABLE_SIMD=ON', '-DES_WASM_BIGINT=OFF'],+ cmakeFlags: ['-DES_BUILD_WXGAME=ON', '-DES_BUILD_TESTS=OFF', '-DES_MAIN_DISABLE_SIMD=ON'],targets: ['esengine_wxgame'],outputs: {'sdk/esengine.wxgame.js': 'wasm/quickgame/esengine.wxgame.js',diff --git a/cmake/Emscripten.cmake b/cmake/Emscripten.cmakeindex f5c773ac5..606f6d57f 100644--- a/cmake/Emscripten.cmake+++ b/cmake/Emscripten.cmake@@ -26,17 +26,23 @@ set(ES_EMSCRIPTEN_COMPILE_FLAGS# already ships SIMD to web AND wechat, so this is on by default with a compat# fallback (`-DES_MAIN_DISABLE_SIMD=ON`) mirroring BOX2D_DISABLE_SIMD.option(ES_MAIN_DISABLE_SIMD "Disable wasm SIMD for the main module (compat fallback)" OFF)-# Hosts on V8 older than 8.5 reject an i64 in a wasm↔JS signature ("wasm function-# signature contains illegal type"); OFF legalizes i64 into i32 pairs instead.-option(ES_WASM_BIGINT "Pass i64 across the wasm↔JS boundary as BigInt" ON)+# A mini-game module never crosses the wasm↔JS boundary with BigInt, in any target of+# this configuration: i64 is legalized into i32 pairs and the glue carries no HEAP64.+# Mini-game hosts differ on what they offer. V8 older than 8.5 rejects an i64 in a+# signature ("wasm function signature contains illegal type"), WeChat DevTools' game+# realm has no BigInt64Array, and JavaScriptCore before iOS 15 neither. No target here+# has an i64 the SDK reads as a BigInt, so this costs nothing the game can see.+if(ES_BUILD_WXGAME)+ add_link_options(-sWASM_BIGINT=0)+endif()# The engine as plain JavaScript (emscripten's wasm2js, -sWASM=0) for a host that# has no WebAssembly at all: the same C++, the same embind surface, the same SDK —# only the core's container changes. wasm2js has no SIMD and no BigInt i64, so a# configure that asks for it gets neither (see the checks below).option(ES_WASM2JS "Build the SDK engine as plain JavaScript (wasm2js) instead of wasm" OFF)if(ES_WASM2JS)- if(NOT ES_MAIN_DISABLE_SIMD OR ES_WASM_BIGINT)- message(FATAL_ERROR "ES_WASM2JS needs -DES_MAIN_DISABLE_SIMD=ON -DES_WASM_BIGINT=OFF: wasm2js lowers neither SIMD nor BigInt i64.")+ if(NOT ES_MAIN_DISABLE_SIMD)+ message(FATAL_ERROR "ES_WASM2JS needs -DES_MAIN_DISABLE_SIMD=ON: wasm2js does not lower SIMD.")endif()endif()if(NOT ES_MAIN_DISABLE_SIMD)@@ -286,9 +292,6 @@ function(es_apply_wxgame_sdk_settings TARGET_NAME)target_compile_options(${TARGET_NAME} PRIVATE ${ES_EMSCRIPTEN_COMPILE_FLAGS} -flto -fno-exceptions)set(_WXGAME_LINK ${ES_EMSCRIPTEN_WXGAME_SDK_FLAGS})- if(NOT ES_WASM_BIGINT)- list(APPEND _WXGAME_LINK -sWASM_BIGINT=0)- endif()# WeChat's EmscriptenGLX: its gl* run inside the wasm and hand commands to# the host, falling back to emscripten_gl* where the host has no GLX. The# runtime starts it (miniGameRuntime) when the entry points are exported.diff --git a/pipeline/src/project/platforms.ts b/pipeline/src/project/platforms.tsindex 8d5739e5e..4312ac490 100644--- a/pipeline/src/project/platforms.ts+++ b/pipeline/src/project/platforms.ts@@ -68,9 +68,9 @@ export type MiniGamePlatform = (typeof MINIGAME_PLATFORMS)[number];/*** Which engine build a web-runtime target packages: the browser one, the- * CommonJS mini-game one, or that one again without wasm SIMD and BigInt i64 —- * for the quick-game hosts, whose V8 (8.3) refuses both, and for Alipay and- * Huawei, which publish no wasm feature level to rely on.+ * CommonJS mini-game one, or that one again without wasm SIMD — for the+ * quick-game hosts, whose V8 (8.3) refuses it, and for Alipay and Huawei, which+ * publish no wasm feature level to rely on.*/export function engineBuildFor(platform: ExportPlatform): 'web' | 'minigame' | 'quickgame' {if (platform === 'quickgame' || platform === 'alipay' || platform === 'huawei') return 'quickgame';diff --git a/tools/launchers/minigameHost.mjs b/tools/launchers/minigameHost.mjsindex 7eb529439..608489527 100644--- a/tools/launchers/minigameHost.mjs+++ b/tools/launchers/minigameHost.mjs@@ -101,6 +101,11 @@ export const HOST_PAGE = (entry, failSubpackage = null) => `<!doctype html><script>(() => {const log = (m) => console.log('[minigame] ' + m);+ // Not every mini-game realm has these: WeChat DevTools' does not, nor does+ // JavaScriptCore before iOS 15. A glue that builds a view from them fails here too+ // rather than only on the host it reaches a user through.+ delete globalThis.BigInt64Array;+ delete globalThis.BigUint64Array;// Vendor contract: the FIRST createCanvas() hands back the on-screen canvas and// every call after it is offscreen scratch. Hand the engine a fresh offscreen// one instead and the game runs perfectly, drawing where nobody can see.