Skip to content

Commit

Permalink
[release/8.0] [browser] ENVIRONMENT_IS_WEB is also true on WebWorker (#…
Browse files Browse the repository at this point in the history
…91627)

* ENVIRONMENT_IS_WEB is now also true on WebWorker

* noExitRuntime stay false on pthread

---------

Co-authored-by: pavelsavara <pavel.savara@gmail.com>
  • Loading branch information
github-actions[bot] and pavelsavara authored Sep 15, 2023
1 parent d8a419a commit 28e72d2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/mono/wasm/runtime/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export let Module: DotnetModuleInternal;
export let INTERNAL: any;

export const ENVIRONMENT_IS_NODE = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string";
export const ENVIRONMENT_IS_WEB = typeof window == "object";
export const ENVIRONMENT_IS_WORKER = typeof importScripts == "function";
export const ENVIRONMENT_IS_WEB = typeof window == "object" || (ENVIRONMENT_IS_WORKER && !ENVIRONMENT_IS_NODE);
export const ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
// these are imported and re-exported from emscripten internals
export let ENVIRONMENT_IS_PTHREAD: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/runtime/loader/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import { hasDebuggingEnabled } from "./config";
import { logDownloadStatsToConsole, purgeUnusedCacheEntriesAsync } from "./assetsCache";

export const ENVIRONMENT_IS_NODE = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string";
export const ENVIRONMENT_IS_WEB = typeof window == "object";
export const ENVIRONMENT_IS_WORKER = typeof importScripts == "function";
export const ENVIRONMENT_IS_WEB = typeof window == "object" || (ENVIRONMENT_IS_WORKER && !ENVIRONMENT_IS_NODE);
export const ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;

export let runtimeHelpers: RuntimeHelpers = {} as any;
Expand Down
4 changes: 2 additions & 2 deletions src/mono/wasm/runtime/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import MonoWasmThreads from "consts:monoWasmThreads";
import type { EmscriptenReplacements } from "./types/internal";
import type { TypedArray } from "./types/emscripten";
import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_WEB, INTERNAL, Module, loaderHelpers, runtimeHelpers } from "./globals";
import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_PTHREAD, ENVIRONMENT_IS_WEB, INTERNAL, Module, loaderHelpers, runtimeHelpers } from "./globals";
import { replaceEmscriptenPThreadLibrary } from "./pthreads/shared/emscripten-replacements";

const dummyPerformance = {
Expand All @@ -30,7 +30,7 @@ export function initializeReplacements(replacements: EmscriptenReplacements): vo
replacements.fetch = loaderHelpers.fetch_like;

// misc
replacements.noExitRuntime = ENVIRONMENT_IS_WEB;
replacements.noExitRuntime = ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_PTHREAD;

// threads
if (MonoWasmThreads) {
Expand Down

0 comments on commit 28e72d2

Please sign in to comment.