dotnet / dotnet/runtime

[browser][coreCLR] Assembly.LoadFrom("xxx.dll") doesn't hit external_assembly_probe

Open
#122,972 5 comments 0 reactions 1 assignee Claimed by @pavelsavara View on GitHub
arch-wasm area-Host os-browser
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

In browser/wasm we download DLLs from server during startup. This is done because dotnet API for loading assemblies is synchronous and browser `fetch` is asynchronous. And so we could not fetch assembly from server lazily on-demand (in single thread).

So there is application manifest that contains list of all known assemblies. We install them into linear memory, but we do not place them into virtual file system (VFS). Because that would consume additional memory of the browser tab. We don't really have memory mapping that normal OS has. VFS is bunch of JS objects, which don't live in WASM linear memory.

The normal behavior of `Assembly.LoadFrom("xxx.dll")` is to look up the file on disk and memory map it into dotnet process.
Mono on WASM intercepts LoadFrom via `mono_dl_open` and if the file is already in memory, we would return that.

**On CoreCLR, there is `external_assembly_probe` that we use to load files into memory, but it is not called for `Assembly.LoadFrom`. Should we call `external_assembly_probe` for `Assembly.LoadFrom` ?**

[Xharness](https://github.com/dotnet/xharness/blob/799df8d4c86ff50c83b7a57df9e3691eeab813ec/src/Microsoft.DotNet.XHarness.TestRunners.Xunit/WasmApplicationEntryPoint.cs#L56) on WASM is using that Mono/WASM behavior and possibly other Blazor applications, we don't know.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.