This commit is contained in:
Michael Droettboom 2018-09-19 18:33:03 -04:00
parent 8d37d095b3
commit c2e981b87e
1 changed files with 13 additions and 11 deletions

View File

@ -32,11 +32,12 @@ var languagePluginLoader = new Promise((resolve, reject) => {
}
};
// clang-format off
let preloadWasm = () => {
// On Chrome, we have to instantiate wasm asynchronously. Since that can't
// be done synchronously within the call to dlopen, we instantiate every .so
// that comes our way up front, caching it in the `preloadedWasm`
// dictionary.
// On Chrome, we have to instantiate wasm asynchronously. Since that
// can't be done synchronously within the call to dlopen, we instantiate
// every .so that comes our way up front, caching it in the
// `preloadedWasm` dictionary.
let promise = new Promise((resolve) => resolve());
let FS = pyodide._module.FS;
@ -55,11 +56,12 @@ var languagePluginLoader = new Promise((resolve, reject) => {
const path = rootpath + entry;
if (entry.endsWith('.so')) {
if (Module['preloadedWasm'][path] === undefined) {
promise = promise.then(
() => Module['loadWebAssemblyModule'](FS.readFile(path), true)
).then(
(module) => { Module['preloadedWasm'][path] = module; }
);
promise = promise
.then(() => Module['loadWebAssemblyModule'](
FS.readFile(path), true))
.then((module) => {
Module['preloadedWasm'][path] = module;
});
}
} else if (FS.isDir(FS.lookupPath(path).node.mode)) {
recurseDir(path + '/');
@ -71,6 +73,7 @@ var languagePluginLoader = new Promise((resolve, reject) => {
return promise;
}
// clang-format on
let _loadPackage = (names) => {
// DFS to find all dependencies of the requested packages
@ -132,8 +135,7 @@ var languagePluginLoader = new Promise((resolve, reject) => {
delete window.pyodide._module.monitorRunDependencies;
const packageList = Array.from(Object.keys(toLoad)).join(', ');
if (!isFirefox) {
preloadWasm().then(() => {
resolve(`Loaded ${packageList}`) });
preloadWasm().then(() => {resolve(`Loaded ${packageList}`)});
} else {
resolve(`Loaded ${packageList}`);
}