Skip to content

Commit 50f646f

Browse files
vmoroziamAbhi-916
andauthored
[0.80] Add support for modern inspector (#15357)
* Add support for modern inspector * Change files * Remove old change file * Fix JSI test compilation errors * enable dynamic_casts (RTTI) at a project level * Format code --------- Co-authored-by: Abhijeet Jha <[email protected]>
1 parent 2248327 commit 50f646f

File tree

114 files changed

+2219
-2382
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+2219
-2382
lines changed

change/@react-native-windows-automation-channel-329de26f-47f0-4f3a-8d1e-18eef1084456.json

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Add support for modern inspector",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

docs/modern-inspector-details.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Modern Inspector Support in React Native for Windows
2+
3+
## Overview
4+
The modern inspector is the Chrome DevTools–based debugging experience that ships with the latest
5+
versions of React Native. This experience now works end-to-end for React Native for Windows (RNW)
6+
applications, enabling parity with Android and iOS. The integration provides a unified way to inspect
7+
JavaScript execution, evaluate console expressions, profile CPU and memory usage, and visualize the
8+
component hierarchy for both the Paper and Composition UI stacks.
9+
10+
## Modern Inspector Building Blocks
11+
- **Host Target** – One per `ReactHost`; surfaces metadata, reload requests, pause overlays, and
12+
implements the CDP-facing delegate (`ReactInspectorHostTargetDelegate`).
13+
- **Instance Target** – Created for each React instance; registers runtime targets, tracks instance
14+
lifecycle, and unregisters cleanly on reload.
15+
- **Runtime Target & Agent** – Runtime targets map to JavaScript VMs; agents are per-session objects
16+
that translate Chrome DevTools Protocol (CDP) messages into engine calls. RNW mirrors upstream
17+
lifetimes so reloads tear everything down deterministically.
18+
- **Frontend Channel** – Delivers JSON CDP payloads between the RNW host and DevTools.
19+
- **Inspector Thread** – A single `ReactInspectorThread` ensures CDP work is serialized away from
20+
the UI and JS queues. (iOS and Andrtoid use UI thread.)
21+
- **Debugger Notifications**`DebuggerNotifications.h` broadcasts pause/resume events so view
22+
hosts can react (e.g., showing overlays or resuming when the debugger continues).
23+
24+
## Windows Integration Points
25+
- **ReactHost & ReactOptions**`ReactHost` creates the `HostTarget`, exposes it through
26+
`ReactOptions::InspectorHostTarget`, and implements reload/pause hooks. This is the jump-off point
27+
for all inspector traffic. The inspector supported only if the `UseDirectDebugger` is true.
28+
- **ReactInstanceWin / OInstance** – Register and unregister instance/runtime targets around runtime
29+
creation, keeping the inspector aligned with bridgeless and legacy bridge lifecycles.
30+
- **DevSupportManager & Packager**`DevSupportManager` now spins up
31+
`ReactInspectorPackagerConnectionDelegate`, allowing Metro to broker modern inspector connections
32+
and reuse the existing websocket infrastructure.
33+
- **Dev Console Shortcut** – Metro’s `J` shortcut launches the inspector for Windows apps, matching
34+
upstream behavior.
35+
36+
## UI Overlays
37+
- **Composition**`DebuggerUIIsland` renders pause overlays, focus chrome, and selection adorners
38+
whenever the runtime is paused.
39+
- **Paper**`ReactRootView` updates provide the same pause/selection affordances.
40+
41+
## Hermes Runtime Integration
42+
- `HermesRuntimeTargetDelegate` and `HermesRuntimeAgentDelegate` wrap the hermes-windows C debug API
43+
so we can re-use upstream modern inspector code.
44+
- `RuntimeHolder`/`HermesRuntimeHolder` surface a `createRuntimeTargetDelegate` hook that instantiates
45+
delegates only when the inspector is enabled, and safely tears them down during reloads.
46+
47+
## Packager & Console Integration
48+
- `ReactInspectorPackagerConnectionDelegate` maps the Metro websocket APIs to the modern inspector
49+
handshake.
50+
- Console output, CPU sampling, and memory profiling are forwarded through the Hermes inspector
51+
plumbing automatically once a session is active.
52+
53+
## Using the Modern Inspector with RNW
54+
1. Start your Metro bundler (`npx react-native start` or `yarn start`).
55+
2. Launch your RNW app (Paper or Composition).
56+
3. In the Metro console, press `J` to open the modern inspector URL in a browser.
57+
4. Chrome DevTools will connect to the Hermes runtime. Pause execution, explore the component tree,
58+
and capture profiles as needed.
59+
5. When execution is paused, the corresponding overlay is rendered in the app window; resume to clear
60+
the overlay.
61+
62+
## Known Limitations & Follow-Up Work
63+
- **Network profiling** – The `NetworkIOAgent` is not wired up yet for Windows. The integration point
64+
is the `ReactInspectorHostTargetDelegate` in
65+
`vnext/Microsoft.ReactNative/ReactHost/ReactHost.cpp`; override `loadNetworkResource` there to
66+
forward requests through a Windows HTTP helper (similar to `GetJavaScriptFromServerAsync`) and
67+
stream results back via the provided `NetworkRequestListener`. Until this happens, the Network tab
68+
in DevTools stays empty.
69+
- **Legacy Chakra runtime** – Modern inspector support currently targets Hermes. Chakra-based apps
70+
continue to rely on legacy debugging flows.

packages/@react-native-windows/automation-channel/windows/AutomationChannel/packages.chakra.lock.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
},
3030
"Microsoft.JavaScript.Hermes": {
3131
"type": "Transitive",
32-
"resolved": "0.0.0-2507.21007-eda7aef6",
33-
"contentHash": "3oyJXoPaayrtWSjBgnLFfVBrNcnvB3EJ1r2/K0yz9exmmESTTzWaCh8JlhX7fsjtMv/LpQxJOctHP0Ng2k8spQ=="
32+
"resolved": "0.0.0-2511.7001-d7ca19b3",
33+
"contentHash": "/EGy/gbTWpFZPZ4Z81QxbGQxpZhqiOE3qrnSokZRgXAyHivl15s7zZkRLOy9daDmVyEfanq7YBCOMi0ha58uQA=="
3434
},
3535
"Microsoft.SourceLink.Common": {
3636
"type": "Transitive",
@@ -72,7 +72,7 @@
7272
"dependencies": {
7373
"Common": "[1.0.0, )",
7474
"Folly": "[1.0.0, )",
75-
"Microsoft.JavaScript.Hermes": "[0.0.0-2507.21007-eda7aef6, )",
75+
"Microsoft.JavaScript.Hermes": "[0.0.0-2511.7001-d7ca19b3, )",
7676
"Microsoft.SourceLink.GitHub": "[1.1.1, )",
7777
"Microsoft.UI.Xaml": "[2.8.0, )",
7878
"ReactCommon": "[1.0.0, )",

packages/@react-native-windows/automation-channel/windows/AutomationChannel/packages.lock.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
},
3030
"Microsoft.JavaScript.Hermes": {
3131
"type": "Transitive",
32-
"resolved": "0.0.0-2507.21007-eda7aef6",
33-
"contentHash": "3oyJXoPaayrtWSjBgnLFfVBrNcnvB3EJ1r2/K0yz9exmmESTTzWaCh8JlhX7fsjtMv/LpQxJOctHP0Ng2k8spQ=="
32+
"resolved": "0.0.0-2511.7001-d7ca19b3",
33+
"contentHash": "/EGy/gbTWpFZPZ4Z81QxbGQxpZhqiOE3qrnSokZRgXAyHivl15s7zZkRLOy9daDmVyEfanq7YBCOMi0ha58uQA=="
3434
},
3535
"Microsoft.SourceLink.Common": {
3636
"type": "Transitive",
@@ -72,7 +72,7 @@
7272
"dependencies": {
7373
"Common": "[1.0.0, )",
7474
"Folly": "[1.0.0, )",
75-
"Microsoft.JavaScript.Hermes": "[0.0.0-2507.21007-eda7aef6, )",
75+
"Microsoft.JavaScript.Hermes": "[0.0.0-2511.7001-d7ca19b3, )",
7676
"Microsoft.SourceLink.GitHub": "[1.1.1, )",
7777
"Microsoft.UI.Xaml": "[2.8.0, )",
7878
"ReactCommon": "[1.0.0, )",

packages/@react-native-windows/automation-channel/windows/AutomationChannel/packages.newarch.lock.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
},
3838
"Microsoft.JavaScript.Hermes": {
3939
"type": "Transitive",
40-
"resolved": "0.0.0-2507.21007-eda7aef6",
41-
"contentHash": "3oyJXoPaayrtWSjBgnLFfVBrNcnvB3EJ1r2/K0yz9exmmESTTzWaCh8JlhX7fsjtMv/LpQxJOctHP0Ng2k8spQ=="
40+
"resolved": "0.0.0-2511.7001-d7ca19b3",
41+
"contentHash": "/EGy/gbTWpFZPZ4Z81QxbGQxpZhqiOE3qrnSokZRgXAyHivl15s7zZkRLOy9daDmVyEfanq7YBCOMi0ha58uQA=="
4242
},
4343
"Microsoft.SourceLink.Common": {
4444
"type": "Transitive",
@@ -85,7 +85,7 @@
8585
"dependencies": {
8686
"Common": "[1.0.0, )",
8787
"Folly": "[1.0.0, )",
88-
"Microsoft.JavaScript.Hermes": "[0.0.0-2507.21007-eda7aef6, )",
88+
"Microsoft.JavaScript.Hermes": "[0.0.0-2511.7001-d7ca19b3, )",
8989
"Microsoft.SourceLink.GitHub": "[1.1.1, )",
9090
"Microsoft.WindowsAppSDK": "[1.7.250401001, )",
9191
"ReactCommon": "[1.0.0, )",

packages/e2e-test-app-fabric/windows/RNTesterApp-Fabric.Package/packages.lock.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
},
1515
"Microsoft.JavaScript.Hermes": {
1616
"type": "Transitive",
17-
"resolved": "0.0.0-2507.21007-eda7aef6",
18-
"contentHash": "3oyJXoPaayrtWSjBgnLFfVBrNcnvB3EJ1r2/K0yz9exmmESTTzWaCh8JlhX7fsjtMv/LpQxJOctHP0Ng2k8spQ=="
17+
"resolved": "0.0.0-2511.7001-d7ca19b3",
18+
"contentHash": "/EGy/gbTWpFZPZ4Z81QxbGQxpZhqiOE3qrnSokZRgXAyHivl15s7zZkRLOy9daDmVyEfanq7YBCOMi0ha58uQA=="
1919
},
2020
"Microsoft.SourceLink.Common": {
2121
"type": "Transitive",
@@ -85,7 +85,7 @@
8585
"dependencies": {
8686
"Common": "[1.0.0, )",
8787
"Folly": "[1.0.0, )",
88-
"Microsoft.JavaScript.Hermes": "[0.0.0-2507.21007-eda7aef6, )",
88+
"Microsoft.JavaScript.Hermes": "[0.0.0-2511.7001-d7ca19b3, )",
8989
"Microsoft.SourceLink.GitHub": "[1.1.1, )",
9090
"Microsoft.WindowsAppSDK": "[1.7.250401001, )",
9191
"ReactCommon": "[1.0.0, )",
@@ -103,7 +103,7 @@
103103
"type": "Project",
104104
"dependencies": {
105105
"AutomationChannel": "[1.0.0, )",
106-
"Microsoft.JavaScript.Hermes": "[0.0.0-2507.21007-eda7aef6, )",
106+
"Microsoft.JavaScript.Hermes": "[0.0.0-2511.7001-d7ca19b3, )",
107107
"Microsoft.ReactNative": "[1.0.0, )",
108108
"Microsoft.VCRTForwarders.140": "[1.0.2-rc, )",
109109
"Microsoft.WindowsAppSDK": "[1.7.250401001, )",

packages/e2e-test-app-fabric/windows/RNTesterApp-Fabric/packages.lock.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
},
1111
"Microsoft.JavaScript.Hermes": {
1212
"type": "Direct",
13-
"requested": "[0.0.0-2507.21007-eda7aef6, )",
14-
"resolved": "0.0.0-2507.21007-eda7aef6",
15-
"contentHash": "3oyJXoPaayrtWSjBgnLFfVBrNcnvB3EJ1r2/K0yz9exmmESTTzWaCh8JlhX7fsjtMv/LpQxJOctHP0Ng2k8spQ=="
13+
"requested": "[0.0.0-2511.7001-d7ca19b3, )",
14+
"resolved": "0.0.0-2511.7001-d7ca19b3",
15+
"contentHash": "/EGy/gbTWpFZPZ4Z81QxbGQxpZhqiOE3qrnSokZRgXAyHivl15s7zZkRLOy9daDmVyEfanq7YBCOMi0ha58uQA=="
1616
},
1717
"Microsoft.VCRTForwarders.140": {
1818
"type": "Direct",
@@ -95,7 +95,7 @@
9595
"dependencies": {
9696
"Common": "[1.0.0, )",
9797
"Folly": "[1.0.0, )",
98-
"Microsoft.JavaScript.Hermes": "[0.0.0-2507.21007-eda7aef6, )",
98+
"Microsoft.JavaScript.Hermes": "[0.0.0-2511.7001-d7ca19b3, )",
9999
"Microsoft.SourceLink.GitHub": "[1.1.1, )",
100100
"Microsoft.WindowsAppSDK": "[1.7.250401001, )",
101101
"ReactCommon": "[1.0.0, )",

packages/e2e-test-app/windows/RNTesterApp/packages.chakra.lock.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
},
4747
"Microsoft.JavaScript.Hermes": {
4848
"type": "Transitive",
49-
"resolved": "0.0.0-2507.21007-eda7aef6",
50-
"contentHash": "3oyJXoPaayrtWSjBgnLFfVBrNcnvB3EJ1r2/K0yz9exmmESTTzWaCh8JlhX7fsjtMv/LpQxJOctHP0Ng2k8spQ=="
49+
"resolved": "0.0.0-2511.7001-d7ca19b3",
50+
"contentHash": "/EGy/gbTWpFZPZ4Z81QxbGQxpZhqiOE3qrnSokZRgXAyHivl15s7zZkRLOy9daDmVyEfanq7YBCOMi0ha58uQA=="
5151
},
5252
"Microsoft.Net.Native.Compiler": {
5353
"type": "Transitive",
@@ -197,7 +197,7 @@
197197
"dependencies": {
198198
"Common": "[1.0.0, )",
199199
"Folly": "[1.0.0, )",
200-
"Microsoft.JavaScript.Hermes": "[0.0.0-2507.21007-eda7aef6, )",
200+
"Microsoft.JavaScript.Hermes": "[0.0.0-2511.7001-d7ca19b3, )",
201201
"Microsoft.SourceLink.GitHub": "[1.1.1, )",
202202
"Microsoft.UI.Xaml": "[2.8.0, )",
203203
"ReactCommon": "[1.0.0, )",

packages/e2e-test-app/windows/RNTesterApp/packages.lock.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"UAP,Version=v10.0.17763": {
55
"Microsoft.JavaScript.Hermes": {
66
"type": "Direct",
7-
"requested": "[0.0.0-2507.21007-eda7aef6, )",
8-
"resolved": "0.0.0-2507.21007-eda7aef6",
9-
"contentHash": "3oyJXoPaayrtWSjBgnLFfVBrNcnvB3EJ1r2/K0yz9exmmESTTzWaCh8JlhX7fsjtMv/LpQxJOctHP0Ng2k8spQ=="
7+
"requested": "[0.0.0-2511.7001-d7ca19b3, )",
8+
"resolved": "0.0.0-2511.7001-d7ca19b3",
9+
"contentHash": "/EGy/gbTWpFZPZ4Z81QxbGQxpZhqiOE3qrnSokZRgXAyHivl15s7zZkRLOy9daDmVyEfanq7YBCOMi0ha58uQA=="
1010
},
1111
"Microsoft.NETCore.UniversalWindowsPlatform": {
1212
"type": "Direct",
@@ -198,7 +198,7 @@
198198
"dependencies": {
199199
"Common": "[1.0.0, )",
200200
"Folly": "[1.0.0, )",
201-
"Microsoft.JavaScript.Hermes": "[0.0.0-2507.21007-eda7aef6, )",
201+
"Microsoft.JavaScript.Hermes": "[0.0.0-2511.7001-d7ca19b3, )",
202202
"Microsoft.SourceLink.GitHub": "[1.1.1, )",
203203
"Microsoft.UI.Xaml": "[2.8.0, )",
204204
"ReactCommon": "[1.0.0, )",

0 commit comments

Comments
 (0)