Skip to content

Instantly share code, notes, and snippets.

@alexnj
Created March 27, 2023 18:42
Show Gist options
  • Save alexnj/8252c2e3cd4b9d5fd85cf188e07f64e0 to your computer and use it in GitHub Desktop.
Save alexnj/8252c2e3cd4b9d5fd85cf188e07f64e0 to your computer and use it in GitHub Desktop.
trace event patch
diff --git a/base/trace_event/common/trace_event_common.h b/base/trace_event/common/trace_event_common.h
index f2ee4d36b317d..7d5731053bbd7 100644
--- a/base/trace_event/common/trace_event_common.h
+++ b/base/trace_event/common/trace_event_common.h
@@ -965,6 +965,13 @@ struct BASE_EXPORT TraceTimestampTraits<::base::TimeTicks> {
TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, category_group, name, id, \
TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_COPY, \
arg1_name, arg1_val)
+#define TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP2( \
+ category_group, name, id, timestamp, arg1_name, arg1_val, \
+ arg2_name, arg2_val) \
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
+ TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, category_group, name, id, \
+ TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_COPY, \
+ arg1_name, arg1_val, arg2_name, arg2_val)
#define TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TIMESTAMP0( \
category_group, name, id, timestamp) \
INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
diff --git a/third_party/blink/renderer/core/timing/performance_user_timing.cc b/third_party/blink/renderer/core/timing/performance_user_timing.cc
index 1056e5c6f04d7..0ee17e6c6efc2 100644
--- a/third_party/blink/renderer/core/timing/performance_user_timing.cc
+++ b/third_party/blink/renderer/core/timing/performance_user_timing.cc
@@ -36,6 +36,7 @@
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/wtf/text/string_hash.h"
+#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
@@ -209,10 +210,12 @@ PerformanceMeasure* UserTiming::Measure(ScriptState* script_state,
unsigned hash = WTF::GetHash(measure_name);
WTF::AddFloatToHash(hash, start_time);
WTF::AddFloatToHash(hash, end_time);
+ WTF::String serialized_detail;
+ detail.ToString(serialized_detail);
- TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP1(
+ TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP2(
"blink.user_timing", measure_name.Utf8().c_str(), hash,
- unsafe_start_time, "startTime", start_time);
+ unsafe_start_time, "startTime", start_time, "detail", serialized_detail);
TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TIMESTAMP0(
"blink.user_timing", measure_name.Utf8().c_str(), hash,
unsafe_end_time);
diff --git a/third_party/blink/web_tests/inspector-protocol/timeline/user-timing-expected.txt b/third_party/blink/web_tests/inspector-protocol/timeline/user-timing-expected.txt
index 022ce7fb3734a..7b33b661db1b0 100644
--- a/third_party/blink/web_tests/inspector-protocol/timeline/user-timing-expected.txt
+++ b/third_party/blink/web_tests/inspector-protocol/timeline/user-timing-expected.txt
@@ -2,13 +2,23 @@ Tests render blocking status in script traces.
Recording started
Tracing complete
now to first
+undefined
now
+undefined
now to first
+undefined
first to second
+undefined
first to third
+undefined
first
+undefined
first to second
+undefined
second
+undefined
first to third
+undefined
third
+undefined
diff --git a/third_party/blink/web_tests/inspector-protocol/timeline/user-timing.js b/third_party/blink/web_tests/inspector-protocol/timeline/user-timing.js
index cbb8fc54cbc55..cf0316b44b47f 100644
--- a/third_party/blink/web_tests/inspector-protocol/timeline/user-timing.js
+++ b/third_party/blink/web_tests/inspector-protocol/timeline/user-timing.js
@@ -34,6 +34,7 @@
for (let e of sorted_events) {
testRunner.log(e["name"]);
+ testRunner.log(e["detail"]);
}
testRunner.completeTest();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment