Skip to content
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

Prevent app crash if MAUI View becomes null #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

milanio
Copy link

@milanio milanio commented Feb 28, 2024

We are experiencing System.InvalidOperationException: VirtualView cannot be null here from time to time on Android. Stacktrace:

Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IWebView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Android.Webkit.WebView, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].get_VirtualView()
HybridWebView.AndroidHybridWebViewClient.ShouldInterceptRequest(WebView view, IWebResourceRequest request)
Android.Webkit.WebViewClient.n_ShouldInterceptRequest_Landroid_webkit_WebView_Landroid_webkit_WebResourceRequest_(IntPtr jnienv, IntPtr native__this, IntPtr native_view, IntPtr native_request)
Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLL_L(_JniMarshal_PPLL_L callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1)

This would suggest that Android WebView lives longer that MAUI control and tries to download something. This PR just encapsulates relevant code into a try/catch block and returns '500 - Internal Server Error'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant