Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelsavara committed Apr 5, 2024
1 parent 1ee7118 commit 556e4b1
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/mono/browser/runtime/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ module.exports = {
"object-curly-spacing": ["error", "always"],
"array-bracket-spacing": ["error"],
"space-infix-ops": ["error"],
"func-call-spacing": ["error", "never"],
"space-before-function-paren": ["error", "always"],
}
};
6 changes: 6 additions & 0 deletions src/mono/browser/runtime/loader/exit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,17 @@ function unregisterEmscriptenExitHandlers () {
}
}
function onExit (code: number) {
// eslint-disable-next-line no-console
console.warn("onExit A " + JSON.stringify({ code, monoThreadInfo:runtimeHelpers.monoThreadInfo, stack:"" + new Error().stack, }) ); // TODO PAVEL, remove before merge
if (originalOnExit) {
originalOnExit(code);
}
mono_exit(code, loaderHelpers.exitReason);
}

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

function fatal_handler (event: any, reason: any, type: string) {
// eslint-disable-next-line no-console
console.warn("fatal_handler A " + JSON.stringify({ reason, monoThreadInfo:runtimeHelpers.monoThreadInfo, stack:"" + new Error().stack, }) ); // TODO PAVEL, remove before merge
event.preventDefault();
try {
if (!reason) {
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/loader/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ export function teardown_proxy_console (message?: string) {
console.warn("teardown_proxy_console A "); // TODO PAVEL, remove before merge
let counter = 30;
const stop_when_ws_buffer_empty = () => {
console.warn("teardown_proxy_console B " + counter + " buf:" + consoleWebSocket?.bufferedAmount); // TODO PAVEL, remove before merge
if (!consoleWebSocket) {
console.warn("teardown_proxy_console B "); // TODO PAVEL, remove before merge
if (message && originalConsoleMethods) {
originalConsoleMethods.log(message);
}
Expand Down
16 changes: 15 additions & 1 deletion src/mono/browser/runtime/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.

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

Expand Down Expand Up @@ -135,6 +136,19 @@ export function mono_wasm_trace_logger (log_domain_ptr: CharPtr, log_level_ptr:
loaderHelpers.exitReason = messageWithStack;
}
console.error(mono_wasm_stringify_as_error_with_stack(messageWithStack));
try {
if (tcwraps && tcwraps.mono_wasm_print_thread_dump) {
tcwraps.mono_wasm_print_thread_dump();
}
} catch (e) {
console.error("Failed to print thread dump", e);
}
if (ENVIRONMENT_IS_WORKER) {
setTimeout(() => {
console.error("PAVEL aborting 1000ms later");
loaderHelpers.mono_exit(1, messageWithStack);
}, 1000);
}
}
break;
case "warning":
Expand Down
3 changes: 1 addition & 2 deletions src/mono/browser/runtime/pthreads/deputy-thread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.

import WasmEnableThreads from "consts:wasmEnableThreads";
import BuildConfiguration from "consts:configuration";

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

if (BuildConfiguration === "Debug" && globalThis.setInterval) globalThis.setInterval(() => {
if (globalThis.setInterval) globalThis.setInterval(() => {
mono_log_info("Deputy thread is alive!");
}, 3000);

Expand Down
3 changes: 1 addition & 2 deletions src/mono/browser/runtime/pthreads/io-thread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.

import WasmEnableThreads from "consts:wasmEnableThreads";
import BuildConfiguration from "consts:configuration";

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


if (BuildConfiguration === "Debug" && globalThis.setInterval) globalThis.setInterval(() => {
if (globalThis.setInterval) globalThis.setInterval(() => {
mono_log_info("I/O thread is alive!");
}, 3000);

Expand Down
3 changes: 1 addition & 2 deletions src/mono/browser/runtime/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.

import WasmEnableThreads from "consts:wasmEnableThreads";
import BuildConfiguration from "consts:configuration";

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


Module.runtimeKeepalivePush();
if (WasmEnableThreads && BuildConfiguration === "Debug" && globalThis.setInterval) globalThis.setInterval(() => {
if (WasmEnableThreads && globalThis.setInterval) globalThis.setInterval(() => {
mono_log_info("UI thread is alive!");
}, 3000);

Expand Down

0 comments on commit 556e4b1

Please sign in to comment.