Open cgranade opened 3 years ago
@cgranade I also started building a WebAssembly playground for Q# but ran into a different issue. The one your reported here no longer happens on .NET 5.0 RC2 but there is now a new one, further down
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Cannot wait on monitors on this runtime.
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.SpinThenBlockingWait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.InternalWaitCore(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.InternalWait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at Microsoft.Quantum.QsCompiler.CompilationBuilder.ProcessingQueue.QueueForExecution[Compilation](Func`1 execute, Compilation& result)
at Microsoft.Quantum.QsCompiler.CompilationBuilder.CompilationUnitManager.FlushAndExecute[Compilation](Func`1 execute)
at Microsoft.Quantum.QsCompiler.CompilationBuilder.CompilationUnitManager.Build()
at Microsoft.Quantum.QsCompiler.CompilationLoader..ctor(SourceLoader loadSources, ReferenceLoader loadReferences, Nullable`1 options, ILogger logger)
at Strathweb.Samples.BlazorQSharpInteractive.Pages.Compile.RunQSharp(String sourceCode)
at Strathweb.Samples.BlazorQSharpInteractive.Pages.Compile.<BuildRenderTree>b__0_1()
at Microsoft.AspNetCore.Components.EventCallbackWorkItem.InvokeAsync[Object](MulticastDelegate delegate, Object arg)
at Microsoft.AspNetCore.Components.EventCallbackWorkItem.InvokeAsync(Object arg)
at Microsoft.AspNetCore.Components.ComponentBase.Microsoft.AspNetCore.Components.IHandleEvent.HandleEventAsync(EventCallbackWorkItem callback, Object arg)
at Microsoft.AspNetCore.Components.EventCallback.InvokeAsync(Object arg)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.DispatchEventAsync(UInt64 eventHandlerId, EventFieldInfo fieldInfo, EventArgs eventArgs)
This is caused by doing sync over async here https://github.com/microsoft/qsharp-compiler/blob/edc3d1557d62dc3cf1175caf6386e78aee91eb03/src/QsCompiler/CompilationManager/CompilationUnitManager.cs#L505.
I already provided feedback a while ago to @bettinaheim that it would be good to get rid of blocking calls and have a fully async compiler API - this will be another reason why it's needed 😀
@filipw Do you have a suggestion for the concrete case here? If I remember correctly, the runSynchonously is used only to enable a flush that guarantees that all processing that is currently queued finishes before a certain action is performed.
In case anyone is interested in looking into this, the feature/allow-disable-parallel
branch has some partial progress towards resolving this issue, as discussed at #744.
Describe the bug
When calling the
CompilationLoader
constructor from a Blazor WebAssembly project, an incomplete task is disposed internal to the constructor, causing an exception to propagate out to the Blazor runtime.To Reproduce
Add the following Razor page to a Blazor WebAssembly project, then navigate to
/compile
in a browser and press "Compile."Expected behavior
Expected the call to
CompilationLoader
to complete without error, but the following exception is printed to the browser console log instead:System information
Additional context