Bytedance mini-game WASM support for both android and iOS platforms. (#16644)

This commit is contained in:
James Chen
2023-12-29 16:01:34 +08:00
committed by GitHub
parent 716b935944
commit e080cf17a7
2 changed files with 12 additions and 4 deletions
+10 -1
View File
@@ -64,6 +64,9 @@ if (WECHAT) {
let isVersionGreaterOrEqualTo;
if (BYTEDANCE) {
isVersionGreaterOrEqualTo = function isVersionGreaterOrEqualTo (versionA: string, versionB: string): boolean {
if (!versionA || !versionB) {
return false;
}
// Split the version number string into an array of integers
function parseVersion (version: string): number[] {
return version.split('.').map((part: string) => parseInt(part, 10));
@@ -167,9 +170,15 @@ class SystemInfo extends EventTarget {
}
if (BYTEDANCE) {
let minSDKVersionSupportWasm = '';
if (this.os === OS.ANDROID) {
minSDKVersionSupportWasm = '3.9.0';
} else if (this.os === OS.IOS) {
minSDKVersionSupportWasm = '3.8.0';
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error TTWebAssembly is defined if bytedance client supports wasm.
if (isVersionGreaterOrEqualTo(minigameSysInfo.SDKVersion, '3.7.0') && typeof TTWebAssembly === 'object') {
if (isVersionGreaterOrEqualTo(minigameSysInfo.SDKVersion, minSDKVersionSupportWasm) && typeof TTWebAssembly === 'object') {
return true;
}
}
@@ -57,9 +57,8 @@ if (!GameGlobal.__isAdapterInjected) {
GameGlobal.__isAdapterInjected = true;
inject();
}
//NOTE: Don't override global `WebAssembly` variable since bytedance platform has a bug that will cause TTWebAssembly.instantiate fails.
// So we add our own `CCWebAssembly` variable here.
global.CCWebAssembly = global.TTWebAssembly;
global.WebAssembly = global.CCWebAssembly = global.TTWebAssembly;
require('../../../../common/xmldom/dom-parser');
require('../unify');