-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blazor WASM Regression: Unhandled exception rendering component: Cannot wait on monitors on this runtime. #53228
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsDescribe the bugUsing Task.WaitAll was working on Blazor WASM 3.2.0 and is throwing an exception when using it on .Net 5.0. To ReproduceCreate a Blazor web assembly project for .Net Core 3.1 and use the following code:
It will execute correctly. Create a Blazor Web Assembly project for .NET 5 and use the same code it will throw an exception. Exceptions (if any)System.PlatformNotSupportedException: Cannot wait on monitors on this runtime. Further technical details
Runtime Environment: Host (useful for support): .NET SDKs installed: .NET runtimes installed:
|
Is there some reason you can't use |
We are reusing our code base for several platforms and different versions of the .NET Framework because our users sometimes use our library with some legacy software. That is why we are building with an old version of C#, where async and await are not supported. When .NET Standard was introduced, we ported our library to .NET Standard to distribute it for .NET Core, Xamarin, and Blazor. It was working correctly by now, but with .NET 5.0, it stopped working on Blazor WASM. That made our clients unhappy. I would love to use async-await, but we don't have much choice because of the legacy platforms we have to support. If we have to refactor our code to use async-await only for .NET Standard, it will become a mess. I was hoping you could return the old behavior because it was working. |
Tagging subscribers to this area: @CoffeeFlux Issue DetailsDescribe the bugUsing Task.WaitAll was working on Blazor WASM 3.2.0 and is throwing an exception when using it on .Net 5.0. To ReproduceCreate a Blazor web assembly project for .Net Core 3.1 and use the following code:
It will execute correctly. Create a Blazor Web Assembly project for .NET 5 and use the same code it will throw an exception. Exceptions (if any)System.PlatformNotSupportedException: Cannot wait on monitors on this runtime. Further technical details
Runtime Environment: Host (useful for support): .NET SDKs installed: .NET runtimes installed:
|
When you say 'Using Task.WaitAll was working on Blazor WASM 3.2.0' what do you mean? There's no way to synchronously block the browser while allowing background work to complete (they require you to stop executing and allow the event loop to run before some things will happen), so it's not obvious to me what it would have been doing before. Was it just not pausing, and allowing your app to continue? Did it wait for a little while and then move on? Your example doesn't do anything after waiting, so I can't use it to identify what behavior you're seeking here. |
Moving this to 7.0.0 : @lewing based on priority and scenario, and how risky the fix might be, we can consider backporting a fix if necessary. |
I have never dug deeper to see what was happening. It seems to me it was pausing, waiting for the tasks to complete, and then continue to execute the main program, otherwise, the application wouldn't provide the expected results. The code was working correctly on Blazor WASM 3.2.0. Maybe it was not executing the tasks in parallel, but at least it was not crashing. |
OK, if it was synchronously executing the tasks that makes some amount of sense. If those tasks were doing something like network communication though, it would still be broken - I'm guessing they were pure compute pushed onto the threadpool or with Task.Run? While we could "fix" this it would only be for a subset of use cases so it would help to know what kind of tasks you are trying to wait for in particular. |
It is just some heavy computation logic, no networking or other stuff. |
I don't think we'll be offering any special solutions for this in 7, because the exception is necessary to alert users to patterns that will not work. If you need assistance figuring out how to work around the constraint feel free to reply. In future releases you'll have the option of threads. |
Do you know when the threads will be implemented? Task.WaitAll(tasks); is a .NET Standard API, which means .NET Standard is not exactly a Standard. |
.NET Standard cannot promise the impossible. Were you to Task.WaitAll in any environment without threads (IOT perhaps), it would freeze. Thread support is already mostly implemented, but we have no timeline for when it will be complete enough to use in production applications - we still have to integrate it with Blazor. We will definitely make an announcement once it is available for general testing or if it is released in a preview. |
Describe the bug
Using Task.WaitAll was working on Blazor WASM 3.2.0 and is throwing an exception when using it on .Net 5.0.
To Reproduce
Create a Blazor web assembly project for .Net Core 3.1 and use the following code:
It will execute correctly.
Create a Blazor Web Assembly project for .NET 5 and use the same code it will throw an exception.
Exceptions (if any)
System.PlatformNotSupportedException: Cannot wait on monitors on this runtime.
at System.Threading.Monitor.ObjWait(Boolean exitContext, Int32 millisecondsTimeout, Object obj)
at System.Threading.Monitor.Wait(Object obj, Int32 millisecondsTimeout, Boolean exitContext)
at System.Threading.Monitor.Wait(Object obj, Int32 millisecondsTimeout)
at System.Threading.ManualResetEventSlim.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.WaitAllBlockingCore(List`1 tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.WaitAllCore(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.WaitAll(Task[] tasks)
Further technical details
dotnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.100-preview.2.21155.3
Commit: 1a9103db2d
Runtime Environment:
OS Name: Windows
OS Version: 10.0.18363
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.100-preview.2.21155.3\
Host (useful for support):
Version: 6.0.0-preview.2.21154.6
Commit: 3eaf1f3
.NET SDKs installed:
2.1.602 [C:\Program Files\dotnet\sdk]
2.1.604 [C:\Program Files\dotnet\sdk]
2.1.700 [C:\Program Files\dotnet\sdk]
2.1.701 [C:\Program Files\dotnet\sdk]
2.1.801 [C:\Program Files\dotnet\sdk]
2.2.203 [C:\Program Files\dotnet\sdk]
3.0.100-preview8-013656 [C:\Program Files\dotnet\sdk]
3.1.100 [C:\Program Files\dotnet\sdk]
3.1.101 [C:\Program Files\dotnet\sdk]
3.1.402 [C:\Program Files\dotnet\sdk]
5.0.100 [C:\Program Files\dotnet\sdk]
5.0.200-preview.21077.7 [C:\Program Files\dotnet\sdk]
5.0.201 [C:\Program Files\dotnet\sdk]
5.0.202 [C:\Program Files\dotnet\sdk]
6.0.100-preview.2.21155.3 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview8.19405.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.0-preview.2.21154.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.0-preview.2.21154.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.0-preview.2.21154.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft VIsual Studio Professional 2019 Version 16.9.4
The text was updated successfully, but these errors were encountered: