0

Revert "[tracing] Use trace thread for gpu process to initialize tracing"

This reverts commit 44d8036a9d.

Reason for revert: This is likely causing failures in a ChromeOS perfetto test. b/401194534.

Original change's description:
> [tracing] Use trace thread for gpu process to initialize tracing
>
> For non-zygote child gpu thread, start the trace thread in
> ContentMainRunnerImpl() directly.
>
> For zygote child gpu thread, start the trace thread in RunZygote after
> zygote fork and featurelist init.
>
> For Linux & ChromeOS, stop and restart the trace thread when entering
> sandbox. Restarting trace thread has a caveat that delayed tasks would
> will be lost unless we save them.
>
> This is [3/?] CL of enabling tracing prior to sandboxing.
>
> Bug: 380411640
> Change-Id: I89fa94f63a709de0e3da4f8759098c9fff813bee
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6180639
> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
> Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
> Commit-Queue: Kramer Ge <fangzhoug@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1428704}

Bug: 380411640
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I810beb2c5903951b78d69f30c050f1797c8b28cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6334493
Owners-Override: Scott Haseley <shaseley@google.com>
Commit-Queue: Scott Haseley <shaseley@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1429173}
This commit is contained in:
Scott Haseley
2025-03-06 14:28:41 -08:00
committed by Chromium LUCI CQ
parent ca8fa3d68d
commit e0d4e34c2c
5 changed files with 31 additions and 62 deletions

@ -47,15 +47,17 @@ using base::trace_event::TraceLog;
} // namespace
bool g_tracing_initialized_after_featurelist = false;
bool g_tracing_with_thread = false;
bool IsTracingInitialized() {
return g_tracing_initialized_after_featurelist;
}
void EnableStartupTracingIfNeeded(bool with_thread) {
void EnableStartupTracingIfNeeded() {
RegisterTracedValueProtoWriter();
// Create the PerfettoTracedProcess.
PerfettoTracedProcess::MaybeCreateInstance();
// Initialize the client library's TrackRegistry to support trace points
// during startup tracing. We don't setup the client library completely here
// yet, because we don't have field trials loaded yet (which influence which
@ -64,14 +66,6 @@ void EnableStartupTracingIfNeeded(bool with_thread) {
// setting up the client library?
perfetto::internal::TrackRegistry::InitializeInstance();
// Create the PerfettoTracedProcess.
if (with_thread) {
g_tracing_with_thread = true;
PerfettoTracedProcess::MaybeCreateInstanceWithThread();
} else {
PerfettoTracedProcess::MaybeCreateInstance();
}
// Ensure TraceLog is initialized first.
// https://crbug.com/764357
TraceLog::GetInstance();
@ -112,9 +106,7 @@ void InitTracingPostFeatureList(bool enable_consumer) {
DCHECK(base::FeatureList::GetInstance());
// Create the PerfettoTracedProcess.
if (!g_tracing_with_thread) {
PerfettoTracedProcess::MaybeCreateInstance();
}
PerfettoTracedProcess::MaybeCreateInstance();
PerfettoTracedProcess::Get().OnThreadPoolAvailable(enable_consumer);
#if BUILDFLAG(IS_WIN)
tracing::EnableETWExport();

@ -35,8 +35,7 @@ bool COMPONENT_EXPORT(TRACING_CPP) IsTracingInitialized();
// TODO(eseckler): Consider allocating the SMB in parent processes outside the
// sandbox and supply it via the command line. Then, we can revert to call this
// earlier and from fewer places again.
void COMPONENT_EXPORT(TRACING_CPP)
EnableStartupTracingIfNeeded(bool with_thread = false);
void COMPONENT_EXPORT(TRACING_CPP) EnableStartupTracingIfNeeded();
// Enable startup tracing for the current process with the provided config. Sets
// up ProducerClient and trace event and/or sampler profiler data sources, and