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

HybridWebView ArgumentNullException when using HtmlWebViewSource instead of file #68

Closed
hansmbakker opened this issue Jun 19, 2024 · 4 comments

Comments

@hansmbakker
Copy link

WebView supports setting its Source property to a HtmlWebViewSource object.

Expected behavior:
Since HybridWebView derives from WebView, it is expected that HybridWebView also supports this.

Actual behavior:
However, when doing that (and not specifying a html source file, the app crashes.

Stacktrace:

[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentNullException: Value cannot be null. (Parameter 'path1')
[mono-rt]    at System.ArgumentNullException.Throw(String paramName)
[mono-rt]    at System.ArgumentNullException.ThrowIfNull(Object argument, String paramName)
[mono-rt]    at System.IO.Path.Combine(String path1, String path2)
[mono-rt]    at HybridWebView.AndroidHybridWebViewClient.ShouldInterceptRequest(WebView view, IWebResourceRequest request)
[mono-rt]    at Android.Webkit.WebViewClient.n_ShouldInterceptRequest_Landroid_webkit_WebView_Landroid_webkit_WebResourceRequest_(IntPtr jnienv, IntPtr native__this, IntPtr native_view, IntPtr native_request) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net8.0/android-34/mcw/Android.Webkit.WebViewClient.cs:line 801
[mono-rt]    at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLL_L(_JniMarshal_PPLL_L callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 231
@Eilon
Copy link
Owner

Eilon commented Jun 19, 2024

Hi, the official HybridWebView (work in progress PR here) won't support WebViewSources at all because it serves up only static files that are "Raw MAUI Assets". This worked in the prototype in this repo only because for simplicity the HybridWebView control derived from the regular WebView, so it inherited various APIs that it didn't really support at all.

As such, I am closing this issue because it wasn't really meant to work to begin with.

@Eilon Eilon closed this as not planned Won't fix, can't repro, duplicate, stale Jun 19, 2024
@hansmbakker
Copy link
Author

Is it possible to turn this into a feature request? What's the downside of supporting a string-based source?

@Eilon
Copy link
Owner

Eilon commented Jul 23, 2024

Is it possible to turn this into a feature request? What's the downside of supporting a string-based source?

Yeah go ahead and log an issue in the MAUI repo describing the scenario and what code you'd like to be able to write. I definitely like the idea of 'not having files on disk' for some of the content, but I have some various ideas on how to implement it.

@hansmbakker
Copy link
Author

Done, created dotnet/maui#23908

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

No branches or pull requests

2 participants