Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow client-side device identifiers in inspector proxy (#991)
Summary: Fixes #985 This allows devices connecting to the inspector proxy to provide a client-side unique string identifier. With this, we can pass along a unique identifier that doesn't change when reconnecting, e.g. after a hard crash. It makes the overall debugging experience way more stable since you don't have to restart the debugger in between crashes or full restarts. Allowing users to keep the debugger open also lets the debugger "remember" certain things, such as set breakpoints. >⚠️ When the client doesn't specify this unique identifier, it still falls back to the incremental identifier (the `fallbackDeviceId` in this PR) When a collision occurs, the old device's connection is closed. But, if both the device and app names are equal to the new device connection, the debugger connection is kept open. ## Next steps If this is landed, we still need changes in React Native (the `&device=...` query param). I have no strong opinions on what identifier is used, but it should follow these rules: - Should be unique per device or emulator/simulator (and thus, also per platform) - Must not change when restarting the app - Must be a string that's URL safe On Android, I had good success using the [`Secure.ANDROID_ID`](https://developer.android.com/reference/android/provider/Settings.Secure#ANDROID_ID). It may change after a factory reset, which doesn't matter for our use case. Pull Request resolved: #991 Test Plan: - Create a new project, and enable building from source on both Android & iOS - **android**: edit [this file](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java#L282-L289) in `node_modules/react-native` and add a hardcoded `&device=testingandroid` query param. - **ios**: edit [this file](https://github.com/facebook/react-native/blob/main/packages/react-native/React/DevSupport/RCTInspectorDevServerHelper.mm#L43-L53) in `node_modules/react-naive` and add a hardcoded `&device=testingios` query param. - Connect the debugger to the running app - Force close the app, which should cause a "reconnect" warning in the debugger - Open the app again, and press "reconnect" in the debugger - _Due to the stable identifiers, the URL won't change and the above scenario should work fine_ Also test without these `&device=...` query param since that should work as it does now (with incremental identifiers). Reviewed By: motiz88 Differential Revision: D46482492 Pulled By: huntie fbshipit-source-id: 5d6e1e9c692d78ebfde8f4938041a8f381a1d48c
- Loading branch information