Eilon / MauiHybridWebView

MIT License
216 stars 48 forks source link

Hybrid web view is blank after updating to iOS 18 #84

Closed mtanml closed 3 weeks ago

mtanml commented 1 month ago

This worked great for us until users started updating to iOS 18, after which the webview is just a blank white box. I'm having a hard time troubleshooting... the debugger doesn't show anything. Any suggestions? Thanks

HelloooJoe commented 1 month ago

Troubleshooting Blank White Box Issue in .NET MAUI HybridWebView on iOS 18

1. Check WebView Permissions

Starting with recent iOS versions, some WebView functionalities might require explicit permissions for things like local file access or network requests.

Example:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

2. Enable WebView Debugging

If the debugger isn't showing anything, enable WebView debugging via Safari:

3. Check for CORS or Proxy Changes

iOS 18 might have introduced stricter CORS (Cross-Origin Resource Sharing) policies or network restrictions. If you're using the ProxyRequestReceived event to load content dynamically, ensure that the responses are properly configured to include any necessary CORS headers.

args.ResponseHeaders.Add("Access-Control-Allow-Origin", "*");

4. Check for Deprecation or Changes in WebView API

Review the iOS 18 release notes for any WebView or WKWebView deprecations or changes. Apple might have updated the default behavior of WebView controls. If there are deprecated APIs, you might need to update your WebView or its configuration accordingly.

5. Verify if JavaScript is Enabled

Ensure that JavaScript is enabled in your HybridWebView if you're relying on JS functionality. It's possible that this setting was reset or changed in iOS 18.

myHybridWebView.EnableJavascript = true;

6. Check Asset Bundling

iOS updates might affect how local assets (HTML, CSS, JS) are bundled and accessed. Double-check that the assets are being properly included in your app build and that the paths set in HybridAssetRoot and MainFile still point to the correct resources.

7. Fallback to WKWebView

If the HybridWebView control continues to show issues, you could try falling back to using a standard WKWebView directly. This can help rule out if the issue is with the HybridWebView implementation or with the underlying WebKit framework on iOS 18.

8. Rebuild Web Content

Sometimes, web content might not load properly due to minor version incompatibilities in the web engine. Rebuild your web content (e.g., React app) and ensure that it uses updated dependencies.

9. Review MAUI/HybridWebView Version

Ensure that you're using the latest version of the EJL.MauiHybridWebView package or any MAUI version that is compatible with iOS 18. Check for any available updates or known issues regarding iOS 18 in the package repository.

10. Test with Minimal Content

Create a simple HTML page (just basic HTML, no JS) and see if it loads properly in the HybridWebView. If it does, then the issue might be with your JavaScript or other dynamic content.

mtanml commented 1 month ago

@HelloooJoe thank you for your very fast response. Unfortunately I'm having some issues with your suggestions:

beethmon commented 1 month ago

@HelloooJoe thank you for your very fast response. Unfortunately I'm having some issues with your suggestions:

  • I'm not sure how WebView debugging works with the iOS Simulator
  • I can't find the property myHybridWebView.EnableJavascript

hello,

I suspect the root of the problem lies in Apple blocking requests from 0.0.0.0. You need to download the library files and compile them yourself to use a different address, such as localhost.

This works for me, and I hope it can help you as well. {3012A79A-329F-4f73-B9B3-7D15FBD16AAB}

mtanml commented 1 month ago

@beethmon thank you!

@Eilon are there any plans to update the library?

Eilon commented 1 month ago

Hi yes this is a known bug that is fixed in the .NET MAUI official version.

mtanml commented 1 month ago

@Eilon but it's only available in .NET 9 pre-release, right? My boss won't go for that. We'd rather continue using your solution for now. Possible to update it?

Eilon commented 1 month ago

Yes I'll look into it

mtanml commented 1 month ago

@Eilon you're a rockstar, thank you!

Eilon commented 3 weeks ago

Dupe of #78