Skip to content

[browser] "Expected asset to have the downloaded buffer" assert fails when specifying "buffer" in MonoConfig #89570

Closed
@elringus

Description

@elringus

Description

In an attempt to work around #89510 I've tried loading the assets manually and set them to buffer of MonoConfig, but it throws on this assert: https://github.com/dotnet/runtime/blob/v8.0.0-preview.6.23329.7/src/mono/wasm/runtime/loader/assets.ts#L159

Sorry if I'm missing something obvious, but is there any way at all to run browser app with a custom MonoConfig in .NET 8?

Reproduction Steps

Build and attempt running a minimal browser-wasm app as follows:

import { dotnet } from "./dotnet.js";

(async function () {
    const config = {
        mainAssemblyName: "Test.dll",
        assemblyRootFolder: "managed",
        assets: [
            {
                behavior: "dotnetwasm",
                buffer: await fetchBinary("dotnet.native.wasm"),
                name: "dotnet.native.wasm"
            },
            {
                behavior: "js-module-native",
                name: "dotnet.native.js"
            },
            {
                behavior: "js-module-runtime",
                name: "dotnet.runtime.js"
            },
            {
                behavior: "assembly",
                buffer: await fetchBinary("System.Console.wasm"),
                name: "System.Console.wasm"
            },
            {
                behavior: "assembly",
                buffer: await fetchBinary("System.Private.CoreLib.wasm"),
                name: "System.Private.CoreLib.wasm"
            },
            {
                behavior: "assembly",
                buffer: await fetchBinary("Test.wasm"),
                name: "Test.wasm"
            }
        ]
    };
    const runtime = await dotnet.withConfig(config).create();
})();

async function fetchBinary(name) {
    const uri = `./managed/${name}`;
    return new Uint8Array(await (await fetch(uri)).arrayBuffer());
}

Full repro project with steps: https://github.com/Elringus/JSInteropTest

Expected behavior

dotnet.js initializes with the provided pre-loaded binary assets.

Actual behavior

Error in mono_download_assets: Error: Assert failed: Expected asset to have the downloaded buffer is thrown.

Regression?

Yes, it worked in .NET 7.

Known Workarounds

None.

Configuration

.NET v8.0.0-preview.6.23329.7
Windows 10
Local http server under AppBundle dir with serve under powershell.

Other information

No response

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions