From d6e70791d872569a31e491de4d3b16b1fa612f2f Mon Sep 17 00:00:00 2001 From: Ruslan Lesiutin Date: Thu, 6 Nov 2025 04:25:36 -0800 Subject: [PATCH] No-op by default (#54335) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/54335 # Changelog: [Internal] Actually gate the task scheduling logic, so that the implementation is a no-op by default, if we are not tracing in the background or have Runtime CDP domain enabled. The drawback is that we might loose stack traces for some component renders, if the corresponding JSX declaration was called before we've enabled the `console.createTask()`. Reviewed By: huntie Differential Revision: D85849862 fbshipit-source-id: 2c3e8119ca0ab5677b2c00e83b9a616d5e924db1 --- .../jsinspector-modern/RuntimeTargetConsole.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/react-native/ReactCommon/jsinspector-modern/RuntimeTargetConsole.cpp b/packages/react-native/ReactCommon/jsinspector-modern/RuntimeTargetConsole.cpp index 85511d92053..ac9c8c84362 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/RuntimeTargetConsole.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/RuntimeTargetConsole.cpp @@ -555,7 +555,7 @@ jsi::Value consoleCreateTask( const jsi::Value* args, size_t count, RuntimeTargetDelegate& runtimeTargetDelegate, - bool /* enabled */) { + bool enabled) { if (count < 1 || !args[0].isString()) { throw JSError(runtime, "First argument must be a non-empty string"); } @@ -565,9 +565,12 @@ jsi::Value consoleCreateTask( } jsi::Object task{runtime}; - auto taskContext = std::make_shared( - runtime, runtimeTargetDelegate, name); - taskContext->schedule(); + std::shared_ptr taskContext = nullptr; + if (enabled) { + taskContext = std::make_shared( + runtime, runtimeTargetDelegate, name); + taskContext->schedule(); + } task.setProperty( runtime,