Skip to content

Commit

Permalink
[Tracing] Start Java tracing only after native tracing has started
Browse files Browse the repository at this point in the history
Enabling Java TraceEvents when the tracing session has been only set up
(but not started) leads to weird data races in tests (see the bug).

This CL turns on Java events after the tracing has started and
re-enables the flaky test.

Bug: 1472381
Change-Id: Ic40e6fb647b45822d3d0290a223b2dfe0564fad3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4793489
Commit-Queue: Mikhail Khokhlov <khokhlov@google.com>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1185150}
  • Loading branch information
Mikhail Khokhlov authored and Chromium LUCI CQ committed Aug 18, 2023
1 parent 48336f0 commit 5abaae5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 2 additions & 0 deletions base/android/trace_event_binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ class TraceEnabledObserver : public perfetto::TrackEventSessionObserver {
args.config->chrome_config().trace_config());
event_name_filtering_per_session_[args.internal_instance_index] =
trace_config.IsEventPackageNameFilterEnabled();
}

void OnStart(const perfetto::DataSourceBase::StartArgs&) override {
JNIEnv* env = base::android::AttachCurrentThread();
base::android::Java_TraceEvent_setEnabled(env, true);
base::android::Java_TraceEvent_setEventNameFilteringEnabled(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1737,13 +1737,7 @@ IN_PROC_BROWSER_TEST_F(ProtoBackgroundTracingTest,
background_tracing_helper.WaitForScenarioIdle();
}

// TODO(https://crbug.com/1472381): Flaky on Android
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_ProtoTraceReceived DISABLED_ProtoTraceReceived
#else
#define MAYBE_ProtoTraceReceived ProtoTraceReceived
#endif
IN_PROC_BROWSER_TEST_F(ProtoBackgroundTracingTest, MAYBE_ProtoTraceReceived) {
IN_PROC_BROWSER_TEST_F(ProtoBackgroundTracingTest, ProtoTraceReceived) {
TestBackgroundTracingHelper background_tracing_helper;

std::unique_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig();
Expand Down

0 comments on commit 5abaae5

Please sign in to comment.