Commit f80153f5 authored by Alexei Filippov's avatar Alexei Filippov Committed by Commit Bot

DevTools: Make sure RunMicrotasks event is nested into RunTask.

BUG=953914

Change-Id: Ifd1a96df53a3634ce192016c12f6371cf648ad58
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1572937Reviewed-by: default avatarPaul Irish <paulirish@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Commit-Queue: Alexei Filippov <alph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652178}
parent b62f7828
...@@ -78,11 +78,6 @@ void TaskAnnotator::RunTask(const char* trace_event_name, ...@@ -78,11 +78,6 @@ void TaskAnnotator::RunTask(const char* trace_event_name,
TRACE_DISABLED_BY_DEFAULT("toplevel.flow"), trace_event_name, TRACE_DISABLED_BY_DEFAULT("toplevel.flow"), trace_event_name,
TRACE_ID_MANGLE(GetTaskTraceID(*pending_task)), TRACE_EVENT_FLAG_FLOW_IN); TRACE_ID_MANGLE(GetTaskTraceID(*pending_task)), TRACE_EVENT_FLAG_FLOW_IN);
// Trace-parsing tools (DevTools, Lighthouse, etc) consume this event
// to determine long tasks.
// See https://crbug.com/681863 and https://crbug.com/874982
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "RunTask");
// Before running the task, store the task backtrace with the chain of // Before running the task, store the task backtrace with the chain of
// PostTasks that resulted in this call and deliberately alias it to ensure // PostTasks that resulted in this call and deliberately alias it to ensure
// it is on the stack if the task crashes. Be careful not to assume that the // it is on the stack if the task crashes. Be careful not to assume that the
......
...@@ -182,6 +182,12 @@ void ThreadControllerImpl::DoWork(WorkType work_type) { ...@@ -182,6 +182,12 @@ void ThreadControllerImpl::DoWork(WorkType work_type) {
// Trace events should finish before we call DidRunTask to ensure that // Trace events should finish before we call DidRunTask to ensure that
// SequenceManager trace events do not interfere with them. // SequenceManager trace events do not interfere with them.
TRACE_TASK_EXECUTION("ThreadControllerImpl::RunTask", *task); TRACE_TASK_EXECUTION("ThreadControllerImpl::RunTask", *task);
// Trace-parsing tools (DevTools, Lighthouse, etc) consume this event
// to determine long tasks.
// See https://crbug.com/681863 and https://crbug.com/874982
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "RunTask");
task_annotator_.RunTask("SequenceManager RunTask", &*task); task_annotator_.RunTask("SequenceManager RunTask", &*task);
} }
......
...@@ -349,6 +349,11 @@ TimeDelta ThreadControllerWithMessagePumpImpl::DoWorkImpl( ...@@ -349,6 +349,11 @@ TimeDelta ThreadControllerWithMessagePumpImpl::DoWorkImpl(
work_id_provider_->IncrementWorkId(); work_id_provider_->IncrementWorkId();
// Trace-parsing tools (DevTools, Lighthouse, etc) consume this event
// to determine long tasks.
// See https://crbug.com/681863 and https://crbug.com/874982
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "RunTask");
{ {
// Trace events should finish before we call DidRunTask to ensure that // Trace events should finish before we call DidRunTask to ensure that
// SequenceManager trace events do not interfere with them. // SequenceManager trace events do not interfere with them.
......
Checks the RunMicrotasks event is emitted. Checks the RunMicrotasks event is emitted and nested into RunTask.
RunMicrotasks Properties: RunMicrotasks Properties:
{ {
...@@ -9,4 +9,5 @@ RunMicrotasks Properties: ...@@ -9,4 +9,5 @@ RunMicrotasks Properties:
startTime : <number> startTime : <number>
type : "RunMicrotasks" type : "RunMicrotasks"
} }
Microtask event is nested into Task event: true
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
TestRunner.addResult(`Checks the RunMicrotasks event is emitted.\n`); TestRunner.addResult(`Checks the RunMicrotasks event is emitted and nested into RunTask.\n`);
await TestRunner.loadModule('performance_test_runner'); await TestRunner.loadModule('performance_test_runner');
await TestRunner.showPanel('timeline'); await TestRunner.showPanel('timeline');
await TestRunner.evaluateInPagePromise(` await TestRunner.evaluateInPagePromise(`
...@@ -27,8 +27,15 @@ ...@@ -27,8 +27,15 @@
`); `);
await PerformanceTestRunner.invokeAsyncWithTimeline('performActions'); await PerformanceTestRunner.invokeAsyncWithTimeline('performActions');
const event = PerformanceTestRunner.mainTrackEvents().find(
const microTaskEvent = PerformanceTestRunner.mainTrackEvents().find(
e => e.name === TimelineModel.TimelineModel.RecordType.RunMicrotasks); e => e.name === TimelineModel.TimelineModel.RecordType.RunMicrotasks);
PerformanceTestRunner.printTraceEventProperties(event); PerformanceTestRunner.printTraceEventProperties(microTaskEvent);
const nested = PerformanceTestRunner.mainTrackEvents()
.filter(e => e.name === TimelineModel.TimelineModel.RecordType.Task)
.some(e => e.startTime <= microTaskEvent.startTime && microTaskEvent.endTime <= e.endTime);
TestRunner.addResult(`Microtask event is nested into Task event: ${nested}`);
TestRunner.completeTest(); TestRunner.completeTest();
})(); })();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment