fix wasm path passing
This commit is contained in:
parent
c08d830127
commit
80f72d0a7f
@ -8,8 +8,11 @@ var performance = {
|
|||||||
Module['instantiateWasm'] = (info, receiveInstance) => {
|
Module['instantiateWasm'] = (info, receiveInstance) => {
|
||||||
console.log("loading wasm...", info);
|
console.log("loading wasm...", info);
|
||||||
|
|
||||||
// Use provided wasmPath parameter, fallback to hardcoded path
|
// Use global wasmFilePath (should always be set by the main app)
|
||||||
var wasmPath = Module.wasmFilePath || "pages/emblemscanner/qrtool.wx.wasm.br";
|
var wasmPath = global.wasmFilePath;
|
||||||
|
if (!wasmPath) {
|
||||||
|
throw new Error("wasmFilePath must be provided via global.wasmFilePath");
|
||||||
|
}
|
||||||
console.log("Using WASM path:", wasmPath);
|
console.log("Using WASM path:", wasmPath);
|
||||||
|
|
||||||
WebAssembly.instantiate(wasmPath, info).then((result) => {
|
WebAssembly.instantiate(wasmPath, info).then((result) => {
|
||||||
|
|||||||
@ -164,6 +164,7 @@ function get_current_package_path() {
|
|||||||
*/
|
*/
|
||||||
function get_wasm_file_path(filename) {
|
function get_wasm_file_path(filename) {
|
||||||
const packagePath = get_current_package_path();
|
const packagePath = get_current_package_path();
|
||||||
|
console.log('current package path', packagePath);
|
||||||
return `${packagePath}/${filename}`;
|
return `${packagePath}/${filename}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,12 +8,12 @@ var qrtool_ready = false;
|
|||||||
* Load qrtool WASM module
|
* Load qrtool WASM module
|
||||||
*/
|
*/
|
||||||
function load_qrtool(wasmFilePath) {
|
function load_qrtool(wasmFilePath) {
|
||||||
|
// Set global WASM file path before loading the module
|
||||||
|
global.wasmFilePath = wasmFilePath;
|
||||||
|
|
||||||
// Load the WASM module
|
// Load the WASM module
|
||||||
var m = require('./qrtool.wx.js');
|
var m = require('./qrtool.wx.js');
|
||||||
|
|
||||||
// Set the WASM file path
|
|
||||||
m.wasmFilePath = wasmFilePath;
|
|
||||||
|
|
||||||
m.onRuntimeInitialized = () => {
|
m.onRuntimeInitialized = () => {
|
||||||
qrtool_ready = true;
|
qrtool_ready = true;
|
||||||
qrtool = m;
|
qrtool = m;
|
||||||
|
|||||||
@ -34,8 +34,11 @@ var performance = {
|
|||||||
};
|
};
|
||||||
Module["instantiateWasm"] = (info, receiveInstance) => {
|
Module["instantiateWasm"] = (info, receiveInstance) => {
|
||||||
console.log("loading wasm...", info);
|
console.log("loading wasm...", info);
|
||||||
// Use provided wasmPath parameter, fallback to hardcoded path
|
// Use global wasmFilePath (should always be set by the main app)
|
||||||
var wasmPath = Module.wasmFilePath || "pages/emblemscanner/qrtool.wx.wasm.br";
|
var wasmPath = global.wasmFilePath;
|
||||||
|
if (!wasmPath) {
|
||||||
|
throw new Error("wasmFilePath must be provided via global.wasmFilePath");
|
||||||
|
}
|
||||||
console.log("Using WASM path:", wasmPath);
|
console.log("Using WASM path:", wasmPath);
|
||||||
WebAssembly.instantiate(wasmPath, info).then(result => {
|
WebAssembly.instantiate(wasmPath, info).then(result => {
|
||||||
console.log("result:", result);
|
console.log("result:", result);
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
console.log("hello from emblemscanner worker");
|
console.log("hello from emblemscanner worker");
|
||||||
|
|
||||||
// Set WASM file path before loading qrtool
|
// Set global WASM file path before loading qrtool
|
||||||
// The wasmFilePath will be passed from the main thread when the worker is created
|
// The wasmFilePath will be passed from the main thread when the worker is created
|
||||||
if (typeof worker !== "undefined" && worker.wasmFilePath) {
|
if (typeof worker !== "undefined" && worker.wasmFilePath) {
|
||||||
let qrtoolModule = require('./qrtool.wx.js');
|
global.wasmFilePath = worker.wasmFilePath;
|
||||||
qrtoolModule.wasmFilePath = worker.wasmFilePath;
|
let qrtool = require('./qrtool.wx.js');
|
||||||
let qrtool = qrtoolModule;
|
|
||||||
} else {
|
} else {
|
||||||
let qrtool = require('./qrtool.wx.js');
|
let qrtool = require('./qrtool.wx.js');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,8 +34,11 @@ var performance = {
|
|||||||
};
|
};
|
||||||
Module["instantiateWasm"] = (info, receiveInstance) => {
|
Module["instantiateWasm"] = (info, receiveInstance) => {
|
||||||
console.log("loading wasm...", info);
|
console.log("loading wasm...", info);
|
||||||
// Use provided wasmPath parameter, fallback to hardcoded path
|
// Use global wasmFilePath (should always be set by the main app)
|
||||||
var wasmPath = Module.wasmFilePath || "pages/emblemscanner/qrtool.wx.wasm.br";
|
var wasmPath = global.wasmFilePath;
|
||||||
|
if (!wasmPath) {
|
||||||
|
throw new Error("wasmFilePath must be provided via global.wasmFilePath");
|
||||||
|
}
|
||||||
console.log("Using WASM path:", wasmPath);
|
console.log("Using WASM path:", wasmPath);
|
||||||
WebAssembly.instantiate(wasmPath, info).then(result => {
|
WebAssembly.instantiate(wasmPath, info).then(result => {
|
||||||
console.log("result:", result);
|
console.log("result:", result);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user