fix(QMCv2): Fail gracefully when WebAssembly loader failed.

(cherry picked from commit 700574fb8efd1a1057bc16a053e5015dcb2e3044)
This commit is contained in:
鲁树人 2021-12-25 12:07:47 +00:00 committed by MengYX
parent 55772dec31
commit fc4a0e002f
No known key found for this signature in database
GPG Key ID: E63F9C7303E8F604

View File

@ -25,7 +25,14 @@ export async function DecryptQMCWasm(mggBlob: ArrayBuffer): Promise<QMC2Decrypti
const result: QMC2DecryptionResult = { success: false, data: new Uint8Array(), songId: 0, error: '' }; const result: QMC2DecryptionResult = { success: false, data: new Uint8Array(), songId: 0, error: '' };
// 初始化模组 // 初始化模组
const QMCCrypto = await QMCCryptoModule(); let QMCCrypto: QMCCrypto;
try {
QMCCrypto = await QMCCryptoModule();
} catch (err: any) {
result.error = err?.message || 'wasm 加载失败';
return result;
}
// 申请内存块,并文件末端数据到 WASM 的内存堆 // 申请内存块,并文件末端数据到 WASM 的内存堆
const detectionBuf = new Uint8Array(mggBlob.slice(-DETECTION_SIZE)); const detectionBuf = new Uint8Array(mggBlob.slice(-DETECTION_SIZE));