From ef14712d8aa3612505ff7eca0289914e33b0840a Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Tue, 22 Jun 2021 21:24:54 -0400 Subject: [PATCH 1/5] Added runtime dependency to hopefully fix the intermittent test failures --- src/mono/sample/mbr/browser/runtime.js | 2 ++ src/mono/sample/wasm/browser-bench/runtime.js | 2 ++ src/mono/sample/wasm/browser-profile/runtime.js | 2 ++ src/mono/sample/wasm/browser/runtime.js | 2 ++ src/mono/wasm/debugger/tests/debugger-test/runtime-debugger.js | 2 ++ src/mono/wasm/runtime-test.js | 3 +++ src/tests/FunctionalTests/WebAssembly/Browser/AOT/runtime.js | 2 ++ .../WebAssembly/Browser/NormalInterp/runtime.js | 2 ++ 8 files changed, 17 insertions(+) diff --git a/src/mono/sample/mbr/browser/runtime.js b/src/mono/sample/mbr/browser/runtime.js index 32918aa573a44a..bf5153ff968bd0 100644 --- a/src/mono/sample/mbr/browser/runtime.js +++ b/src/mono/sample/mbr/browser/runtime.js @@ -5,7 +5,9 @@ var Module = { config: null, preInit: async function() { + Module.addRunDependency('mono-config.json'); Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); + Module.removeDependency('mono-config.json'); }, // Called when the runtime is initialized and wasm is ready diff --git a/src/mono/sample/wasm/browser-bench/runtime.js b/src/mono/sample/wasm/browser-bench/runtime.js index 60c383d13cb524..507447bc2111e7 100644 --- a/src/mono/sample/wasm/browser-bench/runtime.js +++ b/src/mono/sample/wasm/browser-bench/runtime.js @@ -4,7 +4,9 @@ var Module = { config: null, preInit: async function() { + Module.addRunDependency('mono-config.json'); Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); + Module.removeDependency('mono-config.json'); }, // Called when the runtime is initialized and wasm is ready diff --git a/src/mono/sample/wasm/browser-profile/runtime.js b/src/mono/sample/wasm/browser-profile/runtime.js index 2c83ff54ef93d0..ecd7b0f9d20a00 100644 --- a/src/mono/sample/wasm/browser-profile/runtime.js +++ b/src/mono/sample/wasm/browser-profile/runtime.js @@ -5,7 +5,9 @@ var Module = { config: null, preInit: async function() { + Module.addRunDependency('mono-config.json'); Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); + Module.removeDependency('mono-config.json'); }, // Called when the runtime is initialized and wasm is ready diff --git a/src/mono/sample/wasm/browser/runtime.js b/src/mono/sample/wasm/browser/runtime.js index e97feef745a95d..ee78b18efa345a 100644 --- a/src/mono/sample/wasm/browser/runtime.js +++ b/src/mono/sample/wasm/browser/runtime.js @@ -6,7 +6,9 @@ var Module = { config: null, preInit: async function() { + Module.addRunDependency('mono-config.json'); Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); + Module.removeDependency('mono-config.json'); }, // Called when the runtime is initialized and wasm is ready diff --git a/src/mono/wasm/debugger/tests/debugger-test/runtime-debugger.js b/src/mono/wasm/debugger/tests/debugger-test/runtime-debugger.js index 360aa9b8b3036d..79c97aa4b2ef7f 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/runtime-debugger.js +++ b/src/mono/wasm/debugger/tests/debugger-test/runtime-debugger.js @@ -5,7 +5,9 @@ var Module = { config: null, preInit: async function() { + Module.addRunDependency('mono-config.json'); Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); + Module.removeDependency('mono-config.json'); }, // Called when the runtime is initialized and wasm is ready diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index 8b3395f4ec50e8..dade18b864eef4 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -211,7 +211,10 @@ var Module = { printErr, preInit: async function() { + // this forces emsdk to await and laod the file now + Module.addRunDependency('mono-config.json'); Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); + Module.removeDependency('mono-config.json'); }, onAbort: function(x) { diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/AOT/runtime.js b/src/tests/FunctionalTests/WebAssembly/Browser/AOT/runtime.js index 65cba13a9b126b..8c8c5e0477cb2c 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/AOT/runtime.js +++ b/src/tests/FunctionalTests/WebAssembly/Browser/AOT/runtime.js @@ -6,7 +6,9 @@ var Module = { config: null, preInit: async function() { + Module.addRunDependency('mono-config.json'); Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); + Module.removeDependency('mono-config.json'); }, onRuntimeInitialized: function () { diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/NormalInterp/runtime.js b/src/tests/FunctionalTests/WebAssembly/Browser/NormalInterp/runtime.js index 1a8abf503fb33f..c0ed41f3005e8d 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/NormalInterp/runtime.js +++ b/src/tests/FunctionalTests/WebAssembly/Browser/NormalInterp/runtime.js @@ -6,7 +6,9 @@ var Module = { config: null, preInit: async function() { + Module.addRunDependency('mono-config.json'); Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); + Module.removeDependency('mono-config.json'); }, onRuntimeInitialized: function () { From dc74867fd26ed659bf6f0137380ef39dc60761c3 Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Tue, 22 Jun 2021 21:33:36 -0400 Subject: [PATCH 2/5] addressed comments --- src/mono/sample/mbr/browser/runtime.js | 2 -- src/mono/sample/wasm/browser-bench/runtime.js | 2 -- .../sample/wasm/browser-profile/runtime.js | 2 -- src/mono/sample/wasm/browser/runtime.js | 2 -- .../tests/debugger-test/runtime-debugger.js | 32 +++++++++---------- src/mono/wasm/runtime/library_mono.js | 8 +++-- .../WebAssembly/Browser/AOT/runtime.js | 2 -- .../Browser/NormalInterp/runtime.js | 2 -- 8 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/mono/sample/mbr/browser/runtime.js b/src/mono/sample/mbr/browser/runtime.js index bf5153ff968bd0..32918aa573a44a 100644 --- a/src/mono/sample/mbr/browser/runtime.js +++ b/src/mono/sample/mbr/browser/runtime.js @@ -5,9 +5,7 @@ var Module = { config: null, preInit: async function() { - Module.addRunDependency('mono-config.json'); Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); - Module.removeDependency('mono-config.json'); }, // Called when the runtime is initialized and wasm is ready diff --git a/src/mono/sample/wasm/browser-bench/runtime.js b/src/mono/sample/wasm/browser-bench/runtime.js index 507447bc2111e7..60c383d13cb524 100644 --- a/src/mono/sample/wasm/browser-bench/runtime.js +++ b/src/mono/sample/wasm/browser-bench/runtime.js @@ -4,9 +4,7 @@ var Module = { config: null, preInit: async function() { - Module.addRunDependency('mono-config.json'); Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); - Module.removeDependency('mono-config.json'); }, // Called when the runtime is initialized and wasm is ready diff --git a/src/mono/sample/wasm/browser-profile/runtime.js b/src/mono/sample/wasm/browser-profile/runtime.js index ecd7b0f9d20a00..2c83ff54ef93d0 100644 --- a/src/mono/sample/wasm/browser-profile/runtime.js +++ b/src/mono/sample/wasm/browser-profile/runtime.js @@ -5,9 +5,7 @@ var Module = { config: null, preInit: async function() { - Module.addRunDependency('mono-config.json'); Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); - Module.removeDependency('mono-config.json'); }, // Called when the runtime is initialized and wasm is ready diff --git a/src/mono/sample/wasm/browser/runtime.js b/src/mono/sample/wasm/browser/runtime.js index ee78b18efa345a..e97feef745a95d 100644 --- a/src/mono/sample/wasm/browser/runtime.js +++ b/src/mono/sample/wasm/browser/runtime.js @@ -6,9 +6,7 @@ var Module = { config: null, preInit: async function() { - Module.addRunDependency('mono-config.json'); Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); - Module.removeDependency('mono-config.json'); }, // Called when the runtime is initialized and wasm is ready diff --git a/src/mono/wasm/debugger/tests/debugger-test/runtime-debugger.js b/src/mono/wasm/debugger/tests/debugger-test/runtime-debugger.js index 79c97aa4b2ef7f..0d565842056d8b 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/runtime-debugger.js +++ b/src/mono/wasm/debugger/tests/debugger-test/runtime-debugger.js @@ -5,30 +5,28 @@ var Module = { config: null, preInit: async function() { - Module.addRunDependency('mono-config.json'); Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); - Module.removeDependency('mono-config.json'); }, // Called when the runtime is initialized and wasm is ready onRuntimeInitialized: function () { - if (!Module.config || Module.config.error) { + if (!Module.config || Module.config.error) { console.log("An error occured while loading the config file"); return; } - Module.config.loaded_cb = function () { - App.init (); - }; - // For custom logging patch the functions below - /* - MONO.logging = { - trace: function (domain, log_level, message, isFatal, dataPtr) {}, - debugger: function (level, message) {} - }; - MONO.mono_wasm_setenv ("MONO_LOG_LEVEL", "debug"); - MONO.mono_wasm_setenv ("MONO_LOG_MASK", "all"); - */ - MONO.mono_load_runtime_and_bcl_args (Module.config) - }, + Module.config.loaded_cb = function () { + App.init (); + }; + // For custom logging patch the functions below + /* + MONO.logging = { + trace: function (domain, log_level, message, isFatal, dataPtr) {}, + debugger: function (level, message) {} + }; + MONO.mono_wasm_setenv ("MONO_LOG_LEVEL", "debug"); + MONO.mono_wasm_setenv ("MONO_LOG_MASK", "all"); + */ + MONO.mono_load_runtime_and_bcl_args (Module.config) + }, }; diff --git a/src/mono/wasm/runtime/library_mono.js b/src/mono/wasm/runtime/library_mono.js index 36837f62cf7096..18cd55a385f65c 100644 --- a/src/mono/wasm/runtime/library_mono.js +++ b/src/mono/wasm/runtime/library_mono.js @@ -2365,12 +2365,14 @@ var MonoSupportLib = { }, /** - * Loads the mono config file (typically called mono-config.json) + * Loads the mono config file (typically called mono-config.json) asynchroniously + * Note: the run dependencies are so emsdk actually awaits it in order. * * @param {string} configFilePath - relative path to the config file * @throws Will throw an error if the config file loading fails */ - mono_wasm_load_config: async function (configFilePath) { + mono_wasm_load_config: async function (configFilePath) { + Module.addRunDependency('mono-config.json'); try { let config = null; // NOTE: when we add nodejs make sure to include the nodejs fetch package @@ -2382,8 +2384,10 @@ var MonoSupportLib = { } else { // shell or worker config = JSON.parse(read(configFilePath)); // read is a v8 debugger command } + Module.removeDependency('mono-config.json'); return config; } catch(e) { + Module.removeDependency('mono-config.json'); return {message: "failed to load config file", error: e}; } } diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/AOT/runtime.js b/src/tests/FunctionalTests/WebAssembly/Browser/AOT/runtime.js index 8c8c5e0477cb2c..65cba13a9b126b 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/AOT/runtime.js +++ b/src/tests/FunctionalTests/WebAssembly/Browser/AOT/runtime.js @@ -6,9 +6,7 @@ var Module = { config: null, preInit: async function() { - Module.addRunDependency('mono-config.json'); Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); - Module.removeDependency('mono-config.json'); }, onRuntimeInitialized: function () { diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/NormalInterp/runtime.js b/src/tests/FunctionalTests/WebAssembly/Browser/NormalInterp/runtime.js index c0ed41f3005e8d..1a8abf503fb33f 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/NormalInterp/runtime.js +++ b/src/tests/FunctionalTests/WebAssembly/Browser/NormalInterp/runtime.js @@ -6,9 +6,7 @@ var Module = { config: null, preInit: async function() { - Module.addRunDependency('mono-config.json'); Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); - Module.removeDependency('mono-config.json'); }, onRuntimeInitialized: function () { From 8ac6755c3dc554de4461ae435296baf29c46a72e Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Tue, 22 Jun 2021 21:52:39 -0400 Subject: [PATCH 3/5] cleanup --- src/mono/wasm/runtime-test.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index dade18b864eef4..8b3395f4ec50e8 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -211,10 +211,7 @@ var Module = { printErr, preInit: async function() { - // this forces emsdk to await and laod the file now - Module.addRunDependency('mono-config.json'); Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); - Module.removeDependency('mono-config.json'); }, onAbort: function(x) { From 5a780c8a03159dfb8f236a68f368033255eb9049 Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Tue, 22 Jun 2021 21:59:07 -0400 Subject: [PATCH 4/5] cleanup accidental spaces and tabs cleanup --- .../tests/debugger-test/runtime-debugger.js | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/mono/wasm/debugger/tests/debugger-test/runtime-debugger.js b/src/mono/wasm/debugger/tests/debugger-test/runtime-debugger.js index 0d565842056d8b..360aa9b8b3036d 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/runtime-debugger.js +++ b/src/mono/wasm/debugger/tests/debugger-test/runtime-debugger.js @@ -10,23 +10,23 @@ var Module = { // Called when the runtime is initialized and wasm is ready onRuntimeInitialized: function () { - if (!Module.config || Module.config.error) { + if (!Module.config || Module.config.error) { console.log("An error occured while loading the config file"); return; } - Module.config.loaded_cb = function () { - App.init (); - }; - // For custom logging patch the functions below - /* - MONO.logging = { - trace: function (domain, log_level, message, isFatal, dataPtr) {}, - debugger: function (level, message) {} - }; - MONO.mono_wasm_setenv ("MONO_LOG_LEVEL", "debug"); - MONO.mono_wasm_setenv ("MONO_LOG_MASK", "all"); - */ - MONO.mono_load_runtime_and_bcl_args (Module.config) - }, + Module.config.loaded_cb = function () { + App.init (); + }; + // For custom logging patch the functions below + /* + MONO.logging = { + trace: function (domain, log_level, message, isFatal, dataPtr) {}, + debugger: function (level, message) {} + }; + MONO.mono_wasm_setenv ("MONO_LOG_LEVEL", "debug"); + MONO.mono_wasm_setenv ("MONO_LOG_MASK", "all"); + */ + MONO.mono_load_runtime_and_bcl_args (Module.config) + }, }; From a544d63437885619b99154503b24ef9d9c7f165d Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Tue, 22 Jun 2021 22:05:30 -0400 Subject: [PATCH 5/5] added Larry's comments --- src/mono/wasm/runtime/library_mono.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mono/wasm/runtime/library_mono.js b/src/mono/wasm/runtime/library_mono.js index 18cd55a385f65c..e9cb8cd2b401d2 100644 --- a/src/mono/wasm/runtime/library_mono.js +++ b/src/mono/wasm/runtime/library_mono.js @@ -2372,7 +2372,7 @@ var MonoSupportLib = { * @throws Will throw an error if the config file loading fails */ mono_wasm_load_config: async function (configFilePath) { - Module.addRunDependency('mono-config.json'); + Module.addRunDependency(configFilePath); try { let config = null; // NOTE: when we add nodejs make sure to include the nodejs fetch package @@ -2384,11 +2384,11 @@ var MonoSupportLib = { } else { // shell or worker config = JSON.parse(read(configFilePath)); // read is a v8 debugger command } - Module.removeDependency('mono-config.json'); return config; } catch(e) { - Module.removeDependency('mono-config.json'); return {message: "failed to load config file", error: e}; + } finally { + Module.removeRunDependency(configFilePath); } } },