Skip to content

Commit

Permalink
Revert "emrun stability improvements (emscripten-core#8456)"
Browse files Browse the repository at this point in the history
This reverts commit 629390f.
  • Loading branch information
VirtualTim authored May 23, 2019
1 parent 9096e58 commit b5f8803
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
4 changes: 2 additions & 2 deletions emrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ def kill_browser_process():
temporary Firefox profile that was created, if one exists."""
global browser_process, processname_killed_atexit, emrun_options, ADB
if browser_process:
logv('Terminating browser process..')
try:
logv('Terminating browser process..')
browser_process.kill()
delete_emrun_safe_firefox_profile()
except Exception as e:
Expand Down Expand Up @@ -1645,7 +1645,7 @@ def run(cmd):
httpd = HTTPWebServer((options.hostname, options.port), HTTPHandler)

if not options.no_browser:
logi("Starting browser: %s" % ' '.join(browser))
logi("Executing %s" % ' '.join(browser))
# if browser[0] == 'cmd':
# Workaround an issue where passing 'cmd /C start' is not able to detect when the user closes the page.
# serve_forever = True
Expand Down
31 changes: 12 additions & 19 deletions src/emrun_postjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ if (typeof window === "object" && (typeof ENVIRONMENT_IS_PTHREAD === 'undefined'
var emrun_should_close_itself = false;
function postExit(msg) {
var http = new XMLHttpRequest();
// Don't do this immediately, this may race with the notification about the return code reaching the
// server. Send a *sync* xhr so that we know for sure that the server has gotten the return code
// before we continue.
http.open("POST", "stdio.html", false);
http.onreadystatechange = function() {
if (http.readyState == 4 /*DONE*/) {
try {
// Try closing the current browser window, since it exit()ed itself. This can shut down the browser process
// and emrun does not need to kill the whole browser process.
if (typeof window !== 'undefined' && window.close) window.close();
} catch(e) {}
}
}
http.open("POST", "stdio.html", true);
http.send(msg);
try {
// Try closing the current browser window, since it exit()ed itself. This can shut down the browser process
// and then emrun does not need to kill the whole browser process.
window.close();
} catch(e) {}
}
function post(msg) {
var http = new XMLHttpRequest();
Expand All @@ -44,16 +45,8 @@ if (typeof window === "object" && (typeof ENVIRONMENT_IS_PTHREAD === 'undefined'
out = function emrun_print(text) { post('^out^'+(emrun_http_sequence_number++)+'^'+encodeURIComponent(text)); prevPrint(text); }
err = function emrun_printErr(text) { post('^err^'+(emrun_http_sequence_number++)+'^'+encodeURIComponent(text)); prevErr(text); }

// Notify emrun web server that this browser has successfully launched the page. Note that we may need to
// wait for the server to be ready.
function tryToSendPageload() {
try {
post('^pageload^');
} catch (e) {
setTimeout(tryToSendPageload, 50);
}
}
tryToSendPageload();
// Notify emrun web server that this browser has successfully launched the page.
post('^pageload^');
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/browser_reporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function reportErrorToServer(message) {
if (typeof window === 'object' && window) {
window.addEventListener('error', function(e) {
var xhr = new XMLHttpRequest();
xhr.open('GET', encodeURI('http://localhost:8888?exception=' + e.message + ' / ' + e.stack));
xhr.open('GET', encodeURI('http://localhost:8888?exception=' + e.message + ' / ' + e.target));
xhr.send();
});
}

0 comments on commit b5f8803

Please sign in to comment.