Revert "Use Clock in internal EventTracer"
This reverts commit ed6507b57e55cd3f1b590f0ae7df2c6bcab3c699.
Reason for revert: Hit problems in the chromium roll:
[62113/82444] CXX obj/remoting/host/remoting_me2me_host_static/remoting_me2me_host.o
../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/remoting/host/remoting_me2me_host_static/remoting_me2me_host.o.d -DREMOT...(too long)
../../remoting/host/remoting_me2me_host.cc:2201:22: error: 'SetupInternalTracer' is deprecated: use SetupInternalTracer(const Environment&, bool) [-Werror,-Wdeprecated-declarations]
2201 | webrtc::tracing::SetupInternalTracer();
| ^
../../third_party/webrtc/rtc_base/event_tracer.h:84:3: note: 'SetupInternalTracer' has been explicitly marked deprecated here
84 | [[deprecated("use SetupInternalTracer(const Environment&, bool)")]]
| ^
1 error generated.
exit=1
error: cannot make progress due to previous 1 errors: exit=1
Original change's description:
> Use Clock in internal EventTracer
>
> This requires changes to X11 capturers due to a poorly defined macro in
> X11.
>
> Bug: webrtc:42223992
> Change-Id: If9f8102386dc93142f9facfba21deb1f6a6a6964
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/445903
> Auto-Submit: Evan Shrubsole <eshr@webrtc.org>
> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
> Commit-Queue: Evan Shrubsole <eshr@webrtc.org>
> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#46819}
Bug: webrtc:42223992
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: Icef9acd1413e9490fb5203fa607379404ace2d68
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/446760
Auto-Submit: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#46825}
diff --git a/modules/desktop_capture/linux/x11/screen_capturer_x11.cc b/modules/desktop_capture/linux/x11/screen_capturer_x11.cc
index c12bc76..9affb03 100644
--- a/modules/desktop_capture/linux/x11/screen_capturer_x11.cc
+++ b/modules/desktop_capture/linux/x11/screen_capturer_x11.cc
@@ -17,12 +17,10 @@
#include <X11/extensions/Xrandr.h>
#include <X11/extensions/damagewire.h>
#include <X11/extensions/randr.h>
-// X11 creates a CurrentTime macro, which causes compilation errors when
-// including webrtc::Clock.
-#undef CurrentTime
#include <dlfcn.h>
#include <cstdint>
+#include <cstring>
#include <memory>
#include <utility>
diff --git a/modules/desktop_capture/linux/x11/window_capturer_x11.cc b/modules/desktop_capture/linux/x11/window_capturer_x11.cc
index fcc4113..fca67df 100644
--- a/modules/desktop_capture/linux/x11/window_capturer_x11.cc
+++ b/modules/desktop_capture/linux/x11/window_capturer_x11.cc
@@ -15,9 +15,6 @@
#include <X11/Xutil.h>
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/composite.h>
-// X11 creates a CurrentTime macro, which causes compilation errors when
-// including webrtc::Clock.
-#undef CurrentTime
#include <cstring>
#include <memory>
@@ -25,7 +22,6 @@
#include <utility>
#include "api/scoped_refptr.h"
-#include "media/base/video_common.h"
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capture_types.h"
#include "modules/desktop_capture/desktop_capturer.h"
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index 309bc31..0f1b5a7 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -223,14 +223,9 @@
":rtc_event",
":timeutils",
"../api:sequence_checker",
- "../api/environment",
"../api/units:time_delta",
- "../api/units:timestamp",
- "../system_wrappers",
"synchronization:mutex",
"system:rtc_export",
- "//third_party/abseil-cpp/absl/base:core_headers",
- "//third_party/abseil-cpp/absl/base:nullability",
"//third_party/abseil-cpp/absl/strings:string_view",
]
all_dependent_configs = [ "//third_party/perfetto/gn:public_config" ]
diff --git a/rtc_base/event_tracer.cc b/rtc_base/event_tracer.cc
index dd8e293..c13d0ce 100644
--- a/rtc_base/event_tracer.cc
+++ b/rtc_base/event_tracer.cc
@@ -11,9 +11,7 @@
#include "rtc_base/event_tracer.h"
#include <cstdio>
-#include <optional>
-#include "api/environment/environment.h"
#include "api/units/time_delta.h"
#include "rtc_base/trace_event.h"
@@ -23,13 +21,13 @@
#else
#include <atomic>
#include <cinttypes>
+#include <cstdint>
#include <cstring>
#include <string>
#include <vector>
#include "absl/strings/string_view.h"
#include "api/sequence_checker.h"
-#include "api/units/timestamp.h"
#include "rtc_base/checks.h"
#include "rtc_base/event.h"
#include "rtc_base/logging.h"
@@ -37,7 +35,7 @@
#include "rtc_base/platform_thread_types.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
-#include "system_wrappers/include/clock.h"
+#include "rtc_base/time_utils.h"
#endif
namespace webrtc {
@@ -94,8 +92,7 @@
#if defined(RTC_USE_PERFETTO)
// TODO(bugs.webrtc.org/15917): Implement for perfetto.
namespace tracing {
-void SetupInternalTracer(bool) {}
-void SetupInternalTracer(const Environment&, bool) {}
+void SetupInternalTracer(bool enable_all_categories) {}
bool StartInternalCapture(absl::string_view filename) {
return false;
}
@@ -119,9 +116,6 @@
// TODO(pbos): Log metadata for all threads, etc.
class EventLogger final {
public:
- explicit EventLogger(std::optional<Environment> env)
- : env_(env),
- clock_(env.has_value() ? env->clock() : *Clock::GetRealTimeClock()) {}
~EventLogger() { RTC_DCHECK(thread_checker_.IsCurrent()); }
void AddTraceEvent(const char* name,
@@ -131,9 +125,9 @@
const char** arg_names,
const unsigned char* arg_types,
const unsigned long long* arg_values,
+ uint64_t timestamp,
int /* pid */,
PlatformThreadId thread_id) {
- Timestamp now = clock_.CurrentTime();
std::vector<TraceArg> args(num_args);
for (int i = 0; i < num_args; ++i) {
TraceArg& arg = args[i];
@@ -155,7 +149,7 @@
.category_enabled = category_enabled,
.phase = phase,
.args = args,
- .timestamp = now,
+ .timestamp = timestamp,
.pid = 1,
.tid = thread_id});
}
@@ -212,7 +206,7 @@
"%s"
"}\n",
has_logged_event ? "," : " ", e.name, e.category_enabled,
- e.phase, e.timestamp.us(), e.pid, e.tid, args_str.c_str());
+ e.phase, e.timestamp, e.pid, e.tid, args_str.c_str());
has_logged_event = true;
}
if (shutting_down)
@@ -291,7 +285,7 @@
const unsigned char* category_enabled;
char phase;
std::vector<TraceArg> args;
- Timestamp timestamp;
+ uint64_t timestamp;
int pid;
PlatformThreadId tid;
};
@@ -358,10 +352,6 @@
Mutex mutex_;
std::vector<TraceEvent> trace_events_ RTC_GUARDED_BY(mutex_);
- // TODO(https://issues.webrtc.org/481963632): Make environment non-optional
- // and remove `clock_` once an environment is required.
- std::optional<Environment> env_;
- Clock& clock_;
PlatformThread logging_thread_;
Event shutdown_event_;
SequenceChecker thread_checker_;
@@ -401,25 +391,16 @@
return;
g_event_logger.load()->AddTraceEvent(name, category_enabled, phase, num_args,
- arg_names, arg_types, arg_values, 1,
- CurrentThreadId());
+ arg_names, arg_types, arg_values,
+ TimeMicros(), 1, CurrentThreadId());
}
} // namespace
void SetupInternalTracer(bool enable_all_categories) {
EventLogger* null_logger = nullptr;
- RTC_CHECK(g_event_logger.compare_exchange_strong(
- null_logger, new EventLogger(std::nullopt)));
- SetupEventTracer(enable_all_categories ? InternalEnableAllCategories
- : InternalGetCategoryEnabled,
- InternalAddTraceEvent);
-}
-
-void SetupInternalTracer(const Environment& env, bool enable_all_categories) {
- EventLogger* null_logger = nullptr;
- RTC_CHECK(g_event_logger.compare_exchange_strong(null_logger,
- new EventLogger(env)));
+ RTC_CHECK(
+ g_event_logger.compare_exchange_strong(null_logger, new EventLogger()));
SetupEventTracer(enable_all_categories ? InternalEnableAllCategories
: InternalGetCategoryEnabled,
InternalAddTraceEvent);
diff --git a/rtc_base/event_tracer.h b/rtc_base/event_tracer.h
index f8f1d6f..a13cdea 100644
--- a/rtc_base/event_tracer.h
+++ b/rtc_base/event_tracer.h
@@ -29,7 +29,6 @@
#include <stdio.h>
#include "absl/strings/string_view.h"
-#include "api/environment/environment.h"
#include "rtc_base/system/rtc_export.h"
namespace webrtc {
@@ -76,14 +75,7 @@
namespace tracing {
// Set up internal event tracer.
// TODO(webrtc:15917): Implement for perfetto.
-RTC_EXPORT void SetupInternalTracer(const Environment& env,
- bool enable_all_categories = true);
-
-// TODO(https://issues.webrtc.org/481963632): Remove once this is no longer
-// used.
-[[deprecated("use SetupInternalTracer(const Environment&, bool)")]]
RTC_EXPORT void SetupInternalTracer(bool enable_all_categories = true);
-
RTC_EXPORT bool StartInternalCapture(absl::string_view filename);
RTC_EXPORT void StartInternalCaptureToFile(FILE* file);
RTC_EXPORT void StopInternalCapture();
@@ -93,4 +85,5 @@
} // namespace webrtc
+
#endif // RTC_BASE_EVENT_TRACER_H_
diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn
index 21687fa..cb8156e 100644
--- a/sdk/android/BUILD.gn
+++ b/sdk/android/BUILD.gn
@@ -859,7 +859,6 @@
"../../api/crypto:options",
"../../api/environment",
"../../api/environment:deprecated_global_field_trials",
- "../../api/environment:environment_factory",
"../../api/neteq:neteq_api",
"../../api/rtc_event_log",
"../../api/rtc_event_log:rtc_event_log_factory",
diff --git a/sdk/android/src/jni/pc/peer_connection_factory.cc b/sdk/android/src/jni/pc/peer_connection_factory.cc
index bd26b84..f449a98 100644
--- a/sdk/android/src/jni/pc/peer_connection_factory.cc
+++ b/sdk/android/src/jni/pc/peer_connection_factory.cc
@@ -33,7 +33,6 @@
#include "api/enable_media.h"
#include "api/environment/deprecated_global_field_trials.h"
#include "api/environment/environment.h"
-#include "api/environment/environment_factory.h"
#include "api/fec_controller.h"
#include "api/media_stream_interface.h"
#include "api/neteq/neteq_factory.h"
@@ -218,8 +217,7 @@
}
static void JNI_PeerConnectionFactory_InitializeInternalTracer(JNIEnv* jni) {
- Environment env = CreateEnvironment();
- tracing::SetupInternalTracer(env);
+ tracing::SetupInternalTracer();
}
static jboolean JNI_PeerConnectionFactory_StartInternalTracingCapture(
diff --git a/sdk/objc/api/peerconnection/RTCTracing.mm b/sdk/objc/api/peerconnection/RTCTracing.mm
index afef157..dca21a9 100644
--- a/sdk/objc/api/peerconnection/RTCTracing.mm
+++ b/sdk/objc/api/peerconnection/RTCTracing.mm
@@ -10,13 +10,10 @@
#import "RTCTracing.h"
-#include "api/environment/environment.h"
-#include "api/environment/environment_factory.h"
#include "rtc_base/event_tracer.h"
void RTCSetupInternalTracer(void) {
- webrtc::Environment env = webrtc::CreateEnvironment();
- webrtc::tracing::SetupInternalTracer(env);
+ webrtc::tracing::SetupInternalTracer();
}
BOOL RTCStartInternalCapture(NSString *filePath) {
diff --git a/system_wrappers/BUILD.gn b/system_wrappers/BUILD.gn
index 12a5a82..656ff3b 100644
--- a/system_wrappers/BUILD.gn
+++ b/system_wrappers/BUILD.gn
@@ -34,7 +34,6 @@
"../rtc_base:timeutils",
"../rtc_base/synchronization:mutex",
"../rtc_base/system:rtc_export",
- "//third_party/abseil-cpp/absl/base:nullability",
]
if (is_win) {
libs += [ "winmm.lib" ]
diff --git a/system_wrappers/include/clock.h b/system_wrappers/include/clock.h
index 52457f3..5f1c665 100644
--- a/system_wrappers/include/clock.h
+++ b/system_wrappers/include/clock.h
@@ -14,7 +14,6 @@
#include <atomic>
#include <cstdint>
-#include "absl/base/nullability.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "rtc_base/numerics/divide_round.h"
@@ -67,7 +66,7 @@
}
// Returns an instance of the real-time system clock implementation.
- static Clock* absl_nonnull GetRealTimeClock();
+ static Clock* GetRealTimeClock();
};
class SimulatedClock : public Clock {
diff --git a/system_wrappers/source/clock.cc b/system_wrappers/source/clock.cc
index cbfc652..9290d19 100644
--- a/system_wrappers/source/clock.cc
+++ b/system_wrappers/source/clock.cc
@@ -13,7 +13,6 @@
#include <atomic>
#include <cstdint>
-#include "absl/base/nullability.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "rtc_base/checks.h"
@@ -63,7 +62,7 @@
}
};
-Clock* absl_nonnull Clock::GetRealTimeClock() {
+Clock* Clock::GetRealTimeClock() {
static Clock* const clock = new RealTimeClock();
return clock;
}
diff --git a/test/BUILD.gn b/test/BUILD.gn
index 0d371c7..28acb9c 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -591,13 +591,11 @@
]
deps = [
- ":create_test_environment",
":fileutils",
":perf_test",
":resources_dir_flag",
":test_flags",
":test_support",
- "../api/environment",
"../api/test/metrics:chrome_perf_dashboard_metrics_exporter",
"../api/test/metrics:global_metrics_logger_and_exporter",
"../api/test/metrics:metric",
diff --git a/test/test_main_lib.cc b/test/test_main_lib.cc
index b824321..caf7751 100644
--- a/test/test_main_lib.cc
+++ b/test/test_main_lib.cc
@@ -23,7 +23,6 @@
#include "absl/flags/flag.h"
#include "absl/strings/string_view.h"
-#include "api/environment/environment.h"
#include "api/test/metrics/chrome_perf_dashboard_metrics_exporter.h"
#include "api/test/metrics/global_metrics_logger_and_exporter.h"
#include "api/test/metrics/metric.h"
@@ -35,7 +34,6 @@
#include "rtc_base/ssl_adapter.h"
#include "rtc_base/ssl_stream_adapter.h"
#include "system_wrappers/include/metrics.h"
-#include "test/create_test_environment.h"
#include "test/gtest.h"
#include "test/test_flags.h"
#include "test/testsupport/file_utils.h"
@@ -297,8 +295,7 @@
<< trace_output_file << "\"";
tracing_session_->StartBlocking();
#else
- Environment env = CreateTestEnvironment();
- tracing::SetupInternalTracer(env);
+ tracing::SetupInternalTracer();
tracing::StartInternalCapture(trace_output_file);
#endif
}