MobileBlazorBindings icon indicating copy to clipboard operation
MobileBlazorBindings copied to clipboard

ObjectDisposedException is throwing after closing Blazor WebView on Android

Open tabachuk opened this issue 3 years ago • 6 comments

Hello! System.ObjectDisposedException is throwing in several seconds after I tap back button and moving to the previous page. Important that it only occurs when I tap back button during Blazor is doing some work. I guess it happens because Blazor tried to render the page, but WebView is already closed. What can I do in order to avoid this issue? Thanks a lot!

image

tabachuk avatar Apr 08 '21 13:04 tabachuk

This definitely looks like a bug. You're using the "physical" back button (the triangle at the bottom) to go back?

Eilon avatar Apr 12 '21 23:04 Eilon

Yes, I am.

tabachuk avatar Apr 16 '21 12:04 tabachuk

After update some nuggets this error seems to be solved for me. I can do a pull request if it could help. https://github.com/Jon2G/MobileBlazorBindings

Jon2G avatar Aug 24 '21 01:08 Jon2G

I'm getting the same error after the app goes to the background, resumes and someone tries to use a button, more specific to navigate to another page using the navigation manager.

Seems like xamarin can't restore the webview's previous state. Any ideas? I was thinking of completely killing the process so it can create a new instance but i still can't put that to test... Not to mention that i understand iOS doesn't allow killing your own process.

ezesil avatar Dec 02 '21 22:12 ezesil

@ezesil Maybe we can try now with MAUI support for RazorWebView? I mean I know it's on preview but I can give it a try and see how it works now.

Jon2G avatar Dec 03 '21 02:12 Jon2G

@Jon2G I tried MAUI but for some reason i couldn't get the navigation manager to work unfortunately... Maybe i used an outdated template? Anyways, I managed to find a workaround by simply adding "return;" to an overrided OnSaveInstanceState on the android project --> MainActivity.cs instead of handling the bundle. For some reason it works flawlessly... Could be that returning that event making it not call base.OnSaveInstanceState makes android handle the pause and background states properly? It's counter-intuitive haha.

As a side topic, is MBB capable of loading bootstrap's javascript to visually change the DOM once? I can't seem to find how honestly... MAUI does load them properly!

Edit: typo

ezesil avatar Dec 03 '21 16:12 ezesil