Add CDP support for WebSocket events (Android)#57541
Open
huntie wants to merge 2 commits into
Open
Conversation
Summary: **Motivation** React Native DevTools' Network panel records fetch, XHR, and Image traffic, but WebSocket connections are invisible — neither the core CDP backend nor any existing inspector integration implements the CDP `Network.webSocket*` events. TODO: **Goal (as of this diff)**: Parity with Expo's current WS event coverage. Network Initiator is added down the stack. **This diff** Adds first-party reporting for six of the seven WebSocket CDP events (`webSocketCreated`, `webSocketWillSendHandshakeRequest`, `webSocketHandshakeResponseReceived`, `webSocketFrameSent`, `webSocketFrameReceived`, `webSocketClosed`), following the layering of the existing HTTP pipeline: - `CdpNetwork` (jsinspector-modern/network): new WebSocket CDP types and event params with `folly::dynamic` serialization. - `NetworkHandler`: new `onWebSocket*` emitters, active only while the Network domain is enabled. - `NetworkReporter` (react/networking): new `reportWebSocket*` platform-facing methods, compiled to no-ops unless `REACT_NATIVE_DEBUGGER_ENABLED`. - iOS: new `RCTInspectorWebSocketReporter` wrapper in React-CoreModules, with call sites in `RCTWebSocketModule`. Each connection gets a UUID request ID (associated object on `SRWebSocket`); the real handshake response is read from `SRWebSocket.receivedHTTPHeaders`. React-CoreModules gains a dependency on React-networking (no cycle: React-networking's transitive closure never reaches React-CoreModules). - Reporting is gated behind a new `fuseboxWebSocketEventsEnabled` feature flag (experimentation, default false), checked alongside `enableNetworkEventReporting` and a connected debugger at the call-site wrapper. **Notes** `webSocketFrameError` is intentionally omitted for now. Android integration follows separately. Changelog: [Internal] Differential Revision: D111561998
Summary: **Context** This stack implements WebSocket event debugging for the Network panel in React Native DevTools. **This diff** Follows the iOS implementation: reports the same six `Network.webSocket*` CDP events through the shared `NetworkReporter` C++ core, gated behind the same `fuseboxWebSocketEventsEnabled` feature flag. **Changes** - `InspectorNetworkReporter` (Kotlin): six new JNI-backed `reportWebSocket*` methods. Binary message payloads take a `ByteString` overload that defers base64 encoding behind `isDebuggingEnabled()`, matching the existing `reportDataReceived` pattern. - `JInspectorNetworkReporter` (JNI): bridges the new methods to `NetworkReporter::reportWebSocket*`. - `WebSocketModule`: each connection gets a UUID CDP request ID. `connect()` reports `webSocketCreated` and the handshake request headers; `onOpen` reports the real handshake response (OkHttp `Response` code and headers); `send`/`sendBinary`/`onMessage` report frames; `onClosed`/`onFailure` report `webSocketClosed`. All call sites funnel through a private `reportToInspector` helper that checks both feature flags, per the `NetworkEventUtil` convention of gating at the call-site layer. Changelog: [Internal] Differential Revision: D111561994
|
@huntie has exported this pull request. If you are a Meta employee, you can view the originating Diff in D111561994. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary:
Context
This stack implements WebSocket event debugging for the Network panel in React Native DevTools.
This diff
Follows the iOS implementation: reports the same six
Network.webSocket*CDP events through the sharedNetworkReporterC++ core, gated behind the samefuseboxWebSocketEventsEnabledfeature flag.Changes
InspectorNetworkReporter+JInspectorNetworkReporter: New JNI-backedreportWebSocket*methods bridging to the sharedNetworkReporterC++ core. Payload conversion costs (base64) are deferred until a debugger is attached.WebSocketModule: Reports connection lifecycle, real handshake headers (from the OkHttpRequest/Response), and sent/received messages, gated behind the same feature flags as iOS.Changelog: [Internal]
Differential Revision: D111561994