Skip to content

Commit

Permalink
bytedance wasm loading. todo: change packaged wasm file extension fro…
Browse files Browse the repository at this point in the history
…m .wasm to .bin
  • Loading branch information
lealzhan committed Sep 27, 2023
1 parent 97a895a commit 6ff5f96
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 9 additions & 2 deletions pal/wasm/wasm-minigame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,21 @@
THE SOFTWARE.
*/

import { HUAWEI, TAOBAO_MINIGAME, WASM_SUBPACKAGE, XIAOMI } from 'internal:constants';
import { BYTEDANCE, HUAWEI, TAOBAO_MINIGAME, WASM_SUBPACKAGE, XIAOMI } from 'internal:constants';
import { minigame } from 'pal/minigame';
import { basename } from '../../cocos/core/utils/path';
import { checkPalIntegrity, withImpl } from '../integrity-check';
import { log } from '../../cocos/core/platform/debug';

export function instantiateWasm (wasmUrl: string, importObject: WebAssembly.Imports): Promise<any> {
return getPlatformBinaryUrl(wasmUrl).then((url) => WebAssembly.instantiate(url, importObject));
if (BYTEDANCE) {
const bytedanceWASMUrl = `${wasmUrl.replace(/\.wasm$/, '.bin')}`;
return fetchBuffer(bytedanceWASMUrl).then(
(arrayBuffer) => WebAssembly.instantiate(arrayBuffer, importObject),
);
} else {
return getPlatformBinaryUrl(wasmUrl).then((url) => WebAssembly.instantiate(url, importObject));
}
}

export function fetchBuffer (binaryUrl: string): Promise<ArrayBuffer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ test('genBuildTimeConstants', () => {
"MINIGAME": false,
"NATIVE": true,
"NET_MODE": 0,
"NOT_PACK_PHYSX_LIBS": false,
"OPPO": false,
"PREVIEW": false,
"QTT": false,
Expand Down

0 comments on commit 6ff5f96

Please sign in to comment.