From e7387aad9da9a1785908768d7fa971252b2ca65c Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 25 Nov 2024 16:53:40 +0100 Subject: [PATCH] testing --- src/mono/browser/runtime/pthreads/deputy-thread.ts | 3 +++ src/mono/browser/runtime/pthreads/ui-thread.ts | 2 ++ src/mono/browser/runtime/startup.ts | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mono/browser/runtime/pthreads/deputy-thread.ts b/src/mono/browser/runtime/pthreads/deputy-thread.ts index 1e2041fa44daee..63c60eedf3f258 100644 --- a/src/mono/browser/runtime/pthreads/deputy-thread.ts +++ b/src/mono/browser/runtime/pthreads/deputy-thread.ts @@ -35,6 +35,7 @@ export function mono_wasm_start_deputy_thread_async () { pthread_self.addEventListenerFromBrowser((message) => { if (message.data.cmd == MainToWorkerMessageType.allAssetsLoaded) { + forceThreadMemoryViewRefresh(); runtimeHelpers.allAssetsInMemory.promise_control.resolve(); } }); @@ -50,6 +51,8 @@ export function mono_wasm_start_deputy_thread_async () { runtimeHelpers.proxyGCHandle = install_main_synchronization_context(runtimeHelpers.config.jsThreadBlockingMode!); + forceThreadMemoryViewRefresh(); + postMessageToMain({ monoCmd: WorkerToMainMessageType.deputyReady, info: monoThreadInfo, diff --git a/src/mono/browser/runtime/pthreads/ui-thread.ts b/src/mono/browser/runtime/pthreads/ui-thread.ts index 92874587cee226..1117d85b3bbc10 100644 --- a/src/mono/browser/runtime/pthreads/ui-thread.ts +++ b/src/mono/browser/runtime/pthreads/ui-thread.ts @@ -9,6 +9,7 @@ import { MonoWorkerToMainMessage, monoThreadInfo, mono_wasm_pthread_ptr, update_ import { Module, ENVIRONMENT_IS_WORKER, createPromiseController, loaderHelpers, mono_assert, runtimeHelpers } from "../globals"; import { PThreadLibrary, MainToWorkerMessageType, MonoThreadMessage, PThreadInfo, PThreadPtr, PThreadPtrNull, PThreadWorker, PromiseController, Thread, WorkerToMainMessageType, monoMessageSymbol } from "../types/internal"; import { mono_log_info, mono_log_debug, mono_log_warn } from "../logging"; +import { forceThreadMemoryViewRefresh } from "../memory"; const threadPromises: Map[]> = new Map(); @@ -100,6 +101,7 @@ function monoWorkerMessageHandler (worker: PThreadWorker, ev: MessageEvent) runtimeHelpers.afterMonoStarted.promise_control.resolve(); break; case WorkerToMainMessageType.deputyReady: + forceThreadMemoryViewRefresh(); runtimeHelpers.afterDeputyReady.promise_control.resolve(message.deputyProxyGCHandle); break; case WorkerToMainMessageType.ioStarted: diff --git a/src/mono/browser/runtime/startup.ts b/src/mono/browser/runtime/startup.ts index 8b37d90e281810..92f05ea3b4cfa2 100644 --- a/src/mono/browser/runtime/startup.ts +++ b/src/mono/browser/runtime/startup.ts @@ -28,7 +28,7 @@ import { populateEmscriptenPool, mono_wasm_init_threads } from "./pthreads"; import { currentWorkerThreadEvents, dotnetPthreadCreated, initWorkerThreadEvents, monoThreadInfo } from "./pthreads"; import { mono_wasm_pthread_ptr, update_thread_info } from "./pthreads"; import { jiterpreter_allocate_tables } from "./jiterpreter-support"; -import { localHeapViewU8, malloc } from "./memory"; +import { forceThreadMemoryViewRefresh, localHeapViewU8, malloc } from "./memory"; import { assertNoProxies } from "./gc-handles"; import { runtimeList } from "./exports"; import { nativeAbort, nativeExit } from "./run"; @@ -322,6 +322,7 @@ async function onRuntimeInitializedAsync (userOnRuntimeInitialized: (module:Emsc await wait_for_all_assets(); if (WasmEnableThreads) { + forceThreadMemoryViewRefresh(); runtimeHelpers.deputyWorker.thread!.postMessageToWorker({ type:"deputyThread", cmd: MainToWorkerMessageType.allAssetsLoaded,