Skip to content
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

Fix android debugging not working when window.location is a file:// URL #462

Merged
merged 1 commit into from Jul 31, 2018

Conversation

hedgepigdaniel
Copy link
Contributor

See #405

I'm not sure if this will break something else (or what the intention is when using window.location), but for me, this allows debugging to work with react-native-debugger and android with haul 1.0.0-rc.5.

@zamotany
Copy link
Contributor

AFAIK this will break remote debugging on Android

@hedgepigdaniel
Copy link
Contributor Author

Interesting - for me remote debugging on android is broken without this change.

Perhaps the issue is that I'm connecting to the debugger over a real network connection, rather than an ADB reversed port on localhost - I'll try with a USB cord and see what happens - perhaps there is a way to make it work in both cases.

@hedgepigdaniel
Copy link
Contributor Author

I've tested with both of these situations:

  • an ADB connection to the device over USB with adb reverse tcp:8081 tcp:8081, and the app configured with the "Dev server host and port for device" to localhost:8081
  • an ADB connection to the device over a network and the app configured with the "Dev server host and port for device" to <ip of machine running haul + rn debugger>:8081

In both of these cases, the app crashes when remote debugging is switched on as detailed in #405. In both cases with this patch, it works correctly.

Other details I am testing with

  • React Native Debugger: 0.7.18
  • OS: Arch Linux
  • React Native: 0.54.4
  • Device: Nexus 6P Android 8.1.0

Not sure what else about the environment might vary such that it works/doesn't work the other way around?

@hedgepigdaniel
Copy link
Contributor Author

I should add that all these tests are done with HMR switched on - Since the crash happens when trying to connect the HMR socket, I think everything is fine in all cases unless you turn on HMR.

@hedgepigdaniel hedgepigdaniel changed the title Do not attempt to get the dev server origin from window.location Fix android debugging not working when window.location is a file:// URL Jul 30, 2018
@hedgepigdaniel
Copy link
Contributor Author

hedgepigdaniel commented Jul 30, 2018

OK how about this - it checks whether window.location.protocol is file: (It is, in my case), and only in that case it skips using window.location to set DEV_SERVER_ORIGIN.

In other cases where window.location is the network location of the debug server, this should now not break debugging.

@thymikee thymikee merged commit d795af3 into callstack:next Jul 31, 2018
@thymikee
Copy link
Member

Thanks you @hedgepigdaniel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants