From b934a50e8c443300cd6b76b7c65e2ac21ad8ab18 Mon Sep 17 00:00:00 2001 From: Giovanni Cappellotto Date: Fri, 23 Oct 2026 11:06:21 -0700 Subject: [PATCH] Initialize Perfetto with the in-process backend on iOS Summary: `initializePerfetto()` registers Perfetto's system backend on every platform. iOS and the other Apple device platforms have no system tracing service, so the system producer never connects and keeps retrying in the background for the app's lifetime, and a tracer in the app that starts a session without naming a backend gets the system one and records nothing. On those platforms, register the in-process backend instead. Other platforms, including macOS, are unchanged. React Native's own `ReactCxxPlatform/react/profiling/perfetto.cpp` already registers the in-process backend on every platform but Android; this change is narrower and keeps the system backend on macOS and other desktop platforms, where `traced` can run. Changelog: [Internal] Reviewed By: christophpurrer, javache Differential Revision: D126071088 --- .../reactperflogger/reactperflogger/ReactPerfetto.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/react-native/ReactCommon/reactperflogger/reactperflogger/ReactPerfetto.cpp b/packages/react-native/ReactCommon/reactperflogger/reactperflogger/ReactPerfetto.cpp index deeab6b22c4d..77ebb2845ada 100644 --- a/packages/react-native/ReactCommon/reactperflogger/reactperflogger/ReactPerfetto.cpp +++ b/packages/react-native/ReactCommon/reactperflogger/reactperflogger/ReactPerfetto.cpp @@ -12,6 +12,10 @@ #include #include +#ifdef __APPLE__ +#include +#endif + #include "FuseboxPerfettoDataSource.h" #include "HermesPerfettoDataSource.h" #include "ReactPerfettoCategories.h" @@ -26,7 +30,13 @@ void initializePerfetto() { // is only used in tracing build, large buffers are okay // for now. args.shmem_size_hint_kb = 20 * 1024; +#if defined(__APPLE__) && TARGET_OS_IPHONE + // iOS and the other Apple device platforms have no system tracing + // service. + args.backends |= perfetto::kInProcessBackend; +#else args.backends |= perfetto::kSystemBackend; +#endif args.use_monotonic_clock = true; perfetto::Tracing::Initialize(args); TrackEvent::Register();