Added support for modern inspector #15328
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds support for the React Native DevTools to the React Native for Windows. The RN DevTools are also known as "modern inspector" or "fusebox", and based on the Chrome DevTools. The implementation follows the React Native modern inspector requirements implemented for Android and iOS platforms.
The PR combines work from several developers:
Type of Change
Why
We want RNW developers to enjoy the same modern developer experience as Android and iOS React Native developers.
What
Runtime plumbing
ReactCommonoverrides now that upstream behavior works on Windows.ReactOptions,ReactHost,ReactInstanceWin, andOInstanceso they surface the modern inspector target and propagate pause/resume notifications to app code.ReactHostonly registers itself for debugging by adding the inspector "page" when theReactSettingshave theUseDirectDebuggerset totrue.ReactInspectorThreadthread for the inspector communication synchronization. (Android and iOS use UI thread)DebuggerNotifications.hto send notifications about the debugger state changes to allow UI updates.ReactInspectorPackagerConnectionDelegateto let Metro drive the modern inspector handshake for RNW.Hermes integration
HermesRuntimeTargetDelegateandHermesRuntimeAgentDelegate, mirroring upstream React Native code for Hermes but targeting the hermes-windows C API.RuntimeHolderandHermesRuntimeHolderto create/use inspector delegates only when needed and to tear them down safely.JsiApi.cppthat caused DevTools from loading scripts.UI / UX
DebuggerUIIslandso paused apps show overlays and selection handles.ReactRootView.DebuggingOverlayComponentViewrecursion that caused stack overflows when selecting deep component trees.TaskDispatchThreadshutdown so we don’t dereference freed objects when the JS thread disposes the dispatcher.Dev tooling
DevSupportManagernow manages modern inspector connections alongside legacy tooling.Jshortcut opens the modern inspector for RNW targets just like other platforms.loadNetworkResourceonReactInspectorHostTargetDelegate(ReactHost.cpp) to proxy requests via a Windows HTTP helper (e.g. reuseGetJavaScriptFromServerAsync) and stream results back through the providedNetworkRequestListener.Documentation
Testing
yarn start, pressJin Metro to attach the inspector, verified source debugging, console evaluation, CPU and memory profiling, and component tree selection with Hermes.Changelog
Microsoft Reviewers: Open in CodeFlow