Skip to content

Commit 771afaf

Browse files
authored
[browser][MT] deputy thread (#98118)
1 parent 8ec001d commit 771afaf

File tree

41 files changed

+607
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+607
-154
lines changed

eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml

+12-11
Original file line numberDiff line numberDiff line change
@@ -290,17 +290,18 @@ jobs:
290290
# ff tests are unstable currently
291291
shouldContinueOnError: true
292292

293-
- template: /eng/pipelines/common/templates/wasm-debugger-tests.yml
294-
parameters:
295-
platforms:
296-
- Browser_wasm
297-
- Browser_wasm_win
298-
extraBuildArgs: /p:WasmEnableThreads=true /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS)
299-
nameSuffix: DebuggerTests_MultiThreaded
300-
alwaysRun: ${{ parameters.isWasmOnlyBuild }}
301-
isExtraPlatformsBuild: ${{ parameters.isExtraPlatformsBuild }}
302-
isWasmOnlyBuild: ${{ parameters.isWasmOnlyBuild }}
303-
runOnlyOnWasmOnlyPipelines: true
293+
# Active Issue https://github.com/dotnet/runtime/issues/98771
294+
# - template: /eng/pipelines/common/templates/wasm-debugger-tests.yml
295+
# parameters:
296+
# platforms:
297+
# - Browser_wasm
298+
# - Browser_wasm_win
299+
# extraBuildArgs: /p:WasmEnableThreads=true /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS)
300+
# nameSuffix: DebuggerTests_MultiThreaded
301+
# alwaysRun: ${{ parameters.isWasmOnlyBuild }}
302+
# isExtraPlatformsBuild: ${{ parameters.isExtraPlatformsBuild }}
303+
# isWasmOnlyBuild: ${{ parameters.isWasmOnlyBuild }}
304+
# runOnlyOnWasmOnlyPipelines: true
304305

305306
# Disable for now
306307
#- template: /eng/pipelines/coreclr/perf-wasm-jobs.yml

eng/testing/tests.browser.targets

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989

9090
<_XUnitBackgroundExec Condition="'$(_XUnitBackgroundExec)' == '' and '$(WasmEnableThreads)' == 'true'">true</_XUnitBackgroundExec>
9191
<WasmTestAppArgs Condition="'$(_XUnitBackgroundExec)' == 'true'">$(WasmTestAppArgs) -backgroundExec</WasmTestAppArgs>
92+
<WasmXHarnessMonoArgs Condition="'$(_XUnitBackgroundExec)' == 'true'">$(WasmXHarnessMonoArgs) --setenv=IsWasmBackgroundExec=true</WasmXHarnessMonoArgs>
9293
<_AppArgs Condition="'$(WasmTestAppArgs)' != ''">$(_AppArgs) $(WasmTestAppArgs)</_AppArgs>
9394

9495
<WasmXHarnessMonoArgs Condition="'$(XunitShowProgress)' == 'true'">$(WasmXHarnessMonoArgs) --setenv=XHARNESS_LOG_TEST_START=true</WasmXHarnessMonoArgs>

src/libraries/Common/src/Interop/Browser/Interop.Runtime.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ internal static unsafe partial class Runtime
4242

4343
#if FEATURE_WASM_MANAGED_THREADS
4444
[MethodImpl(MethodImplOptions.InternalCall)]
45-
public static extern void InstallWebWorkerInterop(nint proxyContextGCHandle);
45+
public static extern void InstallWebWorkerInterop(nint proxyContextGCHandle, void* beforeSyncJSImport, void* afterSyncJSImport);
4646
[MethodImpl(MethodImplOptions.InternalCall)]
4747
public static extern void UninstallWebWorkerInterop();
4848

src/libraries/Common/tests/System/TimeProviderTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ private static void CancelAfter(TimeProvider provider, CancellationTokenSource c
214214
}
215215
#endif // NETFRAMEWORK
216216

217-
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
217+
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
218218
[MemberData(nameof(TimersProvidersListData))]
219219
public static void CancellationTokenSourceWithTimer(TimeProvider provider)
220220
{

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs

+3
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ public static int SlowRuntimeTimeoutModifier
135135
public static bool IsThreadingSupported => (!IsWasi && !IsBrowser) || IsWasmThreadingSupported;
136136
public static bool IsWasmThreadingSupported => IsBrowser && IsEnvironmentVariableTrue("IsBrowserThreadingSupported");
137137
public static bool IsNotWasmThreadingSupported => !IsWasmThreadingSupported;
138+
public static bool IsWasmBackgroundExec => IsBrowser && IsEnvironmentVariableTrue("IsWasmBackgroundExec");
139+
public static bool IsWasmBackgroundExecOrSingleThread => IsWasmBackgroundExec || IsNotWasmThreadingSupported;
140+
public static bool IsThreadingSupportedOrBrowserBackgroundExec => IsWasmBackgroundExec || !IsBrowser;
138141
public static bool IsBinaryFormatterSupported => IsNotMobile && !IsNativeAot;
139142

140143
public static bool IsStartingProcessesSupported => !IsiOS && !IstvOS;

src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceLookup/CallSiteFactoryTest.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ public void CreateCallSite_EnumberableCachedAtLowestLevel(ServiceDescriptor[] de
792792
Assert.Equal(typeof(IEnumerable<FakeService>), callSite.Cache.Key.ServiceIdentifier.ServiceType);
793793
}
794794

795-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
795+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
796796
public void CallSitesAreUniquePerServiceTypeAndSlot()
797797
{
798798
// Connected graph
@@ -828,7 +828,7 @@ public void CallSitesAreUniquePerServiceTypeAndSlot()
828828
}
829829
}
830830

831-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
831+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
832832
public void CallSitesAreUniquePerServiceTypeAndSlotWithOpenGenericInGraph()
833833
{
834834
// Connected graph

src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceProviderContainerTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public void GetService_DisposeOnSameThread_Throws()
371371
});
372372
}
373373

374-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
374+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
375375
public void GetAsyncService_DisposeAsyncOnSameThread_ThrowsAndDoesNotHangAndDisposeAsyncGetsCalled()
376376
{
377377
// Arrange
@@ -398,7 +398,7 @@ public void GetAsyncService_DisposeAsyncOnSameThread_ThrowsAndDoesNotHangAndDisp
398398
Assert.True(asyncDisposableResource.DisposeAsyncCalled);
399399
}
400400

401-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
401+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
402402
public void GetService_DisposeOnSameThread_ThrowsAndDoesNotHangAndDisposeGetsCalled()
403403
{
404404
// Arrange

src/libraries/Microsoft.Extensions.HostFactoryResolver/tests/HostFactoryResolverTests.cs

+22-22
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void BuildWebHostPattern_CanFindServiceProvider()
3737
Assert.IsAssignableFrom<IServiceProvider>(factory(Array.Empty<string>()));
3838
}
3939

40-
[Fact]
40+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
4141
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(BuildWebHostInvalidSignature.Program))]
4242
public void BuildWebHostPattern__Invalid_CantFindWebHost()
4343
{
@@ -46,7 +46,7 @@ public void BuildWebHostPattern__Invalid_CantFindWebHost()
4646
Assert.Null(factory);
4747
}
4848

49-
[Fact]
49+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
5050
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(BuildWebHostInvalidSignature.Program))]
5151
public void BuildWebHostPattern__Invalid_CantFindServiceProvider()
5252
{
@@ -55,7 +55,7 @@ public void BuildWebHostPattern__Invalid_CantFindServiceProvider()
5555
Assert.NotNull(factory);
5656
}
5757

58-
[Fact]
58+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
5959
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(CreateWebHostBuilderPatternTestSite.Program))]
6060
public void CreateWebHostBuilderPattern_CanFindWebHostBuilder()
6161
{
@@ -65,7 +65,7 @@ public void CreateWebHostBuilderPattern_CanFindWebHostBuilder()
6565
Assert.IsAssignableFrom<IWebHostBuilder>(factory(Array.Empty<string>()));
6666
}
6767

68-
[Fact]
68+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
6969
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(CreateWebHostBuilderPatternTestSite.Program))]
7070
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(IWebHost))]
7171
public void CreateWebHostBuilderPattern_CanFindServiceProvider()
@@ -76,7 +76,7 @@ public void CreateWebHostBuilderPattern_CanFindServiceProvider()
7676
Assert.IsAssignableFrom<IServiceProvider>(factory(Array.Empty<string>()));
7777
}
7878

79-
[Fact]
79+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
8080
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(CreateWebHostBuilderInvalidSignature.Program))]
8181
public void CreateWebHostBuilderPattern__Invalid_CantFindWebHostBuilder()
8282
{
@@ -85,7 +85,7 @@ public void CreateWebHostBuilderPattern__Invalid_CantFindWebHostBuilder()
8585
Assert.Null(factory);
8686
}
8787

88-
[Fact]
88+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
8989
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(CreateWebHostBuilderInvalidSignature.Program))]
9090
public void CreateWebHostBuilderPattern__InvalidReturnType_CanFindServiceProvider()
9191
{
@@ -95,7 +95,7 @@ public void CreateWebHostBuilderPattern__InvalidReturnType_CanFindServiceProvide
9595
Assert.Null(factory(Array.Empty<string>()));
9696
}
9797

98-
[Fact]
98+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
9999
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(CreateHostBuilderPatternTestSite.Program))]
100100
public void CreateHostBuilderPattern_CanFindHostBuilder()
101101
{
@@ -105,7 +105,7 @@ public void CreateHostBuilderPattern_CanFindHostBuilder()
105105
Assert.IsAssignableFrom<IHostBuilder>(factory(Array.Empty<string>()));
106106
}
107107

108-
[Fact]
108+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
109109
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(CreateHostBuilderPatternTestSite.Program))]
110110
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(Host))]
111111
public void CreateHostBuilderPattern_CanFindServiceProvider()
@@ -116,7 +116,7 @@ public void CreateHostBuilderPattern_CanFindServiceProvider()
116116
Assert.IsAssignableFrom<IServiceProvider>(factory(Array.Empty<string>()));
117117
}
118118

119-
[Fact]
119+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
120120
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(CreateHostBuilderInvalidSignature.Program))]
121121
public void CreateHostBuilderPattern__Invalid_CantFindHostBuilder()
122122
{
@@ -125,7 +125,7 @@ public void CreateHostBuilderPattern__Invalid_CantFindHostBuilder()
125125
Assert.Null(factory);
126126
}
127127

128-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
128+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
129129
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(CreateHostBuilderInvalidSignature.Program))]
130130
public void CreateHostBuilderPattern__Invalid_CantFindServiceProvider()
131131
{
@@ -135,7 +135,7 @@ public void CreateHostBuilderPattern__Invalid_CantFindServiceProvider()
135135
Assert.Throws<InvalidOperationException>(() => factory(Array.Empty<string>()));
136136
}
137137

138-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
138+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
139139
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(NoSpecialEntryPointPattern.Program))]
140140
public void NoSpecialEntryPointPattern()
141141
{
@@ -145,7 +145,7 @@ public void NoSpecialEntryPointPattern()
145145
Assert.IsAssignableFrom<IServiceProvider>(factory(Array.Empty<string>()));
146146
}
147147

148-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
148+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
149149
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(NoSpecialEntryPointPattern.Program))]
150150
public void NoSpecialEntryPointPatternHostBuilderConfigureHostBuilderCallbackIsCalled()
151151
{
@@ -163,7 +163,7 @@ void ConfigureHostBuilder(object hostBuilder)
163163
Assert.True(called);
164164
}
165165

166-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
166+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
167167
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(NoSpecialEntryPointPattern.Program))]
168168
public void NoSpecialEntryPointPatternBuildsThenThrowsCallsEntryPointCompletedCallback()
169169
{
@@ -183,7 +183,7 @@ void EntryPointCompleted(Exception? exception)
183183
Assert.Null(entryPointException);
184184
}
185185

186-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
186+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
187187
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(NoSpecialEntryPointPatternBuildsThenThrows.Program))]
188188
public void NoSpecialEntryPointPatternBuildsThenThrowsCallsEntryPointCompletedCallbackWithException()
189189
{
@@ -203,7 +203,7 @@ void EntryPointCompleted(Exception? exception)
203203
Assert.NotNull(entryPointException);
204204
}
205205

206-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
206+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
207207
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(NoSpecialEntryPointPatternThrows.Program))]
208208
public void NoSpecialEntryPointPatternThrows()
209209
{
@@ -213,7 +213,7 @@ public void NoSpecialEntryPointPatternThrows()
213213
Assert.Throws<Exception>(() => factory(Array.Empty<string>()));
214214
}
215215

216-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
216+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
217217
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(NoSpecialEntryPointPatternExits.Program))]
218218
public void NoSpecialEntryPointPatternExits()
219219
{
@@ -223,7 +223,7 @@ public void NoSpecialEntryPointPatternExits()
223223
Assert.Throws<InvalidOperationException>(() => factory(Array.Empty<string>()));
224224
}
225225

226-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
226+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
227227
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(NoSpecialEntryPointPatternHangs.Program))]
228228
public void NoSpecialEntryPointPatternHangs()
229229
{
@@ -233,7 +233,7 @@ public void NoSpecialEntryPointPatternHangs()
233233
Assert.Throws<InvalidOperationException>(() => factory(Array.Empty<string>()));
234234
}
235235

236-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
236+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
237237
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(NoSpecialEntryPointPatternMainNoArgs.Program))]
238238
public void NoSpecialEntryPointPatternMainNoArgs()
239239
{
@@ -243,7 +243,7 @@ public void NoSpecialEntryPointPatternMainNoArgs()
243243
Assert.IsAssignableFrom<IServiceProvider>(factory(Array.Empty<string>()));
244244
}
245245

246-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
246+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
247247
[DynamicDependency(DynamicallyAccessedMemberTypes.All, "Program", "TopLevelStatements")]
248248
public void TopLevelStatements()
249249
{
@@ -254,7 +254,7 @@ public void TopLevelStatements()
254254
Assert.IsAssignableFrom<IServiceProvider>(factory(Array.Empty<string>()));
255255
}
256256

257-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
257+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
258258
[DynamicDependency(DynamicallyAccessedMemberTypes.All, "Program", "TopLevelStatementsTestsTimeout")]
259259
public void TopLevelStatementsTestsTimeout()
260260
{
@@ -265,7 +265,7 @@ public void TopLevelStatementsTestsTimeout()
265265
Assert.Throws<InvalidOperationException>(() => factory(Array.Empty<string>()));
266266
}
267267

268-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
268+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
269269
[DynamicDependency(DynamicallyAccessedMemberTypes.All, "Program", "ApplicationNameSetFromArgument")]
270270
public void ApplicationNameSetFromArgument()
271271
{
@@ -277,7 +277,7 @@ public void ApplicationNameSetFromArgument()
277277
Assert.Contains("ApplicationNameSetFromArgument", configuration["applicationName"]);
278278
}
279279

280-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
280+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec))]
281281
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(NoSpecialEntryPointPattern.Program))]
282282
public void NoSpecialEntryPointPatternCanRunInParallel()
283283
{

src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/DependencyInjection/HttpClientFactoryServiceCollectionExtensionsTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ public async Task AddHttpClient_MessageHandler_Scope_TransientDependency()
12031203
}
12041204
}
12051205

1206-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported), nameof(PlatformDetection.IsReflectionEmitSupported))]
1206+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupportedOrBrowserBackgroundExec), nameof(PlatformDetection.IsReflectionEmitSupported))]
12071207
public void AddHttpClient_GetAwaiterAndResult_InSingleThreadedSynchronizationContext_ShouldNotHangs()
12081208
{
12091209
// Arrange

0 commit comments

Comments
 (0)