Unverified Commit 69c0d32b by Rémi Verschelde Committed by GitHub

Merge pull request #26240 from eska014/html5-preload-noown

Properly preload files, always use stdout/-err in HTML5 platform
parents 61b41d60 76522624
...@@ -209,7 +209,7 @@ Error AudioDriverJavaScript::capture_start() { ...@@ -209,7 +209,7 @@ Error AudioDriverJavaScript::capture_start() {
} }
function gotMediaInputError(e) { function gotMediaInputError(e) {
console.log(e); out(e);
} }
if (navigator.mediaDevices.getUserMedia) { if (navigator.mediaDevices.getUserMedia) {
......
...@@ -129,10 +129,6 @@ def configure(env): ...@@ -129,10 +129,6 @@ def configure(env):
# us since we don't know requirements at compile-time. # us since we don't know requirements at compile-time.
env.Append(LINKFLAGS=['-s', 'ALLOW_MEMORY_GROWTH=1']) env.Append(LINKFLAGS=['-s', 'ALLOW_MEMORY_GROWTH=1'])
# Since we use both memory growth and MEMFS preloading,
# this avoids unnecessary copying on start-up.
env.Append(LINKFLAGS=['--no-heap-copy'])
# This setting just makes WebGL 2 APIs available, it does NOT disable WebGL 1. # This setting just makes WebGL 2 APIs available, it does NOT disable WebGL 1.
env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1']) env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1'])
......
...@@ -199,7 +199,8 @@ ...@@ -199,7 +199,8 @@
} }
LIBS.FS.mkdirTree(dir); LIBS.FS.mkdirTree(dir);
} }
LIBS.FS.createDataFile('/', file.path, new Uint8Array(file.buffer), true, true, true); // With memory growth, canOwn should be false.
LIBS.FS.createDataFile(file.path, null, new Uint8Array(file.buffer), true, true, false);
}, this); }, this);
preloadedFiles = null; preloadedFiles = null;
......
...@@ -82,7 +82,7 @@ var GodotHTTPRequest = { ...@@ -82,7 +82,7 @@ var GodotHTTPRequest = {
godot_xhr_send_string: function(xhrId, strPtr) { godot_xhr_send_string: function(xhrId, strPtr) {
if (!strPtr) { if (!strPtr) {
console.warn("Failed to send string per XHR: null pointer"); err("Failed to send string per XHR: null pointer");
return; return;
} }
GodotHTTPRequest.requests[xhrId].send(UTF8ToString(strPtr)); GodotHTTPRequest.requests[xhrId].send(UTF8ToString(strPtr));
...@@ -90,11 +90,11 @@ var GodotHTTPRequest = { ...@@ -90,11 +90,11 @@ var GodotHTTPRequest = {
godot_xhr_send_data: function(xhrId, ptr, len) { godot_xhr_send_data: function(xhrId, ptr, len) {
if (!ptr) { if (!ptr) {
console.warn("Failed to send data per XHR: null pointer"); err("Failed to send data per XHR: null pointer");
return; return;
} }
if (len < 0) { if (len < 0) {
console.warn("Failed to send data per XHR: buffer length less than 0"); err("Failed to send data per XHR: buffer length less than 0");
return; return;
} }
GodotHTTPRequest.requests[xhrId].send(HEAPU8.subarray(ptr, ptr + len)); GodotHTTPRequest.requests[xhrId].send(HEAPU8.subarray(ptr, ptr + len));
......
...@@ -69,7 +69,7 @@ Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) { ...@@ -69,7 +69,7 @@ Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) {
eval_ret = eval(UTF8ToString(CODE)); eval_ret = eval(UTF8ToString(CODE));
} }
} catch (e) { } catch (e) {
console.warn(e); err(e);
eval_ret = null; eval_ret = null;
} }
...@@ -97,7 +97,7 @@ Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) { ...@@ -97,7 +97,7 @@ Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) {
if (array_ptr!==0) { if (array_ptr!==0) {
_free(array_ptr) _free(array_ptr)
} }
console.warn(e); err(e);
// fall through // fall through
} }
break; break;
......
...@@ -986,8 +986,8 @@ bool OS_JavaScript::main_loop_iterate() { ...@@ -986,8 +986,8 @@ bool OS_JavaScript::main_loop_iterate() {
if (sync_wait_time < 0) { if (sync_wait_time < 0) {
/* clang-format off */ /* clang-format off */
EM_ASM( EM_ASM(
FS.syncfs(function(err) { FS.syncfs(function(error) {
if (err) { console.warn('Failed to save IDB file system: ' + err.message); } if (error) { err('Failed to save IDB file system: ' + error.message); }
}); });
); );
/* clang-format on */ /* clang-format on */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment