From 68422c5dd68ec0e3b326d3718035d6513142fe4c Mon Sep 17 00:00:00 2001 From: eska Date: Thu, 12 Jan 2017 01:05:07 +0100 Subject: [PATCH 1/2] Relink web build when HTML shell changes Emscripten injects its loader script when linking, so force relinking whenever the HTML shell changes. Also remove useless FULL_ES2 flag, which should be a linker flag, but would impact performance too much. --- platform/javascript/SCsub | 1 + platform/javascript/detect.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub index 5d5cd1590aa..a20c0f7a700 100644 --- a/platform/javascript/SCsub +++ b/platform/javascript/SCsub @@ -22,6 +22,7 @@ env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_fu env.Append(LINKFLAGS=["--shell-file", '"platform/javascript/godot_shell.html"']) build = env.Program('#bin/godot', javascript_objects, PROGSUFFIX=env["PROGSUFFIX"] + ".html") +Depends(build, "godot_shell.html") def make_html_shell(target, source, env): html_path = target[0].rstr() diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index 2cb68740007..55b05a9123e 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -81,7 +81,6 @@ def configure(env): env.Append(CPPFLAGS=['-DJAVASCRIPT_ENABLED', '-DUNIX_ENABLED', '-DPTHREAD_NO_RENAME', '-DNO_FCNTL', '-DMPC_FIXED_POINT', '-DTYPED_METHOD_BIND', '-DNO_THREADS']) env.Append(CPPFLAGS=['-DGLES2_ENABLED']) env.Append(CPPFLAGS=['-DGLES_NO_CLIENT_ARRAYS']) - env.Append(CPPFLAGS=['-s', 'FULL_ES2=1']) # env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED','-DMPC_FIXED_POINT']) if env['wasm'] == 'yes': From 1f7d4c4d0ee8eba0a1d8084019269a45dfa76be4 Mon Sep 17 00:00:00 2001 From: eska Date: Thu, 12 Jan 2017 14:14:40 +0100 Subject: [PATCH 2/2] Improve usability and style in web export presentation - Check for WebGL support, don't load if unsupported - Check for IndexedDB support - Make canvas support check message visible - Colored debug output for warnings and errors - Make it obvious status can be closed by clicking - Don't use status to display non-critical errors - Limit output message count - Add clear output button - Fix setting total memory --- platform/javascript/export/export.cpp | 2 +- platform/javascript/godot_shell.html | 377 ++++++++++++++---------- platform/javascript/javascript_main.cpp | 38 ++- platform/javascript/os_javascript.cpp | 12 +- 4 files changed, 245 insertions(+), 184 deletions(-) diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index ab64ffbb455..fa84a1e67c5 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -377,7 +377,7 @@ EditorExportPlatformJavaScript::EditorExportPlatformJavaScript() { logo->create_from_image(img); max_memory=3; html_title=""; - html_font_family="arial,sans-serif"; + html_font_family="'Droid Sans',arial,sans-serif"; html_controls_enabled=true; pack_mode=PACK_SINGLE_FILE; } diff --git a/platform/javascript/godot_shell.html b/platform/javascript/godot_shell.html index 3170d2bb9ed..a8b95949356 100644 --- a/platform/javascript/godot_shell.html +++ b/platform/javascript/godot_shell.html @@ -3,14 +3,14 @@ $GODOT_HEAD_TITLE - $GODOT_HEAD_INCLUDE +$GODOT_HEAD_INCLUDE
- HTML5 canvas appears to be unsupported in the current browser.
Please try updating or use a different browser. + HTML5 canvas appears to be unsupported in the current browser.
+ Please try updating or use a different browser.
- Loading page... + Downloading page...
- + - +
- - +
+
+ Output: + +
+
+
+ - {{{ SCRIPT }}} +{{{ SCRIPT }}} + diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp index 586ccc9b4ea..99b16b2b9b0 100644 --- a/platform/javascript/javascript_main.cpp +++ b/platform/javascript/javascript_main.cpp @@ -140,10 +140,9 @@ static void _godot_draw(void) { extern "C" { -void main_after_fs_sync(int value) { +void main_after_fs_sync() { start_step=1; - printf("FS SYNCHED!\n"); } } @@ -178,26 +177,25 @@ int main(int argc, char *argv[]) { glutDisplayFunc(_godot_draw); //glutSpecialFunc(gears_special); + //mount persistent file system + EM_ASM( + FS.mkdir('/userfs'); + FS.mount(IDBFS, {}, '/userfs'); + // sync from persistent state into memory and then + // run the 'main_after_fs_sync' function + FS.syncfs(true, function(err) { - //mount persistent filesystem - EM_ASM( - FS.mkdir('/userfs'); - FS.mount(IDBFS, {}, '/userfs'); - - - - // sync from persisted state into memory and then - // run the 'test' function - FS.syncfs(true, function (err) { - assert(!err); - console.log("done syncinc!"); - _after_sync_cb = Module.cwrap('main_after_fs_sync', 'void',['number']); - _after_sync_cb(0); - - }); - - ); + if (err) { + Module.setStatus('Failed to load persistent data\nPlease allow (third-party) cookies'); + Module.printErr('Failed to populate IDB file system: ' + err.message); + Module.exit(); + } else { + Module.print('Successfully populated IDB file system'); + ccall('main_after_fs_sync', 'void', []); + } + }); + ); glutMainLoop(); diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index 14af9b3e37e..aa728c768a5 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -502,18 +502,12 @@ bool OS_JavaScript::main_loop_iterate() { time_to_save_sync-=elapsed; - print_line("elapsed "+itos(elapsed)+" tts "+itos(time_to_save_sync)); - if (time_to_save_sync<0) { //time to sync, for real - // run 'success' - print_line("DOING SYNCH!"); EM_ASM( - FS.syncfs(function (err) { - assert(!err); - console.log("Synched!"); - //ccall('success', 'v'); - }); + FS.syncfs(function(err) { + if (err) { Module.printErr('Failed to save IDB file system: ' + err.message); } + }); ); }