-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Maui iOS failing to load local resources in using WebView Source #10674
Copy link
Copy link
Closed
Labels
area-controls-webviewWebViewWebViewfixed-in-7.0.100fixed-in-7.0.101fixed-in-7.0.58Look for this fix in 7.0.58!Look for this fix in 7.0.58!fixed-in-8.0.0-preview.1.7762Look for this fix in 8.0.0-preview.1.7762!Look for this fix in 8.0.0-preview.1.7762!platform/iost/bugSomething isn't workingSomething isn't working
Milestone
Description
Description
I would like to load local html content in a WebView. Assuming the file was named data.html and was packaged correctly then
<WebView Source="data.html" />
works on windows and android however it fails on iOS with a uri format exception.
This appears to be because the windows and android versions handle relative uri paths while the iOS one does not.
Windows:
| uri = new Uri(LocalScheme + url, UriKind.RelativeOrAbsolute); |
Android:
| url = AssetBaseUrl + url; |
The iOS one does a new Uri() directly which will fail if the uri is not an absolute path.
| var uri = new Uri(url ?? string.Empty); |
Thus that line throws an exceptions which kills the application.
0x88 in System.Uri.CreateThis C#
0x21 in System.Uri..ctor C#
0x62 in Microsoft.Maui.Platform.MauiWKWebView.LoadUrl C#
0x7 in Microsoft.Maui.Controls.UrlWebViewSource.Load C#
0x10 in Microsoft.Maui.Platform.WebViewExtensions.UpdateSource C#
0x19 in Microsoft.Maui.Handlers.WebViewHandler.MapSource C#
0x21 in Microsoft.Maui.PropertyMapper<Microsoft.Maui.IWebView,Microsoft.Maui.Handlers.IWebViewHandler>. C#
0x18 in Microsoft.Maui.PropertyMapper.UpdatePropertyCore C#
0x1D in Microsoft.Maui.PropertyMapper.UpdateProperties C#
0xCB in Microsoft.Maui.Handlers.ElementHandler.SetVirtualView C#
0x2 in Microsoft.Maui.Handlers.ViewHandler<Microsoft.Maui.IWebView,WebKit.WKWebView>.SetVirtualView C#
0x7 in Microsoft.Maui.Handlers.ViewHandler<Microsoft.Maui.IWebView,WebKit.WKWebView>.SetVirtualView C#
0x65 in Microsoft.Maui.Controls.Element.SetHandler C#
0x2 in Microsoft.Maui.Controls.Element.set_Handler C#
0x18 in Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler C#
0xB0 in Microsoft.Maui.Platform.ElementExtensions.ToHandler C#
0x2 in Microsoft.Maui.Platform.ElementExtensions.ToPlatform C#
0xB2 in Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView C#
0x7 in Microsoft.Maui.Handlers.ViewHandler<Microsoft.Maui.ILayout,Microsoft.Maui.Platform.LayoutView>.SetVirtualView C#
0x65 in Microsoft.Maui.Controls.Element.SetHandler C#
0x2 in Microsoft.Maui.Controls.Element.set_Handler C#
0x18 in Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler C#
0xB0 in Microsoft.Maui.Platform.ElementExtensions.ToHandler C#
0x2 in Microsoft.Maui.Platform.ElementExtensions.ToPlatform C#
0x13 in Telerik.Maui.RadSideDrawerExtensions.UpdateMainContent C#
0xC in Telerik.Maui.Handlers.RadSideDrawerHandler.MapMainContent C#
0x21 in Microsoft.Maui.PropertyMapper<Telerik.Maui.IRadSideDrawer,Telerik.Maui.Handlers.RadSideDrawerHandler>. C#
0x18 in Microsoft.Maui.PropertyMapper.UpdatePropertyCore C#
0x1D in Microsoft.Maui.PropertyMapper.UpdateProperties C#
0xCB in Microsoft.Maui.Handlers.ElementHandler.SetVirtualView C#
0x2 in Microsoft.Maui.Handlers.ViewHandler<Telerik.Maui.IRadSideDrawer,TelerikUI.TKSideDrawerView>.SetVirtualView C#
0x7 in Microsoft.Maui.Handlers.ViewHandler<Telerik.Maui.IRadSideDrawer,TelerikUI.TKSideDrawerView>.SetVirtualView C#
0x65 in Microsoft.Maui.Controls.Element.SetHandler C#
0x2 in Microsoft.Maui.Controls.Element.set_Handler C#
0x18 in Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler C#
0xB0 in Microsoft.Maui.Platform.ElementExtensions.ToHandler C#
0x2 in Microsoft.Maui.Platform.ElementExtensions.ToPlatform C#
0xB2 in Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView C#
0x7 in Microsoft.Maui.Handlers.ViewHandler<Microsoft.Maui.ILayout,Microsoft.Maui.Platform.LayoutView>.SetVirtualView C#
0x65 in Microsoft.Maui.Controls.Element.SetHandler C#
0x2 in Microsoft.Maui.Controls.Element.set_Handler C#
0x18 in Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler C#
0xB0 in Microsoft.Maui.Platform.ElementExtensions.ToHandler C#
0x2 in Microsoft.Maui.Platform.ElementExtensions.ToPlatform C#
0xB2 in Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView C#
0x7 in Microsoft.Maui.Handlers.ViewHandler<Microsoft.Maui.ILayout,Microsoft.Maui.Platform.LayoutView>.SetVirtualView C#
0x65 in Microsoft.Maui.Controls.Element.SetHandler C#
0x2 in Microsoft.Maui.Controls.Element.set_Handler C#
0x18 in Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler C#
0xB0 in Microsoft.Maui.Platform.ElementExtensions.ToHandler C#
0x2 in Microsoft.Maui.Platform.ElementExtensions.ToPlatform C#
0x60 in Microsoft.Maui.Handlers.ContentViewHandler.UpdateContent C#
0x1 in Microsoft.Maui.Handlers.ContentViewHandler.MapContent C#
0x21 in Microsoft.Maui.PropertyMapper<Microsoft.Maui.IContentView,Microsoft.Maui.Handlers.IContentViewHandler>. C#
0x18 in Microsoft.Maui.PropertyMapper.UpdatePropertyCore C#
0x1D in Microsoft.Maui.PropertyMapper.UpdateProperties C#
0xCB in Microsoft.Maui.Handlers.ElementHandler.SetVirtualView C#
0x2 in Microsoft.Maui.Handlers.ViewHandler<Microsoft.Maui.IContentView,Microsoft.Maui.Platform.ContentView>.SetVirtualView C#
0x2 in Microsoft.Maui.Handlers.ContentViewHandler.SetVirtualView C#
0x7 in Microsoft.Maui.Handlers.ViewHandler<Microsoft.Maui.IContentView,Microsoft.Maui.Platform.ContentView>.SetVirtualView C#
0x65 in Microsoft.Maui.Controls.Element.SetHandler C#
0x2 in Microsoft.Maui.Controls.Element.set_Handler C#
0x18 in Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler C#
0xB0 in Microsoft.Maui.Platform.ElementExtensions.ToHandler C#
0x2 in Microsoft.Maui.Platform.ViewExtensions.ToHandler C#
0x19 in Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.SetPageRenderer C#
0xA1 in Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.LoadRenderers C#
0xD3 in Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.ViewDidLoad C#
0x88 in UIKit.UIApplication.xamarin_UIApplicationMain C#
0x6 in UIKit.UIApplication.UIApplicationMain C#
0x51 in UIKit.UIApplication.Main C#
Steps to Reproduce
- Create a new Maui project
- Add an html asset file
data.html - Update view XAML to include
<WebView Source="data.html" /> - Verify working on windows/android
- Verify not working on iOS
Link to public reproduction project repository
https://github.com/Telavian/iosError
Version with bug
6.0.486 (current)
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS 16
Did you find any workaround?
It appears using the current app directory works.
url = Path.Combine(Directory.GetCurrentDirectory(), url);
return $"file://{url}";
Relevant log output
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-controls-webviewWebViewWebViewfixed-in-7.0.100fixed-in-7.0.101fixed-in-7.0.58Look for this fix in 7.0.58!Look for this fix in 7.0.58!fixed-in-8.0.0-preview.1.7762Look for this fix in 8.0.0-preview.1.7762!Look for this fix in 8.0.0-preview.1.7762!platform/iost/bugSomething isn't workingSomething isn't working
Type
Fields
Give feedbackNo fields configured for issues without a type.