[iOS] Fix WebView.Reload() with HtmlWebViewSource returning WebNavigationResult.Failure#14
Draft
[iOS] Fix WebView.Reload() with HtmlWebViewSource returning WebNavigationResult.Failure#14
Conversation
Co-authored-by: devanathan-vaithiyanathan <114395405+devanathan-vaithiyanathan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [iOS] WebView.Reload() with HtmlWebViewSource returns WebNavigationResult.Failure in Navigated event
[iOS] Fix WebView.Reload() with HtmlWebViewSource returning WebNavigationResult.Failure
Jul 11, 2025
546914f to
513755f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description
Fixed an issue where calling
WebView.Reload()on an iOS WebView withHtmlWebViewSourcewould trigger theNavigatedevent withWebNavigationResult.Failureinstead ofWebNavigationResult.Success.Problem
The iOS
WKWebView.Reload()method cannot reload HTML content that was loaded viaLoadHtmlString()because there's no actual URL to reload from. This caused the reload operation to fail forHtmlWebViewSourcewhile working correctly forUrlWebViewSource.Solution
Modified the
UpdateReloadmethod inWebViewExtensions.csto reload from the original source instead of calling the platform's native reload method:This approach leverages the existing polymorphism:
Load()→renderer.LoadHtml(Html, BaseUrl)Load()→renderer.LoadUrl(Url)Testing
Added comprehensive tests for both
HtmlWebViewSourceandUrlWebViewSourcereload scenarios to ensure:WebNavigationResult.Successon reloadChanges
src/Core/src/Platform/iOS/WebViewExtensions.cs: UpdatedUpdateReloadmethodsrc/Core/tests/DeviceTests/Handlers/WebView/WebViewHandlerTests.iOS.cs: Added test coverageFixes #13.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
4vyvsblobprodcus361.vsblob.vsassets.iodotnet build src/Core/tests/DeviceTests/Core.DeviceTests.csproj -c Debug(dns block)4zjvsblobprodcus390.vsblob.vsassets.iodotnet build src/Core/tests/DeviceTests/Core.DeviceTests.csproj -c Debug(dns block)gervsblobprodcus329.vsblob.vsassets.iodotnet build src/Core/tests/DeviceTests/Core.DeviceTests.csproj -c Debug(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js(dns block)jd4vsblobprodcus366.vsblob.vsassets.iodotnet build src/Core/tests/DeviceTests/Core.DeviceTests.csproj -c Debug(dns block)kxqvsblobprodcus376.vsblob.vsassets.iodotnet build src/Core/tests/DeviceTests/Core.DeviceTests.csproj -c Debug(dns block)o3svsblobprodcus318.vsblob.vsassets.iodotnet build src/Core/tests/DeviceTests/Core.DeviceTests.csproj -c Debug(dns block)rcxvsblobprodcus328.vsblob.vsassets.iodotnet build src/Core/tests/DeviceTests/Core.DeviceTests.csproj -c Debug(dns block)tphvsblobprodcus375.vsblob.vsassets.iodotnet build src/Core/tests/DeviceTests/Core.DeviceTests.csproj -c Debug(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.