Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inexplicit 'task' in Chrome Perfomance DevTools

Chrome exhibits huge lags when viewing a given web page of mine. I'm using the DevTools Performance tab to try and find the culprit which I assume to be somewhere in my JavaScript code.

The following screenshot shows a profile recorded using DevTools. For some of the "tasks" shown in the profile, I can see the details of what the tasks are doing (for example, the one between 8700 ms and 9200 ms is GC), but for other tasks there are no details whatsoever, like the two I have highlighted in the screenshot. How do I figure out what are those tasks doing?

Screenshot

like image 257
Sergei Illarionov Avatar asked May 27 '19 16:05

Sergei Illarionov


People also ask

How do you perform performance analysis in Chrome?

To access the Performance tab, navigate to the website you want to profile, then open Chrome DevTools by right-clicking and selecting Inspect. Select the Performance tab inside Chrome DevTools. The easiest way to capture a performance profile is by clicking the Start profiling and reload page icon.

What is idle in Chrome performance?

Idle is just that, nothing was going on so nothing to worry about as far as I know. Other is "un-instrumented activity". Which is stuff that currently isn't able to be broken down. So, you can't analyze what was going on in there from the DevTools.

What is payload in DevTools?

The Request Payload - or to be more precise: payload body of a HTTP Request. is the data normally send by a POST or PUT Request. It's the part after the headers and the CRLF of a HTTP Request.

Which method in Chrome is used to test a web page performance?

Check memory and CPU load # In Chrome you can access the Task Manager from the Window menu. This is a simple way to check a web page's requirements. Chrome's Task Manager — watch out for memory and CPU hogs!


2 Answers

You can use JavaScript's performance observer to know the bottleneck of perf issues in your web app.

Precise code -

const observer = new PerformanceObserver((list) => {
    console.log('Long Task detected! 🚩️');
    const entries = list.getEntries();
    console.log(entries);
});

observer.observe({entryTypes: ['longtask']});

More details here

like image 80
C Ankita Avatar answered Oct 19 '22 20:10

C Ankita


I ran into a similar issue where I had long, opaque "task" taking several seconds without further information in the Dev Tools.

enter image description here

A Chrome dev pointed me towards Perfetto (edit: or you can access a built-in similar tool at chrome://tracing). Perfetto lets you record traces of the internals of Chrome. In my case I suspect this was GPU related so I enabled all the gpu* switches:

enter image description here

and started my trace. After I repro'ed the issue in another tab, I went back to the Perfetto trace. I found these "ThreadControllerImpl::RunTask" slices that seemed to be about the duration of the mysterious system tasks.

enter image description here

Helpfully Perfetto has an arrow from that task to another group of "slices".

enter image description here

And each of these is catagorized as "webaudio". From that I learned that my use of AudioContext was likely the culprit, and indeed if I disabled all audio on my page the issue goes away.

enter image description here

Hopefully this example is illustrative to others trying to solve opaque "system task" issues in Chrome.

like image 1
Daryl Avatar answered Oct 19 '22 19:10

Daryl