-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Added option to disable xip #13326
Added option to disable xip #13326
Conversation
LGTM! |
@ericvicenti has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: When running an app on a real iPhone in debug mode, I occasionally get issues when trying to load the js bundle and I suspect the issue is with xip.io (and it doesn't look like I'm the only one: facebook/react-native#12786 facebook/react-native#9688 (comment)). So I've added the ability to optionally disable the use of xip.io if an env variable `DISABLE_XIP` is set. Add `export DISABLE_XIP=true` to the `Bundle React Native code and images` build phase. Run the app on a real iPhone and ensure that it can load the JS bundle from the host computers IP. Closes facebook/react-native#13326 Differential Revision: D4855719 Pulled By: ericvicenti fbshipit-source-id: cb2e91291acadaa78ea302800b55c2e5388f6380
Summary: When running an app on a real iPhone in debug mode, I occasionally get issues when trying to load the js bundle and I suspect the issue is with xip.io (and it doesn't look like I'm the only one: facebook#12786 facebook#9688 (comment)). So I've added the ability to optionally disable the use of xip.io if an env variable `DISABLE_XIP` is set. Add `export DISABLE_XIP=true` to the `Bundle React Native code and images` build phase. Run the app on a real iPhone and ensure that it can load the JS bundle from the host computers IP. Closes facebook#13326 Differential Revision: D4855719 Pulled By: ericvicenti fbshipit-source-id: cb2e91291acadaa78ea302800b55c2e5388f6380
Is there any reason or benefit to use xip.io? I had a lot of trouble because DNS responses with private ip ranges are blocked. |
Possible to drop that xip.io? If I change
and remove the .xip.io extension, everything is fine with the remote packager. |
Facing similar issue. Will this PR, solve the issue in Android too? The connection with the development server lost frequently. RN v0.42.3 |
@@ -80,9 +80,14 @@ if [[ "$CONFIGURATION" = "Debug" && ! "$PLATFORM_NAME" == *simulator ]]; then | |||
if [ -z "$IP" ]; then | |||
IP=$(ifconfig | grep 'inet ' | grep -v 127.0.0.1 | cut -d\ -f2 | awk 'NR==1{print $1}') | |||
fi | |||
|
|||
if [ -z ${DISABLE_XIP+x} ]; then |
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.
Hey, I'm working on this file and don't know what "+x" in ${DISABLE_XIP+x}
does. (AFAICS, it is also not mentioned in the Bash manual.) Could you please explain?
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.
It's parameter expansion:
${parameter:+word}
If parameter is null or unset, nothing is substituted, otherwise the expansion of word is substituted.
So if DISABLE_XIP
is null or unset then the check will fail otherwise it will pass. x
is used here just as a placeholder.
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.
Turns out I've missed the part where it explains that the colon can be omitted:
Omitting the colon results in a test only for a parameter that is unset. Put another way, if the colon is included, the operator tests for both parameter’s existence and that its value is not null; if the colon is omitted, the operator tests only for existence.
Thanks!
I think I will change this to [[ $DISABLE_XIP != true ]]
like I did with all the other boolean-y variables.
To be honest, ${DISABLE_XIP+x}
looks ugly. I have completely rewritten this script and this is the last part of the whole thing that I could not understand. I don't like saying "If that was hard for me, then it will be for other people." but I guess this one deserves an exception.
Also, correct me if I'm wrong, but if a variable is set and I want to run a single command with that variable being unset, I have to use unset DISABLE_XIP; command
which unsets the variable for the whole env and not just the command. A subshell can be used to avoid that but it just gets uglier. With a != true
check, you can just do DISABLE_XIP= command;
to turn it off and DISABLE_XIP=true command;
to turn it on. This doesn't really matter in this use case, but I guess I will adopt this as one of my "Bash Best Practices".
What do you think?
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.
Yep that sounds completely reasonable and a nicer solution all round. Thanks!
Hi, |
And - I know this thread is not specificly about this - I'd like to modify the script to support using SKIP_BUNDLING also for device builds, while still updating the IP address, which would require creating the ip.txt also if SKIP_BUNDLING is true:
|
Summary: By default, when a react-native app launches in development mode on a physical iOS device, it attempts to load the JS bundle from a packager at `http://_your-local-ip-address_.xip.io:8081/`. This change removes the use of `xip.io`, which changes that url to: `http://_your-local-ip-address_:8081/` <!-- Thank you for sending the PR! We appreciate you spending the time to work on these changes. Help us understand your motivation by explaining why you decided to make this change. You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html Happy contributing! --> Background: The automatic IP detection feature (introduced [here](#8091)) is super handy. However, it’s use of `xip.io` has caused myself and others much grief. Some routers do not allow or have intermittent errors when trying to resolve DNS names to local IP addresses. This prompted the introduction of a [DISABLE_XIP feature](#13326), which helps. However, I don’t believe the use of `xip.io` is needed at all. Based on [this comment](8c29a52#commitcomment-18224788), it appears the original reason for using `xip.io` was to “circumvent the numeric IP address limitation in ATS”. But, the reason you can’t create ATS exceptions for raw IP addresses is that ATS is not enforced for raw IP addresses _at all_. You can read the Apple documentation [here](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html), the relevant portion is: > App Transport Security (ATS) applies only to connections made to public host names. The system does not provide ATS protection to connections made to: > * Internet protocol (IP) addresses > * Unqualified host names > * Local hosts employing the .local top-level domain (TLD) For example, in iOS, if you attempt to make an http request (note: _not_ https) to `http://www.google.com` you will get an error due to ATS. However, you can make the same request to `http://172.217.6.14/` (which for me is the same server) and the request will succeed. And in fact, if an ATS exception _was_ needed, the DISABLE_XIP feature shouldn’t work at all, but it does. In short, using `xip.io` with ATS exceptions is unnecessary, causes some very annoying problems for some people, and I think it should just be removed. Run the app on a physical iOS device and verify that it can load the JS bundle from the host computer's IP. [Implemented automatic IP detection for iOS #8091](#8091) [Added option to disable xip #13326](#13326) <!-- Help reviewers and the release process by writing your own release notes **INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.** CATEGORY [----------] TYPE [ CLI ] [-------------] LOCATION [ DOCS ] [ BREAKING ] [-------------] [ GENERAL ] [ BUGFIX ] [-{Component}-] [ INTERNAL ] [ ENHANCEMENT ] [ {File} ] [ IOS ] [ FEATURE ] [ {Directory} ] |-----------| [ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} | [----------] [-------------] [-------------] |-----------| [CATEGORY] [TYPE] [LOCATION] - MESSAGE EXAMPLES: [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see --> [INTERNAL] [BUGFIX] [./scripts] - Removed use of xip.io Closes #17642 Differential Revision: D6814609 Pulled By: hramos fbshipit-source-id: f2faebd6a29b0b211d78cdfe8e195906307ab552
Motivation (required)
When running an app on a real iPhone in debug mode, I occasionally get issues when trying to load the js bundle and I suspect the issue is with xip.io (and it doesn't look like I'm the only one: #12786 #9688 (comment)). So I've added the ability to optionally disable the use of xip.io if an env variable
DISABLE_XIP
is set.Test Plan (required)
Add
export DISABLE_XIP=true
to theBundle React Native code and images
build phase. Run the app on a real iPhone and ensure that it can load the JS bundle from the host computers IP.