Skip to content

Commit 556e4b1

Browse files
committed
more
1 parent 1ee7118 commit 556e4b1

File tree

7 files changed

+26
-8
lines changed

7 files changed

+26
-8
lines changed

src/mono/browser/runtime/.eslintrc.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ module.exports = {
6060
"object-curly-spacing": ["error", "always"],
6161
"array-bracket-spacing": ["error"],
6262
"space-infix-ops": ["error"],
63+
"func-call-spacing": ["error", "never"],
6364
"space-before-function-paren": ["error", "always"],
6465
}
6566
};

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

+6
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,17 @@ function unregisterEmscriptenExitHandlers () {
5858
}
5959
}
6060
function onExit (code: number) {
61+
// eslint-disable-next-line no-console
62+
console.warn("onExit A " + JSON.stringify({ code, monoThreadInfo:runtimeHelpers.monoThreadInfo, stack:"" + new Error().stack, }) ); // TODO PAVEL, remove before merge
6163
if (originalOnExit) {
6264
originalOnExit(code);
6365
}
6466
mono_exit(code, loaderHelpers.exitReason);
6567
}
6668

6769
function onAbort (reason: any) {
70+
// eslint-disable-next-line no-console
71+
console.warn("onAbort A " + JSON.stringify({ reason, message:reason.message, monoThreadInfo:runtimeHelpers.monoThreadInfo, stack:"" + new Error().stack, }) ); // TODO PAVEL, remove before merge
6872
if (originalOnAbort) {
6973
originalOnAbort(reason || loaderHelpers.exitReason);
7074
}
@@ -303,6 +307,8 @@ function error_handler (event: any) {
303307
}
304308

305309
function fatal_handler (event: any, reason: any, type: string) {
310+
// eslint-disable-next-line no-console
311+
console.warn("fatal_handler A " + JSON.stringify({ reason, monoThreadInfo:runtimeHelpers.monoThreadInfo, stack:"" + new Error().stack, }) ); // TODO PAVEL, remove before merge
306312
event.preventDefault();
307313
try {
308314
if (!reason) {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ export function teardown_proxy_console (message?: string) {
118118
console.warn("teardown_proxy_console A "); // TODO PAVEL, remove before merge
119119
let counter = 30;
120120
const stop_when_ws_buffer_empty = () => {
121-
console.warn("teardown_proxy_console B " + counter + " buf:" + consoleWebSocket?.bufferedAmount); // TODO PAVEL, remove before merge
122121
if (!consoleWebSocket) {
122+
console.warn("teardown_proxy_console B "); // TODO PAVEL, remove before merge
123123
if (message && originalConsoleMethods) {
124124
originalConsoleMethods.log(message);
125125
}

src/mono/browser/runtime/logging.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
/* eslint-disable no-console */
5-
import { INTERNAL, runtimeHelpers, mono_assert, loaderHelpers } from "./globals";
5+
import { threads_c_functions as tcwraps } from "./cwraps";
6+
import { INTERNAL, runtimeHelpers, mono_assert, loaderHelpers, ENVIRONMENT_IS_WORKER } from "./globals";
67
import { utf8ToString } from "./strings";
78
import { CharPtr, VoidPtr } from "./types/emscripten";
89

@@ -135,6 +136,19 @@ export function mono_wasm_trace_logger (log_domain_ptr: CharPtr, log_level_ptr:
135136
loaderHelpers.exitReason = messageWithStack;
136137
}
137138
console.error(mono_wasm_stringify_as_error_with_stack(messageWithStack));
139+
try {
140+
if (tcwraps && tcwraps.mono_wasm_print_thread_dump) {
141+
tcwraps.mono_wasm_print_thread_dump();
142+
}
143+
} catch (e) {
144+
console.error("Failed to print thread dump", e);
145+
}
146+
if (ENVIRONMENT_IS_WORKER) {
147+
setTimeout(() => {
148+
console.error("PAVEL aborting 1000ms later");
149+
loaderHelpers.mono_exit(1, messageWithStack);
150+
}, 1000);
151+
}
138152
}
139153
break;
140154
case "warning":

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
import WasmEnableThreads from "consts:wasmEnableThreads";
5-
import BuildConfiguration from "consts:configuration";
65

76
import { mono_log_error, mono_log_info } from "../logging";
87
import { monoThreadInfo, postMessageToMain, update_thread_info } from "./shared";
@@ -14,7 +13,7 @@ import { forceThreadMemoryViewRefresh } from "../memory";
1413
export function mono_wasm_start_deputy_thread_async () {
1514
if (!WasmEnableThreads) return;
1615

17-
if (BuildConfiguration === "Debug" && globalThis.setInterval) globalThis.setInterval(() => {
16+
if (globalThis.setInterval) globalThis.setInterval(() => {
1817
mono_log_info("Deputy thread is alive!");
1918
}, 3000);
2019

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
import WasmEnableThreads from "consts:wasmEnableThreads";
5-
import BuildConfiguration from "consts:configuration";
65

76
import { mono_log_error, mono_log_info } from "../logging";
87
import { monoThreadInfo, postMessageToMain, update_thread_info } from "./shared";
@@ -14,7 +13,7 @@ export function mono_wasm_start_io_thread_async () {
1413
if (!WasmEnableThreads) return;
1514

1615

17-
if (BuildConfiguration === "Debug" && globalThis.setInterval) globalThis.setInterval(() => {
16+
if (globalThis.setInterval) globalThis.setInterval(() => {
1817
mono_log_info("I/O thread is alive!");
1918
}, 3000);
2019

src/mono/browser/runtime/startup.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
import WasmEnableThreads from "consts:wasmEnableThreads";
5-
import BuildConfiguration from "consts:configuration";
65

76
import { DotnetModuleInternal, CharPtrNull } from "./types/internal";
87
import { exportedRuntimeAPI, INTERNAL, loaderHelpers, Module, runtimeHelpers, createPromiseController, mono_assert } from "./globals";
@@ -272,7 +271,7 @@ async function onRuntimeInitializedAsync (userOnRuntimeInitialized: () => void)
272271

273272

274273
Module.runtimeKeepalivePush();
275-
if (WasmEnableThreads && BuildConfiguration === "Debug" && globalThis.setInterval) globalThis.setInterval(() => {
274+
if (WasmEnableThreads && globalThis.setInterval) globalThis.setInterval(() => {
276275
mono_log_info("UI thread is alive!");
277276
}, 3000);
278277

0 commit comments

Comments
 (0)