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

[dev-server][dev-launcher] inspector network on ios #21265

Merged
merged 10 commits into from
Mar 2, 2023

Conversation

Kudo
Copy link
Contributor

@Kudo Kudo commented Feb 17, 2023

Why

close ENG-7464
close ENG-7492

How

  • [dev-server] enable more devtools features rather than v8only
  • [dev-launcher] intercept URLSession requests and send CDP network events through metro-inspector-proxy to devtools

Test Plan

bare-expo + useDevClient = YES in AppDelegate.mm (this is to enable dev-launcher)

Checklist

@linear
Copy link

linear bot commented Feb 17, 2023

ENG-7464 [network][dev-launcher][iOS] Intercept NSURLSession requests and send to metro-inspector-proxy

By using NSURLSessionConfiguration, we could possibly intercept all network requests sending through NSURLSession: https://blog.codavel.com/how-to-intercept-http-requests-on-an-ios-app

Then to send CDP network events through metro-inspector-proxy to Chrome DevTools: https://chromedevtools.github.io/devtools-protocol/tot/Network/

ENG-7492 [react-native][ios] add sendWrappedEventToAllRemoteConnections to send CDP events

Currently react-native on iOS doesn't expose an interface for us to send events to metro-inspector-proxy. We should either proposing a PR for upstream or hack it.

@expo-bot expo-bot added bot: needs changes ExpoBot found things that don't meet our guidelines bot: suggestions ExpoBot has some suggestions and removed bot: needs changes ExpoBot found things that don't meet our guidelines labels Feb 17, 2023
@expo-bot
Copy link
Collaborator

Hi there! 👋 I'm a bot whose goal is to ensure your contributions meet our guidelines.

I've found some issues in your pull request that should be addressed (click on them for more details) 👇

⚠️ Suggestion: Missing changelog entries


Your changes should be noted in the changelog. Read Updating Changelogs guide and consider adding an appropriate entry to the following changelogs:


Generated by ExpoBot 🤖 against 7391f1a

@byCedric
Copy link
Member

byCedric commented Feb 19, 2023

@Kudo I think we are missing two important protocol messages, the Network.enable and Network.disable events.

It should probably work without them, but it might be nice to implement them to not over-send protocol events that aren't useful. 😄 But, I'm not 100% convinced the chrome debugger is sending these though.

@Kudo
Copy link
Contributor Author

Kudo commented Feb 20, 2023

@byCedric devtools will sent the event
Screenshot 2023-02-21 at 12 20 04 AM

@expo-bot
Copy link
Collaborator

Hi there! 👋 I'm a bot whose goal is to ensure your contributions meet our guidelines.

I've found some issues in your pull request that should be addressed (click on them for more details) 👇

⚠️ Suggestion: Missing changelog entries


Your changes should be noted in the changelog. Read Updating Changelogs guide and consider adding an appropriate entry to the following changelogs:


Generated by ExpoBot 🤖 against 5558c79

@Kudo Kudo force-pushed the @kudo/eng-7464-networkdev-launcherios-intercept branch from 5558c79 to 662f085 Compare February 27, 2023 14:33
@expo-bot
Copy link
Collaborator

Hi there! 👋 I'm a bot whose goal is to ensure your contributions meet our guidelines.

I've found some issues in your pull request that should be addressed (click on them for more details) 👇

⚠️ Suggestion: Missing changelog entries


Your changes should be noted in the changelog. Read Updating Changelogs guide and consider adding an appropriate entry to the following changelogs:


Generated by ExpoBot 🤖 against 662f085

@Kudo Kudo merged commit 6f74b01 into main Mar 2, 2023
@Kudo Kudo deleted the @kudo/eng-7464-networkdev-launcherios-intercept branch March 2, 2023 11:39
byCedric added a commit that referenced this pull request Mar 8, 2023
…oxy` (#21449)

# Why

Fixes ENG-7467

Related #21265

This is an initial draft to extend the CDP functionality of
`metro-inspector-proxy`.

# How

The implementation is slightly wonky around the `ExpoInspectorDevice`.
We want to reuse as much as possible from `metro-inspector-proxy`, but
we need to add stateful data per device.

In order to achieve that, we generate a new class type, based on the
user's installed `metro-inspector-proxy`. This makes everything less
readable but should include future updates in these classes.

As for the `ExpoInspectorProxy`, to avoid having to do the same thing,
we just wrap the whole inspector class and reuse what we can. The device
map is "linked" within the original inspector proxy instance, making the
data available to all methods that need it.

# Test Plan

Enable this feature with `EXPO_USE_CUSTOM_INSPECTOR_PROXY=1`

- [x] See tests for the actual CDP events we handle.
- [ ] See tests on the "bootstrapping code" to create the inspector and
devices.

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `expo prebuild` & EAS Build (eg:
updated a module plugin).

---------

Co-authored-by: Evan Bacon <bacon@expo.io>
Kudo added a commit that referenced this pull request Mar 22, 2023
# Why

close ENG-7631

# How

this is a side effect of #21265 where we enable full feature devtools. the `Debugger.pause` events are sent by devtools frontend: https://github.com/ChromeDevTools/devtools-frontend/blob/e0d743c4f184589db10fb1d276b87dbe90498077/front_end/entrypoints/inspector_main/InspectorMain.ts#L62-L97. we reached the `waitForDebuggerInPage===true` case and then devtools frontend calls `debuggerModel.pause()`.

to skip the call path, we could either set `targetType=tab` or not set `panel=sources`. i am kinda afraid to change targetType which may cause other side effects, so to change the panel instead. with this pr, the initial devtools tab would be the "console" tab.

# Test Plan

bare-expo + devtools + sending js `fetch` call
Kudo added a commit that referenced this pull request Apr 10, 2023
close ENG-7464
close ENG-7492

- [dev-server] enable more devtools features rather than v8only
- [dev-launcher] intercept `URLSession` requests and send CDP network events through metro-inspector-proxy to devtools

bare-expo + `useDevClient = YES` in AppDelegate.mm (this is to enable dev-launcher)

(cherry picked from commit 6f74b01)
Kudo added a commit that referenced this pull request Apr 10, 2023
# Why

close ENG-7631

# How

this is a side effect of #21265 where we enable full feature devtools. the `Debugger.pause` events are sent by devtools frontend: https://github.com/ChromeDevTools/devtools-frontend/blob/e0d743c4f184589db10fb1d276b87dbe90498077/front_end/entrypoints/inspector_main/InspectorMain.ts#L62-L97. we reached the `waitForDebuggerInPage===true` case and then devtools frontend calls `debuggerModel.pause()`.

to skip the call path, we could either set `targetType=tab` or not set `panel=sources`. i am kinda afraid to change targetType which may cause other side effects, so to change the panel instead. with this pr, the initial devtools tab would be the "console" tab.

# Test Plan

bare-expo + devtools + sending js `fetch` call

(cherry picked from commit 80135d2)
Kudo added a commit that referenced this pull request Apr 10, 2023
# Why

close ENG-7631

# How

this is a side effect of #21265 where we enable full feature devtools. the `Debugger.pause` events are sent by devtools frontend: https://github.com/ChromeDevTools/devtools-frontend/blob/e0d743c4f184589db10fb1d276b87dbe90498077/front_end/entrypoints/inspector_main/InspectorMain.ts#L62-L97. we reached the `waitForDebuggerInPage===true` case and then devtools frontend calls `debuggerModel.pause()`.

to skip the call path, we could either set `targetType=tab` or not set `panel=sources`. i am kinda afraid to change targetType which may cause other side effects, so to change the panel instead. with this pr, the initial devtools tab would be the "console" tab.

# Test Plan

bare-expo + devtools + sending js `fetch` call

(cherry picked from commit 80135d2)
Kudo added a commit that referenced this pull request Apr 10, 2023
close ENG-7464
close ENG-7492

- [dev-server] enable more devtools features rather than v8only
- [dev-launcher] intercept `URLSession` requests and send CDP network events through metro-inspector-proxy to devtools

bare-expo + `useDevClient = YES` in AppDelegate.mm (this is to enable dev-launcher)

(cherry picked from commit 6f74b01)
Kudo added a commit that referenced this pull request Apr 10, 2023
# Why

close ENG-7631

# How

this is a side effect of #21265 where we enable full feature devtools. the `Debugger.pause` events are sent by devtools frontend: https://github.com/ChromeDevTools/devtools-frontend/blob/e0d743c4f184589db10fb1d276b87dbe90498077/front_end/entrypoints/inspector_main/InspectorMain.ts#L62-L97. we reached the `waitForDebuggerInPage===true` case and then devtools frontend calls `debuggerModel.pause()`.

to skip the call path, we could either set `targetType=tab` or not set `panel=sources`. i am kinda afraid to change targetType which may cause other side effects, so to change the panel instead. with this pr, the initial devtools tab would be the "console" tab.

# Test Plan

bare-expo + devtools + sending js `fetch` call

(cherry picked from commit 80135d2)
byCedric added a commit that referenced this pull request Apr 11, 2023
…oxy` (#21449)

Fixes ENG-7467

Related #21265

This is an initial draft to extend the CDP functionality of
`metro-inspector-proxy`.

The implementation is slightly wonky around the `ExpoInspectorDevice`.
We want to reuse as much as possible from `metro-inspector-proxy`, but
we need to add stateful data per device.

In order to achieve that, we generate a new class type, based on the
user's installed `metro-inspector-proxy`. This makes everything less
readable but should include future updates in these classes.

As for the `ExpoInspectorProxy`, to avoid having to do the same thing,
we just wrap the whole inspector class and reuse what we can. The device
map is "linked" within the original inspector proxy instance, making the
data available to all methods that need it.

Enable this feature with `EXPO_USE_CUSTOM_INSPECTOR_PROXY=1`

- [x] See tests for the actual CDP events we handle.
- [ ] See tests on the "bootstrapping code" to create the inspector and
devices.

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `expo prebuild` & EAS Build (eg:
updated a module plugin).

---------

Co-authored-by: Evan Bacon <bacon@expo.io>
@Kudo Kudo added the published Changes from the PR have been published to npm label Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: suggestions ExpoBot has some suggestions published Changes from the PR have been published to npm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants