Skip to content

Commit

Permalink
[wasm] Initial emscripten 3.1.30 support (#81215)
Browse files Browse the repository at this point in the history
* [wasm] Initial emscripten 3.1.30 support

* Update icu dependency

* Update emsdk dependency

* Use new docker images

* Add "icudt68_dat" as JS imported function.

It's an undefined symbol in ICU, because we are not linking in a lib, that should in the end be linked out.
Updated version of emscripten has by default turned on the LLD_REPORT_UNDEFINED .

* Drop build-time support for undefined icudt68_dat.

* Fix linker options

Should be `--lto-O0`

* Fix remaining conflict

* Limit new warnings option to browser

* Try to force reinstall of certifi

* Unset `FROZEN_CACHE` for `embuilder build MINIMAL`

* Update emsdk deps

* Remove assert for stack address

The linker puts stack at 0 sometime, so just check that the stack size
is not zero.

* Get back the stack base assert

For non-wasm targets. Add comment.

* Set stack size to 5MB

Which was the default size in older emscripten versions. Let see if it
is related to some of the issues.

* Disable WBT tests with SkiSharp

context: #82725

* Disable more WBT tests with SkiSharp

* Set the stack size also in native targets

* Update icu deps

* Update emsdk deps

* Enable BigInt support

Co-authored-by: pavelsavara <[email protected]>

* Enable BigInt here as well

* Temporarily allow undefined symbols

To unblock other work. After merge of main we are now again getting
linker errors with:

    .nuget/packages/microsoft.netcore.runtime.icu.transport/8.0.0-preview.3.23128.1/runtimes/browser-wasm/native/lib/libicuuc.a(udata.ao): undefined symbol: icudt68_dat

* Try to use pip-system-certs package

Co-authored-by: Ankit Jain <[email protected]>

* Fix merge damage for marking "icudt68_dat" a JS imported function + revert temporal fix.

* Try another python certifi package

* Try install pip-system-certs for emsdk's python

* Try to update machine certs for www.sqlite.org

* Refactor + upgrade pip

Also use the newer pip-system-certs again

* Use new net8 images

* Add `-s INCOMING_MODULE_JS_API=print,printErr`

* Introduce EmccStackSize msbuild property

* Remove FIXME from merge

We don't have afterUpdateGlobalBufferAndViews anymore

* Fixes around updateMemoryViews

* Pass --experimental-wasm-bigint to v8

Ubuntu 18.04 helix image has old v8

* Try multiple --engine-arg options

* Revert "Introduce EmccStackSize msbuild property"

This reverts commit f67ea5e.

* Disable 3 filesystem related tests

* Add bigint to AOT test template

* Introduce EmccStackSize msbuild property

* Update emsdk deps

* Update icu deps

* Revert "Add `-s INCOMING_MODULE_JS_API=print,printErr`"

This reverts commit 889d036.

* Update emsdk deps

* Update icu deps

* Disable one more file related test

---------

Co-authored-by: Marek Fišera <[email protected]>
Co-authored-by: pavelsavara <[email protected]>
Co-authored-by: Ankit Jain <[email protected]>
Co-authored-by: Larry Ewing <[email protected]>
  • Loading branch information
5 people authored Mar 11, 2023
1 parent 8d9ca3f commit fe95ddb
Show file tree
Hide file tree
Showing 37 changed files with 127 additions and 99 deletions.
8 changes: 4 additions & 4 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.NETCore.Runtime.ICU.Transport" Version="8.0.0-preview.3.23159.2">
<Dependency Name="Microsoft.NETCore.Runtime.ICU.Transport" Version="8.0.0-preview.3.23160.1">
<Uri>https://github.com/dotnet/icu</Uri>
<Sha>38d4086df0bf334ccf48e12e257b8759b0c9e97f</Sha>
<Sha>ce62ebe8dbfec7cdf79421d32b2c8eac439ad78c</Sha>
</Dependency>
<Dependency Name="System.Net.MsQuic.Transport" Version="8.0.0-alpha.1.23156.1">
<Uri>https://github.com/dotnet/msquic</Uri>
Expand Down Expand Up @@ -85,9 +85,9 @@
<Sha>b126490cd618d6066ed44e0369b4585e845cf9ab</Sha>
<SourceBuild RepoName="cecil" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.NET.Workload.Emscripten.Current.Manifest-8.0.100.Transport" Version="8.0.0-preview.3.23159.3">
<Dependency Name="Microsoft.NET.Workload.Emscripten.Current.Manifest-8.0.100.Transport" Version="8.0.0-preview.3.23160.1">
<Uri>https://github.com/dotnet/emsdk</Uri>
<Sha>b211c38c398416b516ffab1806b8ba47d49c42da</Sha>
<Sha>352d64e0ce9b99a8cff6207621432a986920ffd9</Sha>
<SourceBuild RepoName="emsdk" ManagedOnly="true" />
</Dependency>
</ProductDependencies>
Expand Down
4 changes: 2 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
<!-- Mono Cecil -->
<MicrosoftDotNetCecilVersion>0.11.4-alpha.23156.1</MicrosoftDotNetCecilVersion>
<!-- ICU -->
<MicrosoftNETCoreRuntimeICUTransportVersion>8.0.0-preview.3.23159.2</MicrosoftNETCoreRuntimeICUTransportVersion>
<MicrosoftNETCoreRuntimeICUTransportVersion>8.0.0-preview.3.23160.1</MicrosoftNETCoreRuntimeICUTransportVersion>
<!-- MsQuic -->
<MicrosoftNativeQuicMsQuicVersion>2.1.7</MicrosoftNativeQuicMsQuicVersion>
<SystemNetMsQuicTransportVersion>8.0.0-alpha.1.23156.1</SystemNetMsQuicTransportVersion>
Expand All @@ -238,7 +238,7 @@
Note: when the name is updated, make sure to update dependency name in eng/pipelines/common/xplat-setup.yml
like - DarcDependenciesChanged.Microsoft_NET_Workload_Emscripten_Current_Manifest-8_0_100_Transport
-->
<MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion>8.0.0-preview.3.23159.3</MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion>
<MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion>8.0.0-preview.3.23160.1</MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion>
<MicrosoftNETRuntimeEmscriptenVersion>$(MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion)</MicrosoftNETRuntimeEmscriptenVersion>
<!-- workloads -->
<SwixPackageVersion>1.1.87-gba258badda</SwixPackageVersion>
Expand Down
4 changes: 2 additions & 2 deletions eng/pipelines/common/templates/pipeline-with-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ resources:
ROOTFS_DIR: /crossrootfs/ppc64le

- container: browser_wasm
image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-webassembly
image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-webassembly-net8

- container: wasi_wasm
image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-20.04-webassembly
image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-20.04-webassembly-net8

- container: freebsd_x64
image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-cross-freebsd-12
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/libraries/helix-queues-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,6 @@ jobs:

# Browser WebAssembly windows
- ${{ if in(parameters.platform, 'browser_wasm_win', 'wasi_wasm_win') }}:
- (Windows.Amd64.Server2022.Open)[email protected]/dotnet-buildtools/prereqs:windowsservercore-ltsc2022-helix-webassembly
- (Windows.Amd64.Server2022.Open)[email protected]/dotnet-buildtools/prereqs:windowsservercore-ltsc2022-helix-webassembly-net8

${{ insert }}: ${{ parameters.jobParameters }}
46 changes: 28 additions & 18 deletions eng/pipelines/mono/update-machine-certs.ps1
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
# This seems to update the machine cert store so that python can download the files as required by emscripten's install
# Based on info at https://pypi.org/project/certifi/
pip install certifi
python -m pip install --upgrade pip
pip install --upgrade certifi pip-system-certs

$WebsiteURL="storage.googleapis.com"
Try {
$Conn = New-Object System.Net.Sockets.TcpClient($WebsiteURL,443)
function UpdateSite {

param (
$WebsiteURL
)

Try {
$Stream = New-Object System.Net.Security.SslStream($Conn.GetStream())
$Stream.AuthenticateAsClient($WebsiteURL)
$Conn = New-Object System.Net.Sockets.TcpClient($WebsiteURL,443)

$Cert = $Stream.Get_RemoteCertificate()
Try {
$Stream = New-Object System.Net.Security.SslStream($Conn.GetStream())
$Stream.AuthenticateAsClient($WebsiteURL)

$ValidTo = [datetime]::Parse($Cert.GetExpirationDatestring())
$Cert = $Stream.Get_RemoteCertificate()

Write-Host "`nConnection Successful" -ForegroundColor DarkGreen
Write-Host "Website: $WebsiteURL"
}
Catch { Throw $_ }
Finally { $Conn.close() }
}
Catch {
Write-Host "`nError occurred connecting to $($WebsiteURL)" -ForegroundColor Yellow
$ValidTo = [datetime]::Parse($Cert.GetExpirationDatestring())

Write-Host "`nConnection Successful" -ForegroundColor DarkGreen
Write-Host "Website: $WebsiteURL"
Write-Host "Status:" $_.exception.innerexception.message -ForegroundColor Yellow
Write-Host ""
}
Catch { Throw $_ }
Finally { $Conn.close() }
}
Catch {
Write-Host "`nError occurred connecting to $($WebsiteURL)" -ForegroundColor Yellow
Write-Host "Website: $WebsiteURL"
Write-Host "Status:" $_.exception.innerexception.message -ForegroundColor Yellow
Write-Host ""
}
}

UpdateSite("storage.googleapis.com")
UpdateSite("www.sqlite.org")
10 changes: 5 additions & 5 deletions eng/testing/WasmRunnerAOTTemplate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ if [[ -z "$XHARNESS_COMMAND" ]]; then
fi

if [[ "$XHARNESS_COMMAND" == "test" ]]; then
if [[ -z "$JS_ENGINE_ARGS" ]]; then
JS_ENGINE_ARGS="--engine-arg=--stack-trace-limit=1000"
fi

if [[ -z "$JS_ENGINE" ]]; then
if [[ "$SCENARIO" == "WasmTestOnNodeJS" || "$SCENARIO" == "wasmtestonnodejs" ]]; then
JS_ENGINE="--engine=NodeJS"
JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--experimental-wasm-simd"
else
JS_ENGINE="--engine=V8"
JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--experimental-wasm-simd"
JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--experimental-wasm-simd --engine-arg=--experimental-wasm-bigint"
fi
fi

if [[ -z "$MAIN_JS" ]]; then
MAIN_JS="--js-file=test-main.js"
fi

if [[ -z "$JS_ENGINE_ARGS" ]]; then
JS_ENGINE_ARGS="--engine-arg=--stack-trace-limit=1000"
fi
fi

if [[ -z "$XHARNESS_ARGS" ]]; then
Expand Down
6 changes: 5 additions & 1 deletion eng/testing/WasmRunnerTemplate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ if [[ "$XHARNESS_COMMAND" == "test" ]]; then
fi

if [[ -z "$JS_ENGINE_ARGS" ]]; then
JS_ENGINE_ARGS="--engine-arg=--stack-trace-limit=1000"
if [[ "$SCENARIO" == "WasmTestOnNodeJS" || "$SCENARIO" == "wasmtestonnodejs" ]]; then
JS_ENGINE_ARGS="--engine-arg=--stack-trace-limit=1000"
else
JS_ENGINE_ARGS="--engine-arg=--stack-trace-limit=1000 --engine-arg=--experimental-wasm-bigint"
fi
fi
fi

Expand Down
2 changes: 1 addition & 1 deletion eng/testing/tests.browser.targets
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
</PropertyGroup>

<PropertyGroup>
<EmccLinkOptimizationFlag Condition="'$(EmccLinkOptimizationFlag)' == ''">-Oz -Wl,-O0 -Wl,-lto-O0</EmccLinkOptimizationFlag>
<EmccLinkOptimizationFlag Condition="'$(EmccLinkOptimizationFlag)' == ''">-Oz -Wl,-O0 -Wl,--lto-O0</EmccLinkOptimizationFlag>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public override IEnumerable<TimeFunction> TimeFunctions(bool requiresRoundtrippi
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/83197", TestPlatforms.Browser)]
public void SetLastWriteTimeTicks()
{
string firstFile = GetTestFilePath();
Expand Down Expand Up @@ -184,6 +185,7 @@ public void SetDateTimeMax()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/83197", TestPlatforms.Browser)]
public void SetLastAccessTimeTicks()
{
string firstFile = GetTestFilePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ public void LeaveOpenRespected_Basic(bool leaveOpen)
[Theory]
[InlineData(true)]
[InlineData(false)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/83197", TestPlatforms.Browser)]
public void LeaveOpenRespected_OutstandingViews(bool leaveOpen)
{
const int Capacity = 4096;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ public void InvalidAfterDisposal()
/// Test to verify that we can still use a view after the associated map has been disposed.
/// </summary>
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/83197", TestPlatforms.Browser)]
public void UseAfterMMFDisposal()
{
foreach (MemoryMappedFile mmf in CreateSampleMaps(8192))
Expand Down
1 change: 1 addition & 0 deletions src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ elseif(CLR_CMAKE_HOST_OS STREQUAL "emscripten")
add_definitions(-D_THREAD_SAFE)
add_compile_options(-Wno-strict-prototypes)
add_compile_options(-Wno-unused-but-set-variable)
add_compile_options(-Wno-single-bit-bitfield-constant-conversion)
set(DISABLE_EXECUTABLES 1)
# FIXME: Is there a cmake option for this ?
set(DISABLE_SHARED_LIBS 1)
Expand Down
5 changes: 5 additions & 0 deletions src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
<ActivateCmd>$(EMSDK_PATH)/emsdk$(EmsdkExt) activate $(EmscriptenVersion)</ActivateCmd>
<InstallCmd Condition="'$(HostOS)' == 'windows'">powershell -NonInteractive -command &quot;&amp; $(InstallCmd); Exit $LastExitCode &quot;</InstallCmd>
<ActivateCmd Condition="'$(HostOS)' == 'windows'">powershell -NonInteractive -command &quot;&amp; $(ActivateCmd); Exit $LastExitCode &quot;</ActivateCmd>
<PythonCmd Condition="'$(HostOS)' == 'windows'and '$(TargetsBrowser)' == 'true'">setlocal EnableDelayedExpansion &amp;&amp; call &quot;$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env.bat'))&quot; &amp;&amp; !EMSDK_PYTHON!</PythonCmd>
</PropertyGroup>

<RemoveDir Directories="$(EMSDK_PATH)" />
Expand All @@ -162,6 +163,10 @@
<Exec Command="git checkout $(EmscriptenVersion) &amp;&amp; $(InstallCmd) &amp;&amp; $(ActivateCmd)"
WorkingDirectory="$(EMSDK_PATH)"
IgnoreStandardErrorWarningFormat="true" />
<Exec Command="$(PythonCmd) -m pip install certifi &amp;&amp; $(PythonCmd) -m pip install pip-system-certs"
Condition="'$(HostOS)' == 'windows'"
WorkingDirectory="$(EMSDK_PATH)"
IgnoreStandardErrorWarningFormat="true" />
</Target>

<!-- Sets up WASI SDK if you don't have the WASI_SDK_PATH env variable set -->
Expand Down
4 changes: 4 additions & 0 deletions src/mono/mono/utils/mono-threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,11 @@ register_thread (MonoThreadInfo *info)
mono_native_tls_set_value (thread_info_key, info);

mono_thread_info_get_stack_bounds (&staddr, &stsize);

/* for wasm, the stack can be placed at the start of the linear memory */
#ifndef TARGET_WASM
g_assert (staddr);
#endif
g_assert (stsize);
info->stack_start_limit = staddr;
info->stack_end = staddr + stsize;
Expand Down
1 change: 1 addition & 0 deletions src/mono/wasm/Wasm.Build.Tests/Blazor/BuildPublishTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public void DefaultTemplate_NoAOT_WithWorkload(string config)
[InlineData("Release", /*build*/true, /*publish*/false)]
[InlineData("Release", /*build*/false, /*publish*/true)]
[InlineData("Release", /*build*/true, /*publish*/true)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/82725")]
public async Task WithDllImportInMainAssembly(string config, bool build, bool publish)
{
// Based on https://github.com/dotnet/runtime/issues/59255
Expand Down
2 changes: 2 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/Blazor/NativeRefTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public NativeRefTests(ITestOutputHelper output, SharedBuildPerTestClassFixture b
[Theory]
[InlineData("Debug")]
[InlineData("Release")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/82725")]
public void WithNativeReference_AOTInProjectFile(string config)
{
string id = $"blz_nativeref_aot_{config}_{Path.GetRandomFileName()}";
Expand All @@ -41,6 +42,7 @@ public void WithNativeReference_AOTInProjectFile(string config)
[Theory]
[InlineData("Debug")]
[InlineData("Release")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/82725")]
public void WithNativeReference_AOTOnCommandLine(string config)
{
string id = $"blz_nativeref_aot_{config}_{Path.GetRandomFileName()}";
Expand Down
1 change: 1 addition & 0 deletions src/mono/wasm/Wasm.Build.Tests/NativeLibraryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void ProjectWithNativeReference(BuildArgs buildArgs, RunHost host, string
[Theory]
[BuildAndRun(aot: false)]
[BuildAndRun(aot: true)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/82725")]
public void ProjectUsingSkiaSharp(BuildArgs buildArgs, RunHost host, string id)
{
string projectName = $"AppUsingSkiaSharp";
Expand Down
7 changes: 6 additions & 1 deletion src/mono/wasm/build/WasmApp.Native.targets
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
<_EmccLinkRsp>$(_WasmIntermediateOutputPath)emcc-link.rsp</_EmccLinkRsp>

<EmccInitialHeapSize Condition="'$(EmccInitialHeapSize)' == ''">$(EmccTotalMemory)</EmccInitialHeapSize>
<EmccStackSize Condition="'$(EmccStackSize)' == ''">5MB</EmccStackSize>
<WasmAllowUndefinedSymbols Condition="'$(WasmAllowUndefinedSymbols)' == ''">false</WasmAllowUndefinedSymbols>
</PropertyGroup>

Expand Down Expand Up @@ -322,10 +323,12 @@
<WriteLinesToFile Lines="@(_EmccCFlags)" File="$(_EmccCompileRsp)" Overwrite="true" WriteOnlyWhenDifferent="true" />
<ItemGroup>
<FileWrites Include="$(_EmccCompileRsp)" />
<EmscriptenMinimalBuildEnvVars Include="@(EmscriptenEnvVars)" />
<EmscriptenMinimalBuildEnvVars Include="FROZEN_CACHE=" />
</ItemGroup>

<!-- warm up the cache -->
<Exec Command="$(_EmBuilder) build MINIMAL" EnvironmentVariables="@(EmscriptenEnvVars)" StandardOutputImportance="Low" StandardErrorImportance="Low" />
<Exec Command="$(_EmBuilder) build MINIMAL" EnvironmentVariables="@(EmscriptenMinimalBuildEnvVars)" StandardOutputImportance="Low" StandardErrorImportance="Low" />

<Message Text="Compiling native assets with emcc with $(EmccCompileOptimizationFlag). This may take a while ..." Importance="High" />
<ItemGroup>
Expand Down Expand Up @@ -419,6 +422,8 @@
<ItemGroup>
<!-- order matters -->
<_EmccLDSFlags Include="-s INITIAL_MEMORY=$(EmccInitialHeapSize)" />
<_EmccLDSFlags Include="-s STACK_SIZE=$(EmccStackSize)" />
<_EmccLDSFlags Include="-s WASM_BIGINT=1" />

<_WasmNativeFileForLinking Include="%(_BitcodeFile.ObjectFile)" />
<_WasmNativeFileForLinking Include="%(_WasmSourceFileToCompile.ObjectFile)" />
Expand Down
4 changes: 3 additions & 1 deletion src/mono/wasm/build/WasmApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@
- $(EmccExtraLDFlags) - Extra emcc flags for linking
- $(EmccExtraCFlags) - Extra emcc flags for compiling native files
- $(EmccInitialHeapSize) - Initial heap size specified with `emcc`. Default value: 16777216 or size of the DLLs, whichever is larger.
Corresponds to `INITIAL_MEMORY` arg for emcc.
Corresponds to `-s INITIAL_MEMORY=...` emcc arg.
(previously named EmccTotalMemory, which is still kept as an alias)
- $(EmccStackSize) - Stack size. Default value: 5MB.
Corresponds to `-s STACK_SIZE=...` emcc arg.
- $(WasmBuildAppAfterThisTarget) - This target is used as `AfterTargets` for `WasmBuildApp. this
is what triggers the wasm app building. Defaults to `Build`.
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/emscripten-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.12
3.1.30
16 changes: 8 additions & 8 deletions src/mono/wasm/runtime/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,17 @@ export async function mono_download_assets(): Promise<void> {
// and we are not awating it here
Promise.all(promises_of_asset_instantiation).then(() => {
allAssetsInMemory.promise_control.resolve();
}).catch(err => {
Module.printErr("MONO_WASM: Error in mono_download_assets: " + err);
abort_startup(err, true);
}).catch(e => {
Module.err("MONO_WASM: Error in mono_download_assets: " + e);
abort_startup(e, true);
});
// OPTIMIZATION explained:
// we do it this way so that we could allocate memory immediately after asset is downloaded (and after onRuntimeInitialized which happened already)
// spreading in time
// rather than to block all downloads after onRuntimeInitialized or block onRuntimeInitialized after all downloads are done. That would create allocation burst.
} catch (err: any) {
Module.printErr("MONO_WASM: Error in mono_download_assets: " + err);
throw err;
} catch (e: any) {
Module.err("MONO_WASM: Error in mono_download_assets: " + e);
throw e;
}
}

Expand Down Expand Up @@ -282,7 +282,7 @@ async function start_asset_download_sources(asset: AssetEntryInternal): Promise<
err.status = response.status;
throw err;
} else {
Module.print(`MONO_WASM: optional download '${response.url}' for ${asset.name} failed ${response.status} ${response.statusText}`);
Module.out(`MONO_WASM: optional download '${response.url}' for ${asset.name} failed ${response.status} ${response.statusText}`);
return undefined;
}
}
Expand Down Expand Up @@ -426,7 +426,7 @@ function _instantiate_asset(asset: AssetEntry, url: string, bytes: Uint8Array) {
}
else if (asset.behavior === "icu") {
if (!mono_wasm_load_icu_data(offset!))
Module.printErr(`MONO_WASM: Error loading ICU asset ${asset.name}`);
Module.err(`MONO_WASM: Error loading ICU asset ${asset.name}`);
}
else if (asset.behavior === "resource") {
cwraps.mono_wasm_add_satellite_assembly(virtualName, asset.culture || "", offset!, bytes.length);
Expand Down
4 changes: 2 additions & 2 deletions src/mono/wasm/runtime/dotnet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ declare interface EmscriptenModule {
HEAPF64: Float64Array;
_malloc(size: number): VoidPtr;
_free(ptr: VoidPtr): void;
print(message: string): void;
printErr(message: string): void;
out(message: string): void;
err(message: string): void;
ccall<T>(ident: string, returnType?: string | null, argTypes?: string[], args?: any[], opts?: any): T;
cwrap<T extends Function>(ident: string, returnType: string, argTypes?: string[], opts?: any): T;
cwrap<T extends Function>(ident: string, ...args: any[]): T;
Expand Down
Loading

0 comments on commit fe95ddb

Please sign in to comment.