-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
DisposeAsync() on IJSObjectReference causes hanging when called on Android 11 and lower on app suspension #13529
Comments
Note, this issue affects most major Blazor libraries, including MudBlazor and Blazorise |
Any comments from Microsoft side what causing this issue?
To my knowledge, I'm wondering if author considered trying the new API |
@ScarletKuro From my investigations this is an Android lifecycle issue. Scopes are only ended when the app is resumed, not when it's closed. By then, the WebView itself is likely already disposed or otherwise made so that the IpcSender can't actually reach it, so the dispose calls hang. Since this doesn't throw an exception, I assume the WebView is only partially cleaned up but a handle still exists which returns a noop without a callback to notify the IpcSender that the message has been successfully sent. |
Verified this on Visual Studio Enterprise 17.7.0 Preview 2.0. This issue does not repro on Android 13.0-API33, repro on Android 11.0-API30 with below Project: |
Description
On Android 11 and lower, the back button on the home page has different behaviour from the home button - it finishes the current activity. This was changed on Android 12 (see this page), however on earlier versions, this results in a different behaviour.
This, however, means that pressing back, then re-opening the app causes Blazor to dispose of resources during app initialization when the app has re-opened. This means the WebView has already been disposed of, or not yet initialized - I'm not quite sure which one. This causes any
DisposeAsync()
calls againstIJSObjectReference
objects to hang synchronously.Steps to Reproduce
wwwroot
Transient
orScoped
LoadModuleAsync()
LoadModuleAsync()
is called. Note: Any other JS invoke function could work so long as we're left with anIJSObjectReference
Link to public reproduction project repository
https://github.com/kanadaj/MauiHangRepro
Version with bug
7.0 (current)
Last version that worked well
7.0 (current)
Affected platforms
Android
Affected platform versions
Android 11 and down
Did you find any workaround?
The only workaround we've found is tying
IJSObjectReference
lifecycle to their holding component if they aren't on the home page. No idea about the home page. This also breaks most existing Blazor libraries on Android 11 and under.Relevant log output
No response
The text was updated successfully, but these errors were encountered: