Skip to content

Commit 3af30c9

Browse files
committed
fix MT
1 parent 4c82546 commit 3af30c9

4 files changed

Lines changed: 5 additions & 7 deletions

File tree

src/mono/browser/runtime/loader/run.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,10 @@ async function createEmscriptenWorker (): Promise<EmscriptenModuleInternal> {
466466

467467
await mono_download_assets();
468468

469+
const CMD_LOAD = 1; // emscripten/src/lib/libpthread.js CMD_LOAD
469470
self.dispatchEvent(new MessageEvent("message", {
470471
data: {
471-
cmd: "load",
472+
cmd: CMD_LOAD,
472473
handlers: emscriptenModule.handlers,
473474
wasmMemory: emscriptenModule.wasmMemory,
474475
wasmModule: emscriptenModule.wasmModule

src/mono/browser/runtime/pthreads/ui-thread.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ function getNewWorker (modulePThread: PThreadLibrary): PThreadWorker {
274274
if (!WasmEnableThreads) return null as any;
275275

276276
if (modulePThread.unusedWorkers.length == 0) {
277-
mono_log_debug(() => `Failed to find unused WebWorker, this may deadlock. Please increase the pthreadPoolInitialSize. Running threads ${modulePThread.runningWorkers.length}. Loading workers: ${modulePThread.unusedWorkers.length}`);
277+
mono_log_debug(() => `Failed to find unused WebWorker, this may deadlock. Please increase the pthreadPoolInitialSize. Running threads ${Object.keys(modulePThread.pthreads).length}. Loading workers: ${modulePThread.unusedWorkers.length}`);
278278
const worker = allocateUnusedWorker();
279279
modulePThread.loadWasmModuleToWorker(worker);
280280
return worker;
@@ -293,7 +293,7 @@ function getNewWorker (modulePThread: PThreadLibrary): PThreadWorker {
293293
return worker;
294294
}
295295
}
296-
mono_log_debug(() => `Failed to find loaded WebWorker, this may deadlock. Please increase the pthreadPoolInitialSize. Running threads ${modulePThread.runningWorkers.length}. Loading workers: ${modulePThread.unusedWorkers.length}`);
296+
mono_log_debug(() => `Failed to find loaded WebWorker, this may deadlock. Please increase the pthreadPoolInitialSize. Running threads ${Object.keys(modulePThread.pthreads).length}. Loading workers: ${modulePThread.unusedWorkers.length}`);
297297
return modulePThread.unusedWorkers.pop()!;
298298
}
299299

@@ -333,7 +333,7 @@ export function getUnusedWorkerPool (): PThreadWorker[] {
333333
}
334334

335335
export function getRunningWorkers (): PThreadWorker[] {
336-
return getModulePThread().runningWorkers;
336+
return Object.values(getModulePThread().pthreads);
337337
}
338338

339339
export function terminateAllThreads (): void {

src/mono/browser/runtime/startup.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ export function configureEmscriptenStartup (module: DotnetModuleInternal): void
8585
if (runtimeHelpers.emscriptenBuildOptions.wasmEnableEH) {
8686
mono_assert(runtimeHelpers.featureWasmFinalEh, "This browser/engine doesn't support WASM exception handling. Please use a modern version. See also https://learn.microsoft.com/aspnet/core/blazor/supported-platforms");
8787
}
88-
module.mainScriptUrlOrBlob = loaderHelpers.scriptUrl;// this is needed by worker threads
8988

9089
// these all could be overridden on DotnetModuleConfig, we are chaining them to async below, as opposed to emscripten
9190
// when the user sets config, we are running our default startup sequence.

src/mono/browser/runtime/types/internal.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,6 @@ export declare interface EmscriptenModuleInternal {
433433

434434
__locateFile?: (path: string, prefix?: string) => string;
435435
locateFile?: (path: string, prefix?: string) => string;
436-
mainScriptUrlOrBlob?: string;
437436
ENVIRONMENT_IS_PTHREAD?: boolean;
438437
FS: any;
439438
wasmModule: WebAssembly.Module | null;
@@ -572,7 +571,6 @@ export interface PThreadInfo {
572571

573572
export interface PThreadLibrary {
574573
unusedWorkers: PThreadWorker[];
575-
runningWorkers: PThreadWorker[];
576574
pthreads: PThreadInfoMap;
577575
allocateUnusedWorker: () => void;
578576
loadWasmModuleToWorker: (worker: PThreadWorker) => Promise<PThreadWorker>;

0 commit comments

Comments
 (0)