[iOS tracing] Inject iOS system log events into perfetto traces [chromium/src : main]

4 views
Skip to first unread message

Etienne Pierre-Doray (Gerrit)

unread,
May 15, 2026, 2:30:21 PM (6 days ago) May 15
to Justin Novosad, Chromium LUCI CQ, Rohit Rao, android-bu...@system.gserviceaccount.com, Justin Cohen, chromium...@chromium.org, spang...@chromium.org, tracing...@chromium.org, wfh+...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org
Attention needed from Justin Cohen, Justin Novosad and Rohit Rao

Etienne Pierre-Doray added 3 comments

File ios/chrome/browser/tracing/os_log_data_source.mm
Line 109, Patchset 5 (Latest): // We have no way to know whether other data sources have already added
// a track and thread descriptor for this thread, so we add one just in
// case. Perfetto's incremental state tracking handles deduplication
// automatically.
if (seen_threads.insert(thread_id).second) {
auto packet = ctx.NewTracePacket();
auto* track_descriptor = packet->set_track_descriptor();
track_descriptor->set_uuid(thread_track_uuid);
track_descriptor->set_parent_uuid(thread_track.parent_uuid);
auto* thread = track_descriptor->set_thread();
thread->set_pid(thread_track.pid);
thread->set_tid(thread_id);
const char* thread_name =
base::ThreadIdNameManager::GetInstance()->GetName(
base::PlatformThreadId(thread_id));
if (thread_name && thread_name[0] != '\0') {
thread->set_thread_name(thread_name);
} else {
// Fallback: if this thread is not known to Chromium, we must still
// provide a thread descriptor with some name for it.
thread->set_thread_name("Unknown Thread");
}
}
Etienne Pierre-Doray . unresolved

I find this awkward - emitting track event data is a lot of boilerplate when not using TRACE_EVENT macros directly.
I hit a similar problem for SystemMetricsSampler:
https://source.chromium.org/chromium/chromium/src/+/main:services/tracing/public/cpp/system_metrics_sampler.cc?q=systemmetricssampler&ss=chromium

I ended up using a combination of DataSource (to allow configuration and capturing Start/Stop) + using TRACE_EVENT directly, which is a bit weird (because it requires enabling both the category and the data source, which is the case here as well) but a lot simpler.
This could also be a simple TRACE_EVENT + TraceSessionObserver if you don't need a dedicated DataSourceConfig and state.

Line 145, Patchset 5 (Latest): track_event->add_categories("os_log");
Etienne Pierre-Doray . unresolved

Let's have this match the category in AddDataSourceConfigs()

File services/tracing/public/cpp/perfetto/perfetto_config.cc
Line 123, Patchset 5 (Latest): TRACE_DISABLED_BY_DEFAULT("os_log"))) {
Etienne Pierre-Doray . unresolved

Let's add the category in base/trace_event/builtin_categories.h
Nit: TRACE_DISABLED_BY_DEFAULT is mostly deprecated, I'd recommend seomthing like "ios.log.debug"

Open in Gerrit

Related details

Attention is currently required from:
  • Justin Cohen
  • Justin Novosad
  • Rohit Rao
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I4cd63ee4d6e46247e909d1ef0783555ef8732d79
Gerrit-Change-Number: 7748848
Gerrit-PatchSet: 5
Gerrit-Owner: Justin Novosad <ju...@chromium.org>
Gerrit-Reviewer: Etienne Pierre-Doray <etie...@chromium.org>
Gerrit-Reviewer: Justin Cohen <justi...@google.com>
Gerrit-Reviewer: Justin Novosad <ju...@chromium.org>
Gerrit-Reviewer: Rohit Rao <rohi...@chromium.org>
Gerrit-Attention: Justin Novosad <ju...@chromium.org>
Gerrit-Attention: Justin Cohen <justi...@google.com>
Gerrit-Attention: Rohit Rao <rohi...@chromium.org>
Gerrit-Comment-Date: Fri, 15 May 2026 18:30:14 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Justin Novosad (Gerrit)

unread,
May 15, 2026, 3:18:20 PM (6 days ago) May 15
to Chromium LUCI CQ, Rohit Rao, Etienne Pierre-Doray, android-bu...@system.gserviceaccount.com, Justin Cohen, chromium...@chromium.org, spang...@chromium.org, tracing...@chromium.org, wfh+...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org
Attention needed from Etienne Pierre-Doray, Justin Cohen and Rohit Rao

Justin Novosad added 3 comments

File ios/chrome/browser/tracing/os_log_data_source.mm
Line 109, Patchset 5: // We have no way to know whether other data sources have already added

// a track and thread descriptor for this thread, so we add one just in
// case. Perfetto's incremental state tracking handles deduplication
// automatically.
if (seen_threads.insert(thread_id).second) {
auto packet = ctx.NewTracePacket();
auto* track_descriptor = packet->set_track_descriptor();
track_descriptor->set_uuid(thread_track_uuid);
track_descriptor->set_parent_uuid(thread_track.parent_uuid);
auto* thread = track_descriptor->set_thread();
thread->set_pid(thread_track.pid);
thread->set_tid(thread_id);
const char* thread_name =
base::ThreadIdNameManager::GetInstance()->GetName(
base::PlatformThreadId(thread_id));
if (thread_name && thread_name[0] != '\0') {
thread->set_thread_name(thread_name);
} else {
// Fallback: if this thread is not known to Chromium, we must still
// provide a thread descriptor with some name for it.
thread->set_thread_name("Unknown Thread");
}
}
Etienne Pierre-Doray . resolved

I find this awkward - emitting track event data is a lot of boilerplate when not using TRACE_EVENT macros directly.
I hit a similar problem for SystemMetricsSampler:
https://source.chromium.org/chromium/chromium/src/+/main:services/tracing/public/cpp/system_metrics_sampler.cc?q=systemmetricssampler&ss=chromium

I ended up using a combination of DataSource (to allow configuration and capturing Start/Stop) + using TRACE_EVENT directly, which is a bit weird (because it requires enabling both the category and the data source, which is the case here as well) but a lot simpler.
This could also be a simple TRACE_EVENT + TraceSessionObserver if you don't need a dedicated DataSourceConfig and state.

Justin Novosad

Oh, wow. It's so much simpler that way. Thanks!

Done.

Line 145, Patchset 5: track_event->add_categories("os_log");
Etienne Pierre-Doray . resolved

Let's have this match the category in AddDataSourceConfigs()

Justin Novosad

Done

File services/tracing/public/cpp/perfetto/perfetto_config.cc
Line 123, Patchset 5: TRACE_DISABLED_BY_DEFAULT("os_log"))) {
Etienne Pierre-Doray . resolved

Let's add the category in base/trace_event/builtin_categories.h
Nit: TRACE_DISABLED_BY_DEFAULT is mostly deprecated, I'd recommend seomthing like "ios.log.debug"

Justin Novosad

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Etienne Pierre-Doray
  • Justin Cohen
  • Rohit Rao
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I4cd63ee4d6e46247e909d1ef0783555ef8732d79
    Gerrit-Change-Number: 7748848
    Gerrit-PatchSet: 6
    Gerrit-Owner: Justin Novosad <ju...@chromium.org>
    Gerrit-Reviewer: Etienne Pierre-Doray <etie...@chromium.org>
    Gerrit-Reviewer: Justin Cohen <justi...@google.com>
    Gerrit-Reviewer: Justin Novosad <ju...@chromium.org>
    Gerrit-Reviewer: Rohit Rao <rohi...@chromium.org>
    Gerrit-Attention: Justin Cohen <justi...@google.com>
    Gerrit-Attention: Rohit Rao <rohi...@chromium.org>
    Gerrit-Attention: Etienne Pierre-Doray <etie...@chromium.org>
    Gerrit-Comment-Date: Fri, 15 May 2026 19:18:15 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Etienne Pierre-Doray <etie...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Etienne Pierre-Doray (Gerrit)

    unread,
    May 19, 2026, 3:24:58 PM (2 days ago) May 19
    to Justin Novosad, Chromium LUCI CQ, Rohit Rao, android-bu...@system.gserviceaccount.com, Justin Cohen, chromium...@chromium.org, spang...@chromium.org, tracing...@chromium.org, wfh+...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org
    Attention needed from Justin Cohen, Justin Novosad and Rohit Rao

    Etienne Pierre-Doray added 3 comments

    File base/test/tracing/test_trace_processor.cc
    Line 161, Patchset 7 (Latest): session_->FlushBlocking();
    Etienne Pierre-Doray . unresolved

    I'd expect this to happen already as part of StopBlocking below.

    File ios/chrome/browser/tracing/os_log_data_source.mm
    Line 86, Patchset 7 (Latest): auto thread_track = perfetto::ThreadTrack::ForThread(thread_id);
    Etienne Pierre-Doray . unresolved

    Nit: You might want to create a named track scoped by the ThreadTrack, e.g.
    `NamedTrack("OSLog", 0, thread_track)` if you want this to appear separately from the regular thread's trace events.

    File services/tracing/public/cpp/perfetto/perfetto_data_source_names.h
    Line 34, Patchset 7 (Latest):inline constexpr char kOsLogSourceName[] = "org.chromium.os_log";
    Etienne Pierre-Doray . unresolved

    I think the data source name should have ios in the name as well?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Justin Cohen
    • Justin Novosad
    • Rohit Rao
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I4cd63ee4d6e46247e909d1ef0783555ef8732d79
      Gerrit-Change-Number: 7748848
      Gerrit-PatchSet: 7
      Gerrit-Owner: Justin Novosad <ju...@chromium.org>
      Gerrit-Reviewer: Etienne Pierre-Doray <etie...@chromium.org>
      Gerrit-Reviewer: Justin Cohen <justi...@google.com>
      Gerrit-Reviewer: Justin Novosad <ju...@chromium.org>
      Gerrit-Reviewer: Rohit Rao <rohi...@chromium.org>
      Gerrit-Attention: Justin Novosad <ju...@chromium.org>
      Gerrit-Attention: Justin Cohen <justi...@google.com>
      Gerrit-Attention: Rohit Rao <rohi...@chromium.org>
      Gerrit-Comment-Date: Tue, 19 May 2026 19:24:53 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages