Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelsavara committed Mar 3, 2023
1 parent ea02d94 commit c1aa6c3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/mono/sample/wasm/browser/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ function displayMeaning(meaning) {

try {
const { setModuleImports } = await dotnet
.withMemoryCache()
.withElementOnExit()
.create();

Expand Down
1 change: 1 addition & 0 deletions src/mono/wasm/runtime/run-outer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface DotnetHostBuilder {
withDebugging(level: number): DotnetHostBuilder
withMainAssembly(mainAssemblyName: string): DotnetHostBuilder
withApplicationArgumentsFromQuery(): DotnetHostBuilder
withMemoryCache(value: boolean): DotnetHostBuilder
create(): Promise<RuntimeAPI>
run(): Promise<number>
}
Expand Down
15 changes: 8 additions & 7 deletions src/mono/wasm/runtime/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ async function mono_wasm_before_user_runtime_initialized(): Promise<void> {
mono_wasm_globalization_init();

if (!runtimeHelpers.mono_wasm_load_runtime_done) mono_wasm_load_runtime("unused", config.debugLevel);
if (runtimeHelpers.config.cacheMemory && !runtimeHelpers.memoryIsLoaded) {
if (config.cacheMemory && !runtimeHelpers.memoryIsLoaded) {
await storeMemory(runtimeHelpers.configurationHash, Module.HEAP8.buffer);
}
bindings_init();
Expand Down Expand Up @@ -470,7 +470,7 @@ async function instantiate_wasm_module(
if (runtimeHelpers.diagnosticTracing) console.debug("MONO_WASM: instantiate_wasm_module");
const assetToLoad = resolve_asset_path("dotnetwasm");

if (runtimeHelpers.config.cacheMemory && config.assetsHash) {
if (config.cacheMemory && config.assetsHash) {
memoryBytes = await getMemory(runtimeHelpers.configurationHash);
runtimeHelpers.memoryIsLoaded = !!memoryBytes;
}
Expand Down Expand Up @@ -553,7 +553,7 @@ export function mono_wasm_load_runtime(unused?: string, debugLevel?: number): vo
}
endMeasure(mark, MeasuredBlock.loadRuntime);

if (!runtimeHelpers.config.cacheMemory) bindings_init();
if (!config.cacheMemory) bindings_init();
} catch (err: any) {
_print_error("MONO_WASM: mono_wasm_load_runtime () failed", err);

Expand Down Expand Up @@ -602,7 +602,7 @@ export async function mono_wasm_load_config(configFilePath?: string): Promise<vo
configLoaded = true;
if (!configFilePath) {
normalizeConfig();
afterConfigLoaded.promise_control.resolve(runtimeHelpers.config);
afterConfigLoaded.promise_control.resolve(config);
return;
}
if (runtimeHelpers.diagnosticTracing) console.debug("MONO_WASM: mono_wasm_load_config");
Expand All @@ -623,15 +623,15 @@ export async function mono_wasm_load_config(configFilePath?: string): Promise<vo

if (Module.onConfigLoaded) {
try {
await Module.onConfigLoaded(<MonoConfig>runtimeHelpers.config);
await Module.onConfigLoaded(<MonoConfig>config);
normalizeConfig();
}
catch (err: any) {
_print_error("MONO_WASM: onConfigLoaded() failed", err);
throw err;
}
}
afterConfigLoaded.promise_control.resolve(runtimeHelpers.config);
afterConfigLoaded.promise_control.resolve(config);
} catch (err) {
const errMessage = `Failed to load config file ${configFilePath} ${err}`;
abort_startup(errMessage, true);
Expand All @@ -648,13 +648,14 @@ function normalizeConfig() {
config.assets = config.assets || [];
config.runtimeOptions = config.runtimeOptions || [];
config.globalizationMode = config.globalizationMode || "auto";
config.cacheMemory = config.cacheMemory == undefined ? true : !!config.cacheMemory;
if (config.debugLevel === undefined && BuildConfiguration === "Debug") {
config.debugLevel = -1;
}
if (config.diagnosticTracing === undefined && BuildConfiguration === "Debug") {
config.diagnosticTracing = true;
}
runtimeHelpers.diagnosticTracing = !!runtimeHelpers.config.diagnosticTracing;
runtimeHelpers.diagnosticTracing = !!config.diagnosticTracing;

runtimeHelpers.enablePerfMeasure = !!config.browserProfilerOptions
&& globalThis.performance
Expand Down

0 comments on commit c1aa6c3

Please sign in to comment.