diff --git a/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml b/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml
index e6be56a9307d6..0efe765230720 100644
--- a/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml
+++ b/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml
@@ -119,7 +119,7 @@ jobs:
alwaysRun: ${{ parameters.isWasmOnlyBuild }}
# NOTE - Since threading is experimental, we don't want to block mainline work
- shouldContinueOnError: true
+ # TODO put back shouldContinueOnError: true
scenarios:
- WasmTestOnBrowser
#- WasmTestOnNodeJS - this is not supported yet, https://github.com/dotnet/runtime/issues/85592
diff --git a/eng/testing/tests.browser.targets b/eng/testing/tests.browser.targets
index 2b383ef15054e..1e0c5f2be23a3 100644
--- a/eng/testing/tests.browser.targets
+++ b/eng/testing/tests.browser.targets
@@ -111,7 +111,7 @@
$(WasmXHarnessMonoArgs) --no-memory-snapshot
- $(WasmXHarnessMonoArgs) --setenv=IsBrowserThreadingSupported=true
+ $(WasmXHarnessMonoArgs) --multithreaded --setenv=IsBrowserThreadingSupported=true
diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleFormatterTests.cs b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleFormatterTests.cs
index 573006673d888..6da081c4e86ab 100644
--- a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleFormatterTests.cs
+++ b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleFormatterTests.cs
@@ -74,7 +74,6 @@ internal static (ConsoleLogger Logger, ConsoleSink Sink, ConsoleSink ErrorSink,
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void ConsoleLoggerOptions_TimeStampFormat_IsReloaded()
{
// Arrange
@@ -88,7 +87,6 @@ public void ConsoleLoggerOptions_TimeStampFormat_IsReloaded()
}
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[MemberData(nameof(FormatterNames))]
public void InvalidLogLevel_Throws(string formatterName)
{
@@ -103,7 +101,6 @@ public void InvalidLogLevel_Throws(string formatterName)
}
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[MemberData(nameof(FormatterNamesAndLevels))]
public void NoMessageOrException_Noop(string formatterName, LogLevel level)
{
@@ -123,7 +120,6 @@ public void NoMessageOrException_Noop(string formatterName, LogLevel level)
}
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[MemberData(nameof(FormatterNamesAndLevels))]
public void Log_LogsCorrectTimestamp(string formatterName, LogLevel level)
{
diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerTest.cs b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerTest.cs
index f0ef3d6cd7e1d..0994980590122 100644
--- a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerTest.cs
+++ b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerTest.cs
@@ -174,7 +174,6 @@ internal static string GetJsonLogLevelString(LogLevel logLevel)
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void LogsWhenMessageIsNotProvided()
{
// Arrange
@@ -207,7 +206,6 @@ public void LogsWhenMessageIsNotProvided()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void DoesNotLog_NewLine_WhenNoExceptionIsProvided()
{
// Arrange
@@ -236,7 +234,6 @@ public void DoesNotLog_NewLine_WhenNoExceptionIsProvided()
}
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[InlineData(null, 0)]
[InlineData(null, 1)]
[InlineData("missingFormatter", 0)]
@@ -279,7 +276,6 @@ public void Options_FormatterNameNull_UsesDeprecatedProperties(string formatterN
}
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[InlineData("Route with name 'Simple' was not found.")]
public void Writes_NewLine_WhenExceptionIsProvided(string message)
{
@@ -304,7 +300,6 @@ public void Writes_NewLine_WhenExceptionIsProvided(string message)
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void ThrowsException_WhenNoFormatterIsProvided()
{
// Arrange
@@ -316,7 +311,6 @@ public void ThrowsException_WhenNoFormatterIsProvided()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void LogsWhenNullFilterGiven()
{
// Arrange
@@ -338,7 +332,6 @@ public void LogsWhenNullFilterGiven()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void WriteCritical_LogsCorrectColors()
{
// Arrange
@@ -360,7 +353,6 @@ public void WriteCritical_LogsCorrectColors()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void WriteError_LogsCorrectColors()
{
// Arrange
@@ -382,7 +374,6 @@ public void WriteError_LogsCorrectColors()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void WriteWarning_LogsCorrectColors()
{
// Arrange
@@ -404,7 +395,6 @@ public void WriteWarning_LogsCorrectColors()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void WriteInformation_LogsCorrectColors()
{
// Arrange
@@ -456,7 +446,6 @@ public void AddConsole_IsOutputRedirected_ColorDisabled()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void WriteDebug_LogsCorrectColors()
{
// Arrange
@@ -478,7 +467,6 @@ public void WriteDebug_LogsCorrectColors()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void WriteTrace_LogsCorrectColors()
{
// Arrange
@@ -500,7 +488,6 @@ public void WriteTrace_LogsCorrectColors()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void WriteAllLevelsDisabledColors_LogsNoColors()
{
// Arrange
@@ -525,7 +512,6 @@ public void WriteAllLevelsDisabledColors_LogsNoColors()
}
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[MemberData(nameof(FormatsAndLevels))]
public void Log_LogsCorrectTimestamp(ConsoleLoggerFormat format, LogLevel level)
{
@@ -567,7 +553,6 @@ public void Log_LogsCorrectTimestamp(ConsoleLoggerFormat format, LogLevel level)
}
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[MemberData(nameof(FormatsAndLevels))]
public void WriteCore_LogsCorrectTimestampInUtc(ConsoleLoggerFormat format, LogLevel level)
{
@@ -609,7 +594,6 @@ public void WriteCore_LogsCorrectTimestampInUtc(ConsoleLoggerFormat format, LogL
}
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[MemberData(nameof(FormatsAndLevels))]
public void WriteCore_LogsCorrectMessages(ConsoleLoggerFormat format, LogLevel level)
{
@@ -654,7 +638,6 @@ public void WriteCore_LogsCorrectMessages(ConsoleLoggerFormat format, LogLevel l
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void NoLogScope_DoesNotWriteAnyScopeContentToOutput()
{
// Arrange
@@ -676,7 +659,6 @@ public void NoLogScope_DoesNotWriteAnyScopeContentToOutput()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void WritingScopes_LogsWithCorrectColors()
{
// Arrange
@@ -703,7 +685,6 @@ public void WritingScopes_LogsWithCorrectColors()
}
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[MemberData(nameof(Formats))]
public void WritingScopes_LogsExpectedMessage(ConsoleLoggerFormat format)
{
@@ -755,7 +736,6 @@ public void WritingScopes_LogsExpectedMessage(ConsoleLoggerFormat format)
}
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[MemberData(nameof(Formats))]
public void WritingNestedScope_LogsNullScopeName(ConsoleLoggerFormat format)
{
@@ -805,7 +785,6 @@ public void WritingNestedScope_LogsNullScopeName(ConsoleLoggerFormat format)
}
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[MemberData(nameof(Formats))]
public void WritingNestedScopes_LogsExpectedMessage(ConsoleLoggerFormat format)
{
@@ -864,7 +843,6 @@ public void WritingNestedScopes_LogsExpectedMessage(ConsoleLoggerFormat format)
}
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[MemberData(nameof(Formats))]
public void WritingMultipleScopes_LogsExpectedMessage(ConsoleLoggerFormat format)
{
@@ -934,7 +912,6 @@ public void WritingMultipleScopes_LogsExpectedMessage(ConsoleLoggerFormat format
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void CallingBeginScopeOnLogger_AlwaysReturnsNewDisposableInstance()
{
// Arrange
@@ -953,7 +930,6 @@ public void CallingBeginScopeOnLogger_AlwaysReturnsNewDisposableInstance()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void CallingBeginScopeOnLogger_ReturnsNonNullableInstance()
{
// Arrange
@@ -969,7 +945,6 @@ public void CallingBeginScopeOnLogger_ReturnsNonNullableInstance()
}
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[MemberData(nameof(Formats))]
public void ConsoleLoggerLogsToError_WhenOverErrorLevel(ConsoleLoggerFormat format)
{
@@ -1020,7 +995,6 @@ public void ConsoleLoggerLogsToError_WhenOverErrorLevel(ConsoleLoggerFormat form
}
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[MemberData(nameof(FormatsAndLevels))]
public void WriteCore_NullMessageWithException(ConsoleLoggerFormat format, LogLevel level)
{
@@ -1065,7 +1039,6 @@ public void WriteCore_NullMessageWithException(ConsoleLoggerFormat format, LogLe
}
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[MemberData(nameof(FormatsAndLevels))]
public void WriteCore_EmptyMessageWithException(ConsoleLoggerFormat format, LogLevel level)
{
@@ -1109,7 +1082,6 @@ public void WriteCore_EmptyMessageWithException(ConsoleLoggerFormat format, LogL
}
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[MemberData(nameof(FormatsAndLevels))]
public void WriteCore_MessageWithNullException(ConsoleLoggerFormat format, LogLevel level)
{
@@ -1150,7 +1122,6 @@ public void WriteCore_MessageWithNullException(ConsoleLoggerFormat format, LogLe
}
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[MemberData(nameof(Levels))]
public void WriteCore_NullMessageWithNullException(LogLevel level)
{
@@ -1169,7 +1140,6 @@ public void WriteCore_NullMessageWithNullException(LogLevel level)
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public static void IsEnabledReturnsCorrectValue()
{
var logger = SetUp().Logger;
@@ -1184,7 +1154,6 @@ public static void IsEnabledReturnsCorrectValue()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void ConsoleLoggerOptions_DisableColors_IsAppliedToLoggers()
{
// Arrange
@@ -1219,7 +1188,6 @@ public void ConsoleLoggerOptions_SetInvalidBufferMode_Throws()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void ConsoleLoggerOptions_DisableColors_IsReadFromLoggingConfiguration()
{
var configuration = new ConfigurationBuilder().AddInMemoryCollection(new[] { new KeyValuePair("Console:DisableColors", "true") }).Build();
@@ -1237,7 +1205,6 @@ public void ConsoleLoggerOptions_DisableColors_IsReadFromLoggingConfiguration()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void ConsoleLoggerOptions_TimeStampFormat_IsReloaded()
{
// Arrange
@@ -1252,7 +1219,6 @@ public void ConsoleLoggerOptions_TimeStampFormat_IsReloaded()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void ConsoleLoggerOptions_TimeStampFormat_IsReadFromLoggingConfiguration()
{
var configuration = new ConfigurationBuilder().AddInMemoryCollection(new[] { new KeyValuePair("Console:TimeStampFormat", "yyyyMMddHHmmss") }).Build();
@@ -1270,7 +1236,6 @@ public void ConsoleLoggerOptions_TimeStampFormat_IsReadFromLoggingConfiguration(
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void ConsoleLoggerOptions_TimeStampFormat_MultipleReloads()
{
var monitor = new TestOptionsMonitor(new ConsoleLoggerOptions());
@@ -1285,7 +1250,6 @@ public void ConsoleLoggerOptions_TimeStampFormat_MultipleReloads()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void ConsoleLoggerOptions_IncludeScopes_IsAppliedToLoggers()
{
// Arrange
@@ -1300,7 +1264,6 @@ public void ConsoleLoggerOptions_IncludeScopes_IsAppliedToLoggers()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void ConsoleLoggerOptions_LogAsErrorLevel_IsReadFromLoggingConfiguration()
{
var configuration = new ConfigurationBuilder().AddInMemoryCollection(new[] { new KeyValuePair("Console:LogToStandardErrorThreshold", "Warning") }).Build();
@@ -1318,7 +1281,6 @@ public void ConsoleLoggerOptions_LogAsErrorLevel_IsReadFromLoggingConfiguration(
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void ConsoleLoggerOptions_LogAsErrorLevel_IsAppliedToLoggers()
{
// Arrange
@@ -1333,7 +1295,6 @@ public void ConsoleLoggerOptions_LogAsErrorLevel_IsAppliedToLoggers()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void ConsoleLoggerOptions_UpdateQueueOptions_UpdatesConsoleLoggerProcessorProperties()
{
// Arrange
@@ -1353,7 +1314,6 @@ public void ConsoleLoggerOptions_UpdateQueueOptions_UpdatesConsoleLoggerProcesso
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void ConsoleLoggerOptions_UseUtcTimestamp_IsAppliedToLoggers()
{
// Arrange
@@ -1368,7 +1328,6 @@ public void ConsoleLoggerOptions_UseUtcTimestamp_IsAppliedToLoggers()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void ConsoleLoggerOptions_IncludeScopes_IsReadFromLoggingConfiguration()
{
var configuration = new ConfigurationBuilder().AddInMemoryCollection(new[] { new KeyValuePair("Console:IncludeScopes", "true") }).Build();
diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/SimpleConsoleFormatterTests.cs b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/SimpleConsoleFormatterTests.cs
index 26bd40775bb37..3bb1fa491ecea 100644
--- a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/SimpleConsoleFormatterTests.cs
+++ b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/SimpleConsoleFormatterTests.cs
@@ -10,7 +10,6 @@ namespace Microsoft.Extensions.Logging.Console.Test
public class SimpleConsoleFormatterTests : ConsoleFormatterTests
{
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[InlineData(LoggerColorBehavior.Default)]
[InlineData(LoggerColorBehavior.Enabled)]
[InlineData(LoggerColorBehavior.Disabled)]
@@ -55,7 +54,6 @@ public void Log_WritingScopes_LogsWithCorrectColorsWhenColorEnabled(LoggerColorB
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void Log_NoLogScope_DoesNotWriteAnyScopeContentToOutput()
{
// Arrange
@@ -111,7 +109,6 @@ public void Log_SingleLine_LogsWhenMessageIsNotProvided()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void Log_SingleLine_LogsWhenBothMessageAndExceptionProvided()
{
// Arrange
diff --git a/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/tests/Microsoft.Extensions.Logging.Testing.Tests.csproj b/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/tests/Microsoft.Extensions.Logging.Testing.Tests.csproj
index 49e334b679eeb..988cea66207a4 100644
--- a/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/tests/Microsoft.Extensions.Logging.Testing.Tests.csproj
+++ b/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/tests/Microsoft.Extensions.Logging.Testing.Tests.csproj
@@ -4,6 +4,11 @@
true
+
+ <_WasmPThreadPoolSize Condition="'$(MonoWasmBuildVariant)' == 'multithread'">64
+ --setenv=XHARNESS_LOG_TEST_START=true --no-memory-snapshot
+
+
diff --git a/src/libraries/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj b/src/libraries/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj
index bf090364567c5..d9b4f82a51d0e 100644
--- a/src/libraries/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj
+++ b/src/libraries/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj
@@ -13,6 +13,11 @@
$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))
$(DefineConstants);Unix
+
+
+ --setenv=XHARNESS_LOG_TEST_START=true --no-memory-snapshot
+
+
diff --git a/src/libraries/System.Runtime.Extensions/tests/System/Random.cs b/src/libraries/System.Runtime.Extensions/tests/System/Random.cs
index 648a85ae8fc2c..16c3a9a2353b7 100644
--- a/src/libraries/System.Runtime.Extensions/tests/System/Random.cs
+++ b/src/libraries/System.Runtime.Extensions/tests/System/Random.cs
@@ -516,7 +516,6 @@ public void Shared_IsSingleton()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public void Shared_ParallelUsage()
{
using var barrier = new Barrier(2);
diff --git a/src/libraries/System.Threading.Tasks.Parallel/tests/ParallelForTests.cs b/src/libraries/System.Threading.Tasks.Parallel/tests/ParallelForTests.cs
index 7ae7693fb2031..8093dc661b87c 100644
--- a/src/libraries/System.Threading.Tasks.Parallel/tests/ParallelForTests.cs
+++ b/src/libraries/System.Threading.Tasks.Parallel/tests/ParallelForTests.cs
@@ -885,7 +885,6 @@ public static void TestParallelForPaths_Exceptions()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91582", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public static void TestParallelScheduler()
{
ParallelOptions parallelOptions = new ParallelOptions();
@@ -993,7 +992,6 @@ public static void TestParallelScheduler()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91541", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public static void TestInvokeDOPAndCancel()
{
ParallelOptions parallelOptions = null;
diff --git a/src/libraries/System.Threading.Tasks.Parallel/tests/ParallelLoopResultTests.cs b/src/libraries/System.Threading.Tasks.Parallel/tests/ParallelLoopResultTests.cs
index 9006ee9469fc6..430eabdfa01bb 100644
--- a/src/libraries/System.Threading.Tasks.Parallel/tests/ParallelLoopResultTests.cs
+++ b/src/libraries/System.Threading.Tasks.Parallel/tests/ParallelLoopResultTests.cs
@@ -373,7 +373,6 @@ private static void OrderablePartitionerForEachPLRTest(
// Perform tests on various combinations of Stop()/Break()
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91579", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public static void SimultaneousStopBreakTests()
{
//
diff --git a/src/libraries/System.Threading.Tasks.Parallel/tests/RangePartitioner1Chunk.cs b/src/libraries/System.Threading.Tasks.Parallel/tests/RangePartitioner1Chunk.cs
index 02695b7524240..b7eece1c2de61 100644
--- a/src/libraries/System.Threading.Tasks.Parallel/tests/RangePartitioner1Chunk.cs
+++ b/src/libraries/System.Threading.Tasks.Parallel/tests/RangePartitioner1Chunk.cs
@@ -101,7 +101,6 @@ static void oneMoveNext(int length, bool isOrderable)
///
///
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91541", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public static void IterationsWithDependency()
{
static void iterationsWithDependency(int length, int dependencyIndex)
@@ -167,7 +166,6 @@ public static void PFEDisposeEnum()
/// Exception is expected and the enumerators are disposed
///
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91581", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public static void ExceptionOnMoveNext()
{
static void exceptionOnMoveNext(int length, int indexToThrow, bool isOrderable)
diff --git a/src/libraries/System.Threading.Tasks.Parallel/tests/RangePartitionerTests.cs b/src/libraries/System.Threading.Tasks.Parallel/tests/RangePartitionerTests.cs
index 3302c9b3b7383..87e427d0837ec 100644
--- a/src/libraries/System.Threading.Tasks.Parallel/tests/RangePartitionerTests.cs
+++ b/src/libraries/System.Threading.Tasks.Parallel/tests/RangePartitionerTests.cs
@@ -10,7 +10,6 @@ namespace System.Threading.Tasks.Tests
public static class RangePartitionerTests
{
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91541", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public static void RunPartitionerStaticTest_SingleChunking()
{
CountdownEvent cde = new CountdownEvent(2);
diff --git a/src/libraries/System.Threading/tests/SemaphoreSlimTests.cs b/src/libraries/System.Threading/tests/SemaphoreSlimTests.cs
index 4c2c5cc53a524..7aabd01c39f1e 100644
--- a/src/libraries/System.Threading/tests/SemaphoreSlimTests.cs
+++ b/src/libraries/System.Threading/tests/SemaphoreSlimTests.cs
@@ -72,7 +72,6 @@ public static void RunSemaphoreSlimTest1_Wait_NegativeCases()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91541", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public static void RunSemaphoreSlimTest1_WaitAsync()
{
// Infinite timeout
@@ -91,7 +90,6 @@ public static void RunSemaphoreSlimTest1_WaitAsync()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91541", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
public static void RunSemaphoreSlimTest1_WaitAsync_NegativeCases()
{
// Invalid timeout
@@ -464,7 +462,6 @@ private static void RunSemaphoreSlimTest7_AvailableWaitHandle_Helper(int initial
/// The final semaphore count
/// True if the test succeeded, false otherwise
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[InlineData(5, 1000, 50, 50, 50, 0, 5, 1000)]
[InlineData(0, 1000, 50, 25, 25, 25, 0, 500)]
[InlineData(0, 1000, 50, 0, 0, 50, 0, 100)]
@@ -531,7 +528,6 @@ public static void RunSemaphoreSlimTest8_ConcWaitAndRelease(int initial, int max
/// The final semaphore count
/// True if the test succeeded, false otherwise
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/91541", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))]
[InlineData(5, 1000, 50, 50, 50, 0, 5, 500)]
[InlineData(0, 1000, 50, 25, 25, 25, 0, 500)]
[InlineData(0, 1000, 50, 0, 0, 50, 0, 100)]
diff --git a/src/mono/sample/wasm/Directory.Build.targets b/src/mono/sample/wasm/Directory.Build.targets
index 13379588de89a..801e9d02089df 100644
--- a/src/mono/sample/wasm/Directory.Build.targets
+++ b/src/mono/sample/wasm/Directory.Build.targets
@@ -9,7 +9,7 @@
$([MSBuild]::NormalizePath('$(WasmAppDir)', '$(RunScriptOutputName)'))
- <_ServeHeaders Condition="'$(WasmEnableThreads)' == 'true'">$(_ServeHeaders) -h Cross-Origin-Embedder-Policy:require-corp -h Cross-Origin-Opener-Policy:same-origin
+ <_ServeHeaders>$(_ServeHeaders) -h Cross-Origin-Embedder-Policy:require-corp -h Cross-Origin-Opener-Policy:same-origin
<_ServeMimeTypes>$(_ServeMimeTypes) --mime .wasm=application/wasm
diff --git a/src/mono/sample/wasm/browser/main.js b/src/mono/sample/wasm/browser/main.js
index ba84cca682189..abf3b6caeef16 100644
--- a/src/mono/sample/wasm/browser/main.js
+++ b/src/mono/sample/wasm/browser/main.js
@@ -10,6 +10,7 @@ function displayMeaning(meaning) {
try {
const { setModuleImports } = await dotnet
.withElementOnExit()
+ .withSidecar(true)
.create();
setModuleImports("main.js", {
diff --git a/src/mono/wasm/runtime/dotnet.d.ts b/src/mono/wasm/runtime/dotnet.d.ts
index 5dde3a3e265ca..171d466f4e976 100644
--- a/src/mono/wasm/runtime/dotnet.d.ts
+++ b/src/mono/wasm/runtime/dotnet.d.ts
@@ -159,6 +159,10 @@ type MonoConfig = {
* If true, the snapshot of runtime's memory will be stored in the browser and used for faster startup next time. Default is false.
*/
startupMemoryCache?: boolean;
+ /**
+ * If true, the runtime will be initialized in separate web worker. Default is false. It requires COOP headers.
+ */
+ sidecar?: boolean;
/**
* If true, a list of the methods optimized by the interpreter will be saved and used for faster startup
* on future runs of the application
diff --git a/src/mono/wasm/runtime/loader/run.ts b/src/mono/wasm/runtime/loader/run.ts
index 9d26827a83f4a..966b0747618f3 100644
--- a/src/mono/wasm/runtime/loader/run.ts
+++ b/src/mono/wasm/runtime/loader/run.ts
@@ -17,6 +17,7 @@ import { init_globalization } from "./icu";
import { setupPreloadChannelToMainThread } from "./worker";
import { importLibraryInitializers, invokeLibraryInitializers } from "./libraryInitializers";
import { initCacheToUseIfEnabled } from "./assetsCache";
+import { SideCarMessageCreate, SideCarMessageType, dispatchToSideCar } from "./sidecar";
export class HostBuilder implements DotnetHostBuilder {
@@ -364,6 +365,18 @@ export class HostBuilder implements DotnetHostBuilder {
}
}
+ withSidecar(value: boolean): DotnetHostBuilder {
+ try {
+ deep_merge_config(monoConfig, {
+ sidecar: value
+ });
+ return this;
+ } catch (err) {
+ mono_exit(1, err);
+ throw err;
+ }
+ }
+
async create(): Promise {
try {
if (!this.instance) {
@@ -392,13 +405,21 @@ export class HostBuilder implements DotnetHostBuilder {
}
export async function createApi(): Promise {
- if (ENVIRONMENT_IS_WEB && (loaderHelpers.config! as MonoConfigInternal).forwardConsoleLogsToWS && typeof globalThis.WebSocket != "undefined") {
- setup_proxy_console("main", globalThis.console, globalThis.location.origin);
+ if (!monoConfig.sidecar) {
+ if (ENVIRONMENT_IS_WEB && (loaderHelpers.config! as MonoConfigInternal).forwardConsoleLogsToWS && typeof globalThis.WebSocket != "undefined") {
+ setup_proxy_console("main", globalThis.console, globalThis.location.origin);
+ }
+ mono_assert(emscriptenModule, "Null moduleConfig");
+ mono_assert(loaderHelpers.config, "Null moduleConfig.config");
+ await createEmscripten(emscriptenModule);
+ return globalObjectsRoot.api;
+ } else {
+ const createMessage: SideCarMessageCreate = {
+ type: SideCarMessageType.Create,
+ config: loaderHelpers.config!
+ };
+ return dispatchToSideCar(createMessage);
}
- mono_assert(emscriptenModule, "Null moduleConfig");
- mono_assert(loaderHelpers.config, "Null moduleConfig.config");
- await createEmscripten(emscriptenModule);
- return globalObjectsRoot.api;
}
export async function createEmscripten(moduleFactory: DotnetModuleConfig | ((api: RuntimeAPI) => DotnetModuleConfig)): Promise {
diff --git a/src/mono/wasm/runtime/loader/sidecar.ts b/src/mono/wasm/runtime/loader/sidecar.ts
new file mode 100644
index 0000000000000..116922b77ed7d
--- /dev/null
+++ b/src/mono/wasm/runtime/loader/sidecar.ts
@@ -0,0 +1,206 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+import type { PromiseController } from "../types/internal";
+
+import { MonoConfig } from "../types";
+import { mono_exit } from "./exit";
+import { HostBuilder } from "./run";
+import { mono_log_debug, mono_log_warn } from "./logging";
+import { dotnet } from ".";
+import { createPromiseController } from "./promise-controller";
+import { mono_assert } from "./globals";
+
+type TSideCarProxy = {
+ worker?: Worker;
+ promises: Map>;
+ nextPromiseId: number;
+}
+const sidecarProxy: TSideCarProxy = {
+ promises: new Map(),
+ nextPromiseId: 1
+};
+
+export async function dispatchToSideCar(message: SideCarMessage): Promise {
+ const { promise, promise_control } = createPromiseController();
+ message.promiseId = sidecarProxy.nextPromiseId++;
+ sidecarProxy.promises.set(message.promiseId, promise_control);
+ if (!sidecarProxy.worker) {
+ // start and wait for "ready" message
+ sidecarProxy.worker = new Worker(import.meta.url, { type: "module", name: "dotnet-side-car" });
+ sidecarProxy.worker.onmessage = domSideHandler;
+ const { promise: ready, promise_control: readyControl } = createPromiseController();
+ sidecarProxy.promises.set(-1, readyControl);
+ await ready;
+ }
+ sidecarProxy.worker.postMessage(message);
+ return promise;
+}
+
+function domSideHandler(e: MessageEvent) {
+ const message = e.data as SideCarMessage;
+ mono_log_debug(`Message from side car: ${e.data.type}`);
+ const promise_control = sidecarProxy.promises.get(message.promiseId!);
+ mono_assert(message.promiseId && promise_control, `Promise controller not found for: ${message}`);
+ switch (message.type) {
+ case SideCarMessageType.Ready:
+ promise_control.resolve(undefined);
+ break;
+ case SideCarMessageType.Response:
+ promise_control.resolve(message.response);
+ break;
+ case SideCarMessageType.Exit:
+ sidecarProxy.worker?.terminate();
+ mono_exit(message.exitCode);
+ promise_control.resolve(message.exitCode);
+ for (const promise of sidecarProxy.promises.values()) {
+ promise.reject("Side car exited with " + message.exitCode);
+ }
+ break;
+ case SideCarMessageType.Exception:
+ sidecarProxy.worker?.terminate();
+ mono_exit(-1, e.data.exception);
+ promise_control.reject(e.data.exitCode);
+ for (const promise of sidecarProxy.promises.values()) {
+ promise.reject(e.data.exception);
+ }
+ break;
+ default: {
+ const message = `Unexpected message from side car: ${e.data}`;
+ mono_log_warn(message);
+ promise_control.reject(new Error(message));
+ }
+ }
+}
+
+export async function sidecarHandler(e: MessageEvent) {
+ mono_log_debug(`Message from UI thread: ${e.data.type}`);
+ const message = e.data as SideCarMessage;
+ try {
+ switch (message.type) {
+ case SideCarMessageType.Create: {
+ await createSideCar(message);
+ break;
+ }
+ case SideCarMessageType.Run: {
+ await runSideCar(message);
+ break;
+ }
+ default:
+ mono_exit(-1, `Unexpected message from main thread: ${e.data}`);
+ }
+ } catch (exception: any) {
+ mono_log_warn("Exception while running side car", exception);
+ const exceptionMessage: SideCarMessageException = {
+ type: SideCarMessageType.Exception,
+ promiseId: message.promiseId,
+ exception: "" + exception
+ };
+ self.postMessage(exceptionMessage);
+ mono_exit(-1, exception);
+ }
+}
+
+const forwarderFunctions = [];
+function forwardApi(fun: Function): number {
+ const id = forwarderFunctions.length;
+ forwarderFunctions.push(fun);
+ return id;
+}
+
+type TSideCarApi = {
+ runMain: number;
+ runMainAndExit: number;
+}
+
+async function createSideCar(createMessage: SideCarMessageCreate) {
+ mono_log_debug("Creating side car");
+ try {
+ const dotnet = new HostBuilder();
+ const sidecarApi = await dotnet
+ .withConfig(createMessage.config)
+ .create();
+ const api = {
+ runtimeId: sidecarApi.runtimeId,
+ runtimeBuildInfo: sidecarApi.runtimeBuildInfo,
+ runMain: forwardApi(sidecarApi.runMain),
+ runMainAndExit: forwardApi(sidecarApi.runMainAndExit),
+ };
+ forwarderFunctions.push(sidecarApi.runMain);
+
+ const apiMessage: SideCarMessageResponse = {
+ type: SideCarMessageType.Response,
+ promiseId: createMessage.promiseId,
+ response: api
+ };
+ self.postMessage(apiMessage);
+ } catch (exception: any) {
+ mono_log_warn("Exception while creating side car", exception);
+ const message: SideCarMessageException = {
+ type: SideCarMessageType.Exception,
+ promiseId: createMessage.promiseId,
+ exception: "" + exception
+ };
+ self.postMessage(message);
+ mono_exit(-1, exception);
+ }
+}
+
+async function runSideCar(runMessage: SideCarMessageRun) {
+ mono_log_debug("Creating side car");
+ const exitCode = await dotnet.run();
+ const exitMessage: SideCarMessageExit = {
+ type: SideCarMessageType.Exit,
+ promiseId: runMessage.promiseId,
+ exitCode
+ };
+ self.postMessage(exitMessage);
+}
+
+export type SideCarMessage =
+ | SideCarMessageReady
+ | SideCarMessageCreate
+ | SideCarMessageResponse
+ | SideCarMessageRun
+ | SideCarMessageExit
+ | SideCarMessageException;
+
+export type SideCarMessageBase = {
+ promiseId?: number;
+}
+export type SideCarMessageReady = SideCarMessageBase & {
+ type: SideCarMessageType.Ready,
+}
+
+export type SideCarMessageCreate = SideCarMessageBase & {
+ type: SideCarMessageType.Create,
+ config: MonoConfig;
+}
+
+export type SideCarMessageResponse = SideCarMessageBase & {
+ type: SideCarMessageType.Response,
+ response: TResponse;
+}
+
+export type SideCarMessageRun = SideCarMessageBase & {
+ type: SideCarMessageType.Run,
+}
+
+export type SideCarMessageException = SideCarMessageBase & {
+ type: SideCarMessageType.Exception,
+ exception: string;
+}
+
+export type SideCarMessageExit = SideCarMessageBase & {
+ type: SideCarMessageType.Exit,
+ exitCode: number;
+}
+
+export const enum SideCarMessageType {
+ Ready = "dotnet-side-car-ready",
+ Create = "dotnet-side-car-create",
+ Response = "dotnet-side-car-response",
+ Run = "dotnet-side-car-run",
+ Exit = "dotnet-side-car-exit",
+ Exception = "dotnet-side-car-exception",
+}
\ No newline at end of file
diff --git a/src/mono/wasm/runtime/types/index.ts b/src/mono/wasm/runtime/types/index.ts
index 237d49d497160..111cdfbcfb7b1 100644
--- a/src/mono/wasm/runtime/types/index.ts
+++ b/src/mono/wasm/runtime/types/index.ts
@@ -93,6 +93,10 @@ export type MonoConfig = {
* If true, the snapshot of runtime's memory will be stored in the browser and used for faster startup next time. Default is false.
*/
startupMemoryCache?: boolean,
+ /**
+ * If true, the runtime will be initialized in separate web worker. Default is false. It requires COOP headers.
+ */
+ sidecar?: boolean,
/**
* If true, a list of the methods optimized by the interpreter will be saved and used for faster startup
* on future runs of the application
@@ -411,4 +415,4 @@ export type CreateDotnetRuntimeType = (moduleFactory: DotnetModuleConfig | ((api
// This type doesn't have to align with anything in BootConfig.
// Instead, this represents the public API through which certain aspects
// of boot resource loading can be customized.
-export type WebAssemblyBootResourceType = "assembly" | "pdb" | "dotnetjs" | "dotnetwasm" | "globalization" | "manifest" | "configuration";
+export type WebAssemblyBootResourceType = "assembly" | "pdb" | "dotnetjs" | "dotnetwasm" | "globalization" | "manifest" | "configuration";
\ No newline at end of file
diff --git a/src/mono/wasm/test-main.js b/src/mono/wasm/test-main.js
index 4467dc20ce204..6dce0789dfc41 100644
--- a/src/mono/wasm/test-main.js
+++ b/src/mono/wasm/test-main.js
@@ -151,6 +151,8 @@ function processArguments(incomingArguments, runArgs) {
runArgs.interpreterPgo = true;
} else if (currentArg == "--no-interpreter-pgo") {
runArgs.interpreterPgo = false;
+ } else if (currentArg == "--multithreaded") {
+ runArgs.sidecar = true;
} else if (currentArg.startsWith("--fetch-random-delay=")) {
const arg = currentArg.substring("--fetch-random-delay=".length);
if (ENVIRONMENT_IS_WEB) {
@@ -295,8 +297,12 @@ function configureRuntime(dotnet, runArgs) {
}
}
if (ENVIRONMENT_IS_WEB) {
- if (runArgs.memorySnapshot)
+ if (runArgs.memorySnapshot) {
dotnet.withStartupMemoryCache(true);
+ }
+ if (runArgs.sideCar) {
+ dotnet.withSideCar(true);
+ }
if (runArgs.interpreterPgo)
dotnet.withInterpreterPgo(true);
dotnet.withEnvironmentVariable("IsWebSocketSupported", "true");