-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Update default BlazorWebView
host address
#24884
Conversation
Confirmed working on iPhone 14 Simulator with iOS 16.2. |
And confirmed iPhone 15 Pro Simulator with iOS 18.0 works as well. So between the CI automated tests, and a few manual tests, I think we've shown that all platforms are compatible with using |
@@ -49,10 +49,10 @@ internal class WebView2WebViewManager : WebViewManager | |||
// Using an IP address means that WebView2 doesn't wait for any DNS resolution, | |||
// making it substantially faster. Note that this isn't real HTTP traffic, since | |||
// we intercept all the requests within this origin. | |||
internal static readonly string AppHostAddress = "0.0.0.0"; | |||
internal static readonly string AppHostAddress = HostAddressHelper.GetAppHostAddress(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a Mapper that users can override
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the intent here is not to allow complete customization of the address at this point, so we don't need it to be a mapper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it was just a way in the future I think we can allow users to unblock themselves. and using the "recommended" approach for extensibility, I think we do it on WebView on android from some chrome stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems reasonable, but given the stage in the release cycle, I think we're trying to make this fix as targeted as possible. By adding a new API now, we'd be kind of stuck allowing the configuration of the host address, which adds a new opportunity for misconfiguration. In the chance that this becomes a recurring issue (e.g., if browsers decided to ban 0.0.0.1
next), we could add the mapper at that point. But I'm open to having my mind changed.
@Eilon, do you have any thoughts about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah definitely a nice feature request. I thin it's already tracked by another issue.
/backport to net9.0 |
Started backporting to net9.0: https://github.com/dotnet/maui/actions/runs/11076872634 |
We are going to merge main to net9.0 , just added it there. |
Update default host address to 0.0.0.1.
We are having trouble with both
Another usecase is locking down google maps API keys to specific domains, we were not able to make this work with We really need this to be configurable to |
/backport to release/9.0.1xx |
Started backporting to release/9.0.1xx: https://github.com/dotnet/maui/actions/runs/11369775618 |
@PureWeen backporting to release/9.0.1xx failed, the patch most likely resulted in conflicts: $ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Update default host address
Using index info to reconstruct a base tree...
M Microsoft.Maui-dev.sln
M src/BlazorWebView/src/Maui/BlazorWebView.cs
M src/BlazorWebView/src/SharedSource/WebView2WebViewManager.cs
Falling back to patching base and 3-way merge...
Auto-merging src/BlazorWebView/src/SharedSource/WebView2WebViewManager.cs
CONFLICT (content): Merge conflict in src/BlazorWebView/src/SharedSource/WebView2WebViewManager.cs
CONFLICT (add/add): Merge conflict in src/BlazorWebView/src/SharedSource/HostAddressHelper.cs
Auto-merging src/BlazorWebView/src/SharedSource/HostAddressHelper.cs
Auto-merging Microsoft.Maui-dev.sln
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 Update default host address
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
@PureWeen an error occurred while backporting to release/9.0.1xx, please check the run log for details! Error: git am failed, most likely due to a merge conflict. |
Update default host address to 0.0.0.1.
Description of Change
Changed the
BlazorWebView
default host address from0.0.0.0
to0.0.0.1
for all platforms (except Tizen).Another alternative (as mentioned in #24363) was to use a custom host name like
blazor
, but in my testing this slowed down the initial page load quite a lot due to DNS resolution (in theMaui.Controls.Sample
project, load times went from ~450ms to ~2.3 seconds).This PR initially attempted to change to use
localhost
, but this causes problems when other processes use localhost simultaneously (e.g., the appium test server). We deemed this to be a risky change.This PR is effectively an extension of #23906, as it applies a similar fix to Android and Windows platforms.
Issues Fixed
Fixes #24363