Closed AlmightyLks closed 2 years ago
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.
FYI @lewing
Tagging subscribers to 'arch-wasm': @lewing See info in area-owners.md if you want to be subscribed.
Author: | AlmightyLks |
---|---|
Assignees: | - |
Labels: | `arch-wasm`, `untriaged` |
Milestone: | - |
Duplicate of #61308
@marek-safar Mind me asking how this explains why it works with .net standard 2.1 and not with .net 6? I may bring this question over to the other issue if you will
Microsoft.CodeAnalysis.CSharp has different builds for NS2.0 and NETCORE3.1. It's quite possible that the implementation for NS2.0 is less optimized or different in another way but the general problem is the same. Most threading APIs are PNSE for browsers right now.
It may have different builds for .net core 3.1 & .net standard 2.0 https://github.com/dotnet/roslyn/blob/main/src/Compilers/CSharp/Portable/Microsoft.CodeAnalysis.CSharp.csproj#L8
However, all that WaitForWorkers()
does is calling .GetAwaiter().GetResult()
https://github.com/dotnet/roslyn/blob/315c2e149ba7889b0937d872274c33fcbfe9af5f/src/Compilers/CSharp/Portable/Compiler/ClsComplianceChecker.cs#L166-L178
I can't seem to find a target framework-dependent implementation on this within the roslyn compiler library, and this leads back to the standard library
Correct me if I am wrong here
@marek-safar it seems like @AlmightyLks is still looking for more information but a bot accidentally auto-closed this. Reopening!
Judging by this exception, this happens because there's a Task.Wait()
that blocks inside of Microsoft.CodeAnalysis.CSharp.ClsComplianceChecker.CheckCompliance
.
iirc WASM is single-threaded, so a Task.Wait()
that blocks would be a deadlock, right? If so, I think Blazor/WASM is working fine here, and you may need to call an async version of that method and/or file a bug in dotnet/roslyn.
If anyone runs into this particular issue, a quick workaround I found for the current Task.Wait() limitation while using Roslyn which doesn't involve changing the target framework to standard 2.1 is to set concurrentBuild: false
on the CSharpCompilationOptions when creating the compilation.
@AlmightyLks I didn't look that closely to find out what are the differences but it's possible that netstandard version has a different code path or configuration elsewhere.
Given that the current wasm runtime is single threaded, In the move to .NET6 we decided it was better to Fail all .Wait() calls than to have some fail seemingly randomly at runtime. Because of that change this is expected. I hope the workaround is sufficient. Closing
Describe the bug
For whatever reason, threading within Blazor WASM seemed to have "worked" in .NET Standard 2.1, but within .NET 6 it's (understandably) disallowed via a PlatformNotSupportedException? I do not have a clear explanation for this, which is why I ask for further help onto why this is. I have been trying to use the roslyn compiler with .NET 6, but it kept failing on me as I noticed someone else has got it to work with .NET Standard 2.1.
To Reproduce
I have created a very simple example of the exact same code for .NET Standard 2.1 vs .NET 6 Blazor WASM here: https://github.com/AlmightyLks/BlazorWasm You may fiddle with it yourself, as I appreciate any help for this.
As to how to simply reproduce:
Exceptions (if any)
Further technical details
Runtime Environment: OS Name: Windows OS Version: 10.0.19042 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.100\
Host (useful for support): Version: 6.0.0 Commit: 4822e3c3aa
.NET SDKs installed: 5.0.402 [C:\Program Files\dotnet\sdk] 6.0.100-preview.7.21379.14 [C:\Program Files\dotnet\sdk] 6.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed: Microsoft.AspNetCore.All 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.0-preview.7.21378.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.0-preview.7.21377.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.0-preview.7.21378.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]