From 403bbae1f2483bc442dcc8f7f370a7b8e7155417 Mon Sep 17 00:00:00 2001 From: Moti Zilberman Date: Wed, 10 Apr 2024 04:04:12 -0700 Subject: [PATCH] Stub support for Tracing start/end methods and events (#44004) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44004 Changelog: [Internal] Adds the minimal boilerplate needed to support taking an (empty) recording using Chrome DevTools's Performance panel. Reviewed By: hoxyq Differential Revision: D55925170 fbshipit-source-id: 8f5048bd545be3ef410b794573ef7b7bc92f73cc --- .../jsinspector-modern/HostAgent.cpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/react-native/ReactCommon/jsinspector-modern/HostAgent.cpp b/packages/react-native/ReactCommon/jsinspector-modern/HostAgent.cpp index 5d9ddda55be..bbbe14edf76 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/HostAgent.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/HostAgent.cpp @@ -116,6 +116,26 @@ void HostAgent::handleRequest(const cdp::PreparsedRequest& req) { shouldSendOKResponse = true; isFinishedHandlingRequest = true; + } else if (req.method == "Tracing.start") { + // @cdp Tracing.start is implemented as a stub only. + frontendChannel_(cdp::jsonNotification( + // @cdp Tracing.bufferUsage is implemented as a stub only. + "Tracing.bufferUsage", + folly::dynamic::object("percentFull", 0)("eventCount", 0)("value", 0))); + shouldSendOKResponse = true; + isFinishedHandlingRequest = true; + } else if (req.method == "Tracing.end") { + // @cdp Tracing.end is implemented as a stub only. + frontendChannel_(cdp::jsonNotification( + // @cdp Tracing.dataCollected is implemented as a stub only. + "Tracing.dataCollected", + folly::dynamic::object("value", folly::dynamic::array()))); + frontendChannel_(cdp::jsonNotification( + // @cdp Tracing.tracingComplete is implemented as a stub only. + "Tracing.tracingComplete", + folly::dynamic::object("dataLossOccurred", false))); + shouldSendOKResponse = true; + isFinishedHandlingRequest = true; } if (!isFinishedHandlingRequest && instanceAgent_ &&