Skip to content

Remove hard dependency on Browser from Asyncify #12181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 13, 2020
Merged
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
10 changes: 6 additions & 4 deletions src/library_async.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mergeInto(LibraryManager.library, {
},

#if ASYNCIFY
$Asyncify__deps: ['$Browser', '$runAndAbortIfError'],
$Asyncify__deps: ['$runAndAbortIfError'],
$Asyncify: {
State: {
Normal: 0,
Expand Down Expand Up @@ -213,7 +213,7 @@ mergeInto(LibraryManager.library, {
#endif
Asyncify.state = Asyncify.State.Rewinding;
runAndAbortIfError(function() { Module['_asyncify_start_rewind'](Asyncify.currData) });
if (Browser.mainLoop.func) {
if (typeof Browser !== 'undefined' && Browser.mainLoop.func) {
Browser.mainLoop.resume();
}
var start = Asyncify.getDataRewindFunc(Asyncify.currData);
Expand Down Expand Up @@ -251,7 +251,7 @@ mergeInto(LibraryManager.library, {
err('ASYNCIFY: start unwind ' + Asyncify.currData);
#endif
runAndAbortIfError(function() { Module['_asyncify_start_unwind'](Asyncify.currData) });
if (Browser.mainLoop.func) {
if (typeof Browser !== 'undefined' && Browser.mainLoop.func) {
Browser.mainLoop.pause();
}
}
Expand Down Expand Up @@ -287,13 +287,14 @@ mergeInto(LibraryManager.library, {
},
},

emscripten_sleep__deps: ['$Browser'],
emscripten_sleep: function(ms) {
Asyncify.handleSleep(function(wakeUp) {
Browser.safeSetTimeout(wakeUp, ms);
});
},

emscripten_wget__deps: ['$PATH_FS', '$FS'],
emscripten_wget__deps: ['$Browser', '$PATH_FS', '$FS'],
emscripten_wget: function(url, file) {
Asyncify.handleSleep(function(wakeUp) {
var _url = UTF8ToString(url);
Expand All @@ -316,6 +317,7 @@ mergeInto(LibraryManager.library, {
});
},

emscripten_wget_data__deps: ['$Browser'],
emscripten_wget_data: function(url, pbuffer, pnum, perror) {
Asyncify.handleSleep(function(wakeUp) {
Browser.asyncLoad(UTF8ToString(url), function(byteArray) {
Expand Down