diff --git a/docs/workflow/building/coreclr/wasm.md b/docs/workflow/building/coreclr/wasm.md index b2de062d88b066..99dd2911483441 100644 --- a/docs/workflow/building/coreclr/wasm.md +++ b/docs/workflow/building/coreclr/wasm.md @@ -146,7 +146,8 @@ In config below please replace `/path/to/runtime/` by a **absolute unix path** t "/**" ], "runtimeArgs": [ - "--stack-trace-limit=1000" + "--stack-trace-limit=10000", + "--experimental-wasm-exnref" ], "args": [ "HelloWorld.dll" diff --git a/eng/native.wasm.targets b/eng/native.wasm.targets index 5c1238f58dc590..42f9c581114313 100644 --- a/eng/native.wasm.targets +++ b/eng/native.wasm.targets @@ -55,6 +55,17 @@ + + + + + + + + + + + diff --git a/eng/testing/BrowserVersions.props b/eng/testing/BrowserVersions.props index 31f40bbf8ba605..45640424f61f2e 100644 --- a/eng/testing/BrowserVersions.props +++ b/eng/testing/BrowserVersions.props @@ -12,9 +12,9 @@ 1625079 https://storage.googleapis.com/chromium-browser-snapshots/Win_x64/1625123 14.9.207 - 125.0.1 - 0.34.0 - 125.0.1 - 0.34.0 + 140.11.0esr + 0.37.0 + 140.11.0esr + 0.37.0 \ No newline at end of file diff --git a/eng/testing/wasm-provisioning.targets b/eng/testing/wasm-provisioning.targets index 20e1e00ddef184..b2cb4f1b1a92d9 100644 --- a/eng/testing/wasm-provisioning.targets +++ b/eng/testing/wasm-provisioning.targets @@ -28,7 +28,7 @@ $(ArtifactsBinDir)geckodriver\ - https://ftp.mozilla.org/pub/firefox/releases/$(linux_FirefoxRevision)/linux-x86_64/en-US/firefox-$(linux_FirefoxRevision).tar.bz2 + https://ftp.mozilla.org/pub/firefox/releases/$(linux_FirefoxRevision)/linux-x86_64/en-US/firefox-$(linux_FirefoxRevision).tar.xz https://github.com/mozilla/geckodriver/releases/download/v$(linux_GeckoDriverRevision)/geckodriver-v$(linux_GeckoDriverRevision)-linux64.tar.gz firefox geckodriver diff --git a/src/coreclr/hosts/corerun/CMakeLists.txt b/src/coreclr/hosts/corerun/CMakeLists.txt index 8a7b70e7a915ac..3052680a13e7dc 100644 --- a/src/coreclr/hosts/corerun/CMakeLists.txt +++ b/src/coreclr/hosts/corerun/CMakeLists.txt @@ -79,6 +79,24 @@ else() LINK_DEPENDS "${JS_CORE_RUN};${JS_CORE_RUN_EXTPOST};${JS_SYSTEM_NATIVE_BROWSER};${JS_SYSTEM_BROWSER_UTILS};" LINK_FLAGS "--js-library ${JS_SYSTEM_NATIVE_BROWSER} --js-library ${JS_SYSTEM_BROWSER_UTILS} --js-library ${JS_CORE_RUN} --extern-post-js ${JS_CORE_RUN_EXTPOST}" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + if (CORERUN_IN_BROWSER) + target_link_options(corerun PRIVATE -sWASM_BIGINT=1) + # Include the virtual file system data for the browser scenario. + set(WASM_PRELOAD_DIR "${CMAKE_INSTALL_PREFIX}/IL") + if (EXISTS "${WASM_PRELOAD_DIR}") + target_link_options(corerun PRIVATE --preload-file ${WASM_PRELOAD_DIR}@/) + endif() + else() + # Node.js doesn't have good support for WASM_BIGINT, so disable it for the Node/shell. + target_link_options(corerun PRIVATE -sWASM_BIGINT=0) + + # remove HEAP64 and HEAPU64 from CMAKE_EMCC_EXPORTED_RUNTIME_METHODS + string(REPLACE "HEAP64," "" CMAKE_EMCC_EXPORTED_RUNTIME_METHODS "${CMAKE_EMCC_EXPORTED_RUNTIME_METHODS}") + string(REPLACE "HEAPU64," "" CMAKE_EMCC_EXPORTED_RUNTIME_METHODS "${CMAKE_EMCC_EXPORTED_RUNTIME_METHODS}") + + # Add Node.js host file system support. + target_link_options(corerun PRIVATE -sNODERAWFS=1 -lnodefs.js) + endif() target_link_options(corerun PRIVATE -sINITIAL_MEMORY=134217728 -sMAXIMUM_MEMORY=4294967296 @@ -96,27 +114,6 @@ else() -Wl,--export=__stack_pointer -Wl,--export=__coreclr_wasm_rtlrestorecontext_tag -Wl,--error-limit=0) - - if (CORERUN_IN_BROWSER) - # Node.js doesn't have good support for WASM_BIGINT - # so it only is added when running in the browser. - target_link_options(corerun PRIVATE - -sWASM_BIGINT=1) - - # Include the virtual file system data for the - # browser scenario. - set(WASM_PRELOAD_DIR "${CMAKE_INSTALL_PREFIX}/IL") - if (EXISTS "${WASM_PRELOAD_DIR}") - target_link_options(corerun PRIVATE - --preload-file ${WASM_PRELOAD_DIR}@/) - endif() - else() - # If not running in the browser, add - # Node.js file system support. - target_link_options(corerun PRIVATE - -sNODERAWFS=1 - -lnodefs.js) - endif() endif() if (CORERUN_IN_BROWSER) diff --git a/src/mono/browser/runtime/diagnostics/dotnet-gcdump.ts b/src/mono/browser/runtime/diagnostics/dotnet-gcdump.ts index d0d503db4d5ceb..d11c2834828368 100644 --- a/src/mono/browser/runtime/diagnostics/dotnet-gcdump.ts +++ b/src/mono/browser/runtime/diagnostics/dotnet-gcdump.ts @@ -23,6 +23,7 @@ export function collectGcDump (options?:DiagnosticCommandOptions):Promise { stopSent = true; diff --git a/src/mono/browser/runtime/loader/exit.ts b/src/mono/browser/runtime/loader/exit.ts index b57d06b993cc48..bfddfbf3f29097 100644 --- a/src/mono/browser/runtime/loader/exit.ts +++ b/src/mono/browser/runtime/loader/exit.ts @@ -204,6 +204,7 @@ function set_exit_code_and_quit_now (exit_code: number, reason?: any): void { } async function flush_node_streams () { + if (!ENVIRONMENT_IS_NODE) return; try { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore: diff --git a/src/mono/browser/runtime/scheduling.ts b/src/mono/browser/runtime/scheduling.ts index 93dde2a5525281..1a374630d3d18e 100644 --- a/src/mono/browser/runtime/scheduling.ts +++ b/src/mono/browser/runtime/scheduling.ts @@ -70,18 +70,19 @@ export function SystemJS_ScheduleTimerImpl (shortestDueTimeMs: number): void { if (lastScheduledTimeoutId) { globalThis.clearTimeout(lastScheduledTimeoutId); lastScheduledTimeoutId = undefined; + Module.runtimeKeepalivePop(); } lastScheduledTimeoutId = Module.safeSetTimeout(mono_wasm_schedule_timer_tick, shortestDueTimeMs); } function mono_wasm_schedule_timer_tick () { if (WasmEnableThreads) return; + lastScheduledTimeoutId = undefined; Module.maybeExit(); forceThreadMemoryViewRefresh(); if (!loaderHelpers.is_runtime_running()) { return; } - lastScheduledTimeoutId = undefined; try { cwraps.mono_wasm_execute_timer(); } catch (ex) { diff --git a/src/mono/browser/runtime/startup.ts b/src/mono/browser/runtime/startup.ts index c086c6b7c4bb6e..25093725766169 100644 --- a/src/mono/browser/runtime/startup.ts +++ b/src/mono/browser/runtime/startup.ts @@ -197,6 +197,7 @@ async function preRunAsync (userPreRun: ((module:EmscriptenModule) => void)[]) { } async function onRuntimeInitializedAsync (userOnRuntimeInitialized: (module:EmscriptenModule) => void) { + let keepAlivePushed = false; try { // wait for previous stage await runtimeHelpers.afterPreRun.promise; @@ -227,7 +228,10 @@ async function onRuntimeInitializedAsync (userOnRuntimeInitialized: (module:Emsc setTimeout(maybeSaveInterpPgoTable, (runtimeHelpers.config.interpreterPgoSaveDelay || 15) * 1000); + // this push is unbalanced for short while until runtimeReady = true. Accepted trade-off. Module.runtimeKeepalivePush(); + keepAlivePushed = true; + if (WasmEnableThreads && BuildConfiguration === "Debug" && globalThis.setInterval) globalThis.setInterval(() => { mono_log_info("UI thread is alive!"); }, 3000); @@ -291,7 +295,7 @@ async function onRuntimeInitializedAsync (userOnRuntimeInitialized: (module:Emsc await mono_wasm_after_user_runtime_initialized(); endMeasure(mark, MeasuredBlock.onRuntimeInitialized); } catch (err) { - Module.runtimeKeepalivePop(); + if (keepAlivePushed && !runtimeHelpers.runtimeReady) Module.runtimeKeepalivePop(); mono_log_error("onRuntimeInitializedAsync() failed", err); loaderHelpers.mono_exit(1, err); throw err;