Namespace Perfetto usage (#53424)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53424

Use the namespaced version of these macros to avoid symbol conflicts when multiple instances of `PERFETTO_DEFINE_CATEGORIES` are in the same binary.

The current macro is effectively deprecated: https://github.com/a6f/perfetto_protos/blob/master/CHANGELOG#L691-L696

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D80697205

fbshipit-source-id: 713fec4d41137ddd2f025c7e7130dc44c5a3a656
This commit is contained in:
Pieter De Baets authored and Facebook GitHub Bot committed 2025-08-25 11:16:51 -07:00
1 parent 42b94fc709
commit 870836ff84
7 files changed
+10 -11

No files matched your search

@@ -27,8 +27,6 @@ const std::string JS_SAMPLING_TRACK = "JS Sampling";
const int SAMPLING_HZ = 1000;
using perfetto::TrackEvent;
#if defined(__ANDROID__)
std::string getApplicationId() {
pid_t pid = getpid();
@@ -23,8 +23,6 @@ const int SAMPLING_HZ = 100;
int64_t hermesDeltaTime = 0;
using perfetto::TrackEvent;
uint64_t hermesToPerfettoTime(int64_t hermesTs) {
if (hermesDeltaTime == 0) {
hermesDeltaTime = TrackEvent::GetTraceTimeNs() -
@@ -113,7 +111,7 @@ void HermesPerfettoDataSource::OnStart(const StartArgs&) {
"react-native",
perfetto::DynamicString{"Profiling Started"},
getPerfettoWebPerfTrackSync("JS Sampling"),
perfetto::TrackEvent::GetTraceTimeNs());
TrackEvent::GetTraceTimeNs());
}
void HermesPerfettoDataSource::OnFlush(const FlushArgs&) {
@@ -29,7 +29,7 @@ void initializePerfetto() {
args.backends |= perfetto::kSystemBackend;
args.use_monotonic_clock = true;
perfetto::Tracing::Initialize(args);
perfetto::TrackEvent::Register();
TrackEvent::Register();
});
HermesPerfettoDataSource::RegisterDataSource();
@@ -42,7 +42,7 @@ static perfetto::Track createTrack(const std::string& trackName) {
auto track = perfetto::Track(trackId++);
auto desc = track.Serialize();
desc.set_name(trackName);
perfetto::TrackEvent::SetTrackDescriptor(track, desc);
TrackEvent::SetTrackDescriptor(track, desc);
return track;
}
@@ -9,6 +9,7 @@
#include "ReactPerfettoCategories.h"
PERFETTO_TRACK_EVENT_STATIC_STORAGE();
PERFETTO_TRACK_EVENT_STATIC_STORAGE_IN_NAMESPACE(facebook::react);
PERFETTO_USE_CATEGORIES_FROM_NAMESPACE(facebook::react);
#endif
@@ -11,7 +11,8 @@
#include <perfetto.h>
PERFETTO_DEFINE_CATEGORIES(
PERFETTO_DEFINE_CATEGORIES_IN_NAMESPACE(
facebook::react,
perfetto::Category("react-native")
.SetDescription("User timing events from React Native"));
@@ -23,7 +23,7 @@ void initializePerfetto() {
#endif
args.use_monotonic_clock = true;
perfetto::Tracing::Initialize(args);
perfetto::TrackEvent::Register();
facebook::react::TrackEvent::Register();
});
}
@@ -18,7 +18,8 @@
#if WITH_PERFETTO
#include <perfetto.h>
PERFETTO_DEFINE_CATEGORIES(
PERFETTO_DEFINE_CATEGORIES_IN_NAMESPACE(
facebook::react,
perfetto::Category("rncxx").SetDescription("Events from RN/Granite"));
void initializePerfetto();