Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 13 additions & 19 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -2182,25 +2182,19 @@ addToLibrary({
},

$asyncLoad__docs: '/** @param {boolean=} noRunDep */',
$asyncLoad: (url, onload, onerror, noRunDep) => {
var dep = !noRunDep ? getUniqueRunDependency(`al ${url}`) : '';
readAsync(url).then(
(arrayBuffer) => {
#if ASSERTIONS
assert(arrayBuffer, `Loading data file "${url}" failed (no arrayBuffer).`);
#endif
onload(new Uint8Array(arrayBuffer));
if (dep) removeRunDependency(dep);
},
(err) => {
if (onerror) {
onerror();
} else {
throw `Loading data file "${url}" failed.`;
}
}
);
if (dep) addRunDependency(dep);
$asyncLoad: (url, noRunDep) => {
return new Promise((resolve, reject) => {
var dep = !noRunDep ? getUniqueRunDependency(`al ${url}`) : '';
if (dep) addRunDependency(dep);
readAsync(url).then(
(arrayBuffer) => {
#if ASSERTIONS
assert(arrayBuffer, `Loading data file "${url}" failed (no arrayBuffer).`);
#endif
resolve(new Uint8Array(arrayBuffer));
if (dep) removeRunDependency(dep);
}, reject);
});
},

$alignMemory: (size, alignment) => {
Expand Down
5 changes: 3 additions & 2 deletions src/library_async.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,8 @@ addToLibrary({
emscripten_wget_data__async: true,
emscripten_wget_data: (url, pbuffer, pnum, perror) => {
return Asyncify.handleSleep((wakeUp) => {
asyncLoad(UTF8ToString(url), (byteArray) => {
/* no need for run dependency, this is async but will not do any prepare etc. step */
asyncLoad(UTF8ToString(url), /*noRunDep=*/true).then((byteArray) => {
// can only allocate the buffer after the wakeUp, not during an asyncing
var buffer = _malloc(byteArray.length); // must be freed by caller!
HEAPU8.set(byteArray, buffer);
Expand All @@ -481,7 +482,7 @@ addToLibrary({
}, () => {
{{{ makeSetValue('perror', 0, '1', 'i32') }}};
wakeUp();
}, true /* no need for run dependency, this is async but will not do any prepare etc. step */ );
});
});
},

Expand Down
2 changes: 1 addition & 1 deletion src/library_dylink.js
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ var LibraryDylink = {

var libFile = locateFile(libName);
if (flags.loadAsync) {
return new Promise((resolve, reject) => asyncLoad(libFile, resolve, reject));
return asyncLoad(libFile);
}

// load the binary synchronously
Expand Down
2 changes: 1 addition & 1 deletion src/library_fs_shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ addToLibrary({
}
addRunDependency(dep);
if (typeof url == 'string') {
asyncLoad(url, processData, onerror);
asyncLoad(url).then(processData, onerror);
} else {
processData(url);
}
Expand Down
5 changes: 3 additions & 2 deletions src/library_wget.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ var LibraryWget = {
emscripten_async_wget_data__proxy: 'sync',
emscripten_async_wget_data: (url, userdata, onload, onerror) => {
{{{ runtimeKeepalivePush() }}}
asyncLoad(UTF8ToString(url), (byteArray) => {
/* no need for run dependency, this is async but will not do any prepare etc. step */
asyncLoad(UTF8ToString(url), /*noRunDep=*/true).then((byteArray) => {
{{{ runtimeKeepalivePop() }}}
callUserCallback(() => {
var buffer = _malloc(byteArray.length);
Expand All @@ -79,7 +80,7 @@ var LibraryWget = {
{{{ makeDynCall('vp', 'onerror') }}}(userdata);
});
}
}, true /* no need for run dependency, this is async but will not do any prepare etc. step */ );
});
},

emscripten_async_wget2__deps: ['$PATH_FS', '$wget', '$stackRestore', '$stringToUTF8OnStack'],
Expand Down
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_dylink.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6339
6298
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_dylink.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13936
13867
Loading