-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
PopoverService: Fix DisposeAsync causing hangs on MAUI #5367
PopoverService: Fix DisposeAsync causing hangs on MAUI #5367
Conversation
Broadly speaking, JS interop being performed outside of a Blazor context is not a supported scenario for Blazor Hybrid. However, the bug here appears to be something bigger. Since Windows Forms controls must be disposed synchronously, Blazor Hybrid synchronously blocks on the task disposing the service scope. However, this ends up causing a deadlock when a service actually does something asynchronous on disposal (like JS interop). I was able to reproduce a similar hanging bug by reistering a dummy service that implements I'm going to start a discussion on the original thread in dotnet/maui#7997 about potential fixes for this. |
Despite the described issue, the reason I implemented That said, the functional difference between Hopefully, through the started discussion dotnet/maui#7997 we will know if |
@just-the-benno @Mr-Technician Looks like framework fix wont come until net8.0 |
Maybe there is a way to detect that we are running as Blazor Hybrid and just in that case refrain from awaiting? |
I like the idea @henon, but it might be hard to detect given that hybrid apps (at least the winforms ones) run under WebView, which is essentially Microsoft Edge under the hood. I'm not sure we can tell if a "real" browser is involved or not. |
Yeah. To be honest, I don't see a problem in either not waiting ( |
Maybe the Navigator in blazor gives info? |
@mikes-gh |
Maybe you can leave this choice to the developer, with a parameter like "IsBlazorHybrid" |
@cinderbear Sure, if you can give a good reason why. |
@henon The reason would be to alert MudBlazor of a hybrid environment to avoid awaiting a JS disposal indefinitely: #5367 (comment) However, handling the root issue of .AndForget() is probably best. |
Since this issue seems caused by subtle differences in the behavior of webview depending on the underliying platform (like this case that appears to affect winforms) it may be useful to have a parameter to differentiate this kind of usage, given that it's very difficult or impossible to detect automatically. But if you consider that the fix would not affect any other use cases, it may not be currently needed. |
@Mr-Technician how about UA
|
@mikes-gh Good lead, but unfortunately the UA isn't distinguishable from a normal browser:
|
…emove irrelevant test
Description
In Blazor hybrid environments, awaiting a JS interop call may cause the app to hang, such as in: dotnet/maui#7997
I have investigated in this repo and this PR resulted after discussing with @henon.
However, the unit test
MudPopoverService_DisposeAsync_ThrowsExceptionIfNotTaskCancelException
needs some work, so if @just-the-benno could take a look, that would be great.Resolves #6628.
How Has This Been Tested?
Unit tests still need work
Types of changes
Checklist:
dev
).