Measuring smoothness
Read DevTools' Frames track, tell dropped frames from partially presented ones, use long animation frames during animations, and test at 120 Hz.
- 01Read the Frames trackFind it in the Performance panel, and tell its four kinds of frame apart: presented, partially presented, dropped and idle.
- 02Turn frames into a numberCount the late frames during an animation, and work out a percent dropped that leaves idle frames out.
- 03Check what the visitor seesUse long animation frames together with the Frames track, and test an animation on a real 120 Hz screen.
The +1 froze, and Chrome kept showing frames
Asha is back on Leaf and Kettle's mint tea reviews. Ravi has a worry. In lesson 32.1, Asha saw his first +1 freeze. She noticed it with her own eyes. Next time, nobody might be looking.
"Can a tool notice it for me?" he asks. To find out, the course went back to his first +1. Asha taps Helpful on Meera's review. A green +1 starts to rise next to the button. 150 ms later, Ravi's ranking code keeps the page busy for 400 ms. The +1 stops in mid-air, then jumps. The small leaf by the title keeps swaying the whole time.
Here is what Asha saw, in real frames from Chrome. Under them is what DevTools drew for the same 850 ms:
Here are the main numbers as code:
// Asha taps Helpful. DevTools' Frames track, for 850 ms after her tap.const frames = { presented: 27, partiallyPresented: 24, dropped: 0 };const ranking = { startsAt: 160.2, lastsMs: 401 }; const shown = frames.presented + frames.partiallyPresented + frames.dropped;console.log(`Chrome showed ${shown} frames.`);console.log(`${frames.partiallyPresented} of them were partially presented.`);console.log(`Ravi's ranking code ran for ${ranking.lastsMs} ms.`);- Line 1 is a comment. A frame is one picture on the screen. DevTools' Performance panel draws every frame in a row called the Frames track, as in lesson 7.2. A millisecond (ms) is a thousandth of a second.
- Line 2 counts the frames by kind. A presented frame had every change in time. A partially presented frame had only some of them. A dropped frame had nothing new.
- Line 3 holds when Ravi's ranking code started, and how long it ran.
- Line 5 adds the frames up. Line 6 prints
Chrome showed 51 frames. - Line 7 prints
24 of them were partially presented.Line 8 printsRavi's ranking code ran for 401 ms.
So Chrome never stopped. It showed a new frame every 16.7 ms, 51 in all. Counting frames alone, the page looked fine. But 24 of those frames came without the +1's new place. DevTools marked every one of them. That's the tool Ravi wants.
Why it matters: smoothness isn't how many frames Chrome shows. It's whether each frame holds every change it should.
A good bus company doesn't brag about how many buses it ran. It reports how many were late or cancelled. And it only counts buses that had someone to carry. An empty stop can't make a bus late.
- In real life: Each bus on the timetable
- In JavaScript: Each frame, every 16.7 ms at 60 Hz
- In real life: A bus that left on time with everyone
- In JavaScript: A presented frame
- In real life: A bus that left on time without some passengers
- In JavaScript: A partially presented frame
- In real life: A cancelled bus
- In JavaScript: A dropped frame
- In real life: A stop with nobody waiting
- In JavaScript: An idle frame: nothing needed to change
- In real life: The share of late or cancelled buses
- In JavaScript: The percent dropped
Smoothness is the share of frames that reach the screen on time with every change they should hold. Count the late frames, partly presented or dropped, out of the frames where something was moving. The Frames track shows each frame. Long animation frames show which code was busy. And a real screen shows what happens at its own refresh rate.
This lesson takes four steps: the Frames track, dropped and partially presented frames, long animation frames during an animation, and testing at 120 Hz.
How the course recorded it
- The browser: Chrome 157, on a screen the size of Asha's phone, 412 by 823 px. Its CPU was slowed 4 times, as in lessons 32.1 to 32.3. That slows the main thread only.
- The pages: five of Ravi's pages, as he wrote them. His first +1 and his last +1 from lesson 32.1, each calm and with the ranking code. And his first view transition from lesson 32.3.
- The taps: a real mouse click on each page, once untimed, then 5 times. The numbers come from the middle tap, by how many frames came late.
- The frames: DevTools' own trace engine, the code behind the Performance panel, read each trace. So every count is what the Frames track shows. The pictures are Chrome's own screenshots. Your times will differ.
The Frames track
Record in the Performance panel while your animation runs. The Frames track is one of the rows in the recording. Each box in it is one frame. A box starts when Chrome begins a frame, and ends when the next one begins. So its width is how long the frame lasted.
When a box is wide enough, DevTools writes its time inside. Hover over a box for a tooltip with its time and its kind. Click it, and the Summary tab tells you more.
DevTools draws four kinds of frame. Read the table across: the name DevTools gives each kind, its colour, and what reached the screen in time.
| DevTools calls it | Its colour | What reached the screen in time |
|---|---|---|
| Frame | Green. | Every change that should be in the frame. |
| Partially presented frame | Yellow, with sparse, wide dashes. | Some changes, but not all. Often the compositor's part arrived and the main thread's part didn't. |
| Dropped frame | Red, with dense lines. | Nothing new. The screen kept showing the last frame. |
| Idle frame | White. | Nothing, because nothing needed to change. |
Chrome's docs describe a partially presented frame this way: "Chrome did its best to render at least some visual updates in time." A dropped frame is one "Chrome can't render" in reasonable time.
Now the calm pages, with no ranking code:
// The calm pages: no ranking code. Middle of 5 taps, 850 ms after each.const pages = [ { page: "Ravi's first +1", frames: 50, late: 0, eachMs: 16.7 }, { page: "Ravi's last +1", frames: 51, late: 0, eachMs: 16.7 },];for (const p of pages) { console.log(`${p.page}: ${p.frames} frames, ${p.late} late, ${p.eachMs} ms each`);}- Lines 3 and 4 hold one page each: its frames in the 850 ms after the tap, the late ones, and how long each frame lasted.
- Line 7 prints
Ravi's first +1: 50 frames, 0 late, 16.7 ms eachandRavi's last +1: 51 frames, 0 late, 16.7 ms each.
On both calm pages, every frame was presented, and each lasted 16.7 ms. That's the screen's beat at 60 Hz, from lesson 6.2. So Ravi's first +1 looked fine, as long as nothing else needed the main thread.
Why it matters: a calm test can hide a problem. Record your animation while the page is busy too, the way a visitor really uses it.
How DevTools draws the track
DevTools builds the Frames track from the trace. Its code, FramesHandler.ts, starts a new box each time Chrome's compositor begins a frame. The compositor is the thread that puts each frame together, from lesson 32.1.
When a frame comes late, Chrome also writes an event called DroppedFrame into the trace. It has a field, hasPartialUpdate. When it's true, part of the frame reached the screen, and DevTools draws a partially presented frame. When it's false, DevTools draws a dropped frame.
Lesson 32.1 counted these same events, and called the frames "partly late". This lesson lets DevTools' own code count them, so the numbers match what you'd see in the panel.
The same frames, live
You don't have to record to see frames. In DevTools' Rendering tab, from lesson 7.5, tick Frame rendering stats. An overlay appears at the top right of the page. It shows an estimate of frames per second, and a plot with one line per frame. The docs list three colours: blue for frames rendered in time, yellow for partially presented ones, and red for dropped ones.
One warning from web.dev: the frames per second it shows "is for fully-presented frames only." Partly presented frames don't count.
Dropped and partially presented frames
Late frames come in two kinds. The difference is whether any part of the frame reached the screen.
Chrome's compositor writes down how each frame ended. Its source file, frame_info.h, lists the endings:
- Presented all: the frame "contains all the desired update for this vsync". Vsync is the screen's beat, from lesson 6.2.
- Presented partly: the frame has the compositor's changes, but "misses the update from the main-thread".
- Dropped: no new frame reached the screen.
- No update desired: nothing needed to change.
A newspaper goes to press at midnight, every night. One night the sports desk is late. The paper still goes out, with a new front page and yesterday's sports page. Another night the press breaks down. No paper comes, and readers look at yesterday's again.
- In real life: Going to press at midnight, every night
- In JavaScript: A frame's deadline, on the screen's beat
- In real life: A new front page with yesterday's sports page
- In JavaScript: A partially presented frame
- In real life: The sports desk that was late
- In JavaScript: The main thread, busy with other work
- In real life: No paper at all
- In JavaScript: A dropped frame: the screen shows the last one again
- In real life: A quiet night with no news
- In JavaScript: An idle frame
The course ran the same kind of long task on three of Ravi's pages. Here are the frames DevTools drew while it ran:
// The frames DevTools drew while the long task ran, by kind.const during = [ { page: "first +1", presented: 0, partiallyPresented: 24, dropped: 0 }, { page: "last +1", presented: 24, partiallyPresented: 0, dropped: 0 }, { page: "first view transition", presented: 0, partiallyPresented: 0, dropped: 29 },];for (const d of during) { console.log(`${d.page}: ${d.presented} presented, ${d.partiallyPresented} partially presented, ${d.dropped} dropped`);}- Lines 3 to 5 hold one page each. On the +1 pages the long task is the ranking code. On the third, it's the update callback.
- Line 8 prints
first +1: 0 presented, 24 partially presented, 0 droppedandlast +1: 24 presented, 0 partially presented, 0 dropped. - Then it prints
first view transition: 0 presented, 0 partially presented, 29 dropped.
Take the first +1. The compositor kept the leaf swaying, as lesson 32.1 showed, so every frame had a new leaf. But the +1's new place needed the main thread, and the main thread was busy. Part of each frame arrived: partially presented.
Ravi's last +1 uses element.animate() with transform and opacity. The compositor moved it by itself. So every frame was presented, while the main thread was just as busy.
In the view transition, Chrome paused rendering while the update callback ran, as lesson 32.3 showed. Even the compositor's frames stopped. Nothing new reached the screen, not even the leaf. The web.dev article on smoothness puts it plainly: "Your screen doesn't go black, it just repeats itself." Those frames were dropped.
Why it matters: a partially presented frame usually means the main thread held one animation back while others went on. A dropped frame means nothing moved at all. Both are late, and both count.
Only frames that matter are marked
Chrome doesn't mark every slow frame. It only marks one when an animation or a scroll was waiting for an update. Its source, frame_info.cc, says: "If neither of the threads are expected to be smooth, then this frame cannot affect smoothness."
web.dev uses the same words. A thread affects smoothness while an animation depends on it. So on a still page, a slow frame isn't marked dropped. Nobody was waiting to see something move.
One number: the percent dropped
web.dev's article Towards an animation smoothness metric sums frames up as a percent dropped. It counts the late frames, out of all the frames that weren't idle. Idle frames stay out. Nothing was meant to change in them, so they can't be late.
// Late frames out of the frames that weren't idle.const pages = [ { page: "first +1", presented: 27, partiallyPresented: 24, dropped: 0, idle: 0 }, { page: "last +1", presented: 51, partiallyPresented: 0, dropped: 0, idle: 0 },];for (const p of pages) { const late = p.partiallyPresented + p.dropped; const counted = p.presented + late; // idle frames don't count console.log(`${p.page}: ${late} of ${counted} late, ${Math.round((100 * late) / counted)}% dropped`);}- Lines 3 and 4 hold each busy page's frames, from the 850 ms after the tap.
- Line 7 adds up the late frames: partially presented and dropped.
- Line 8 counts the frames that weren't idle.
- Line 9 prints
first +1: 24 of 51 late, 47% droppedandlast +1: 0 of 51 late, 0% dropped.
Nearly half of the first +1's frames were late. Ravi's change to element.animate() took that to zero. Why it matters: a number like this lets you compare two versions, the way you compare load times.
The article also suggests looking at the worst one-second stretch, so one bad second can't hide in a long calm recording. It admits the names are "somewhat historical": a late frame isn't always fully dropped.
Try each of Ravi's pages. Pick one to see its frames, its long task and its long animation frame:
function plusOne(button) {
const plus = makePlus(button);
let start;
requestAnimationFrame(function step(now) {
start ??= now;
const t = Math.min((now - start) / 800, 1);
plus.style.top = `${4 - 40 * t}px`;
if (t < 1) requestAnimationFrame(step);
else plus.remove();
});
}27240047%401 ms, from 160.2 ms0 presented, 24 partially presented, 0 dropped410.2 ms, started by TimerHandler:setTimeoutWhile the ranking code ran, the compositor drew the leaf but the +1 waited for the main thread. Those frames were partially presented.
Long animation frames during an animation
The Frames track shows that frames came late. It doesn't say which code made them late. Long animation frames, from lesson 11.5, can.
A long animation frame is 50 ms or more of main-thread work, up to the moment the page draws, if it draws. Chrome writes an entry for each one, with the scripts that ran in it. To check one animation, keep only the entries that overlap it:
const plus = document.querySelector(".plus");const rise = plus.animate([{ transform: "none" }, { transform: "translateY(-40px)" }], 800);const start = performance.now();setTimeout(() => busy(120), 150); // stands in for the ranking code rise.finished.then(() => { const end = performance.now(); new PerformanceObserver((list) => { const during = list.getEntries().filter((f) => f.startTime < end && f.startTime + f.duration > start); console.log(`Long animation frames during the rise: ${during.length}`); console.log(`The first one started with ${during[0].scripts[0].invoker}`); }).observe({ type: "long-animation-frame", buffered: true });});- Line 2 starts a rise with
element.animate(). Line 3 notes when it started. - Line 4 stands in for the ranking code. 150 ms later,
busy(120)keeps the main thread busy for 120 ms. It's the small helper from lesson 11.5: a loop that runs that long. - Line 6 waits until the animation finishes. Line 7 notes when it ended.
- Lines 8 to 12 make an observer.
buffered: trueon line 12 also brings the entries Chrome wrote before the observer existed. - Line 9 keeps the frames that started before the end and finished after the start.
- The course ran it in Chrome. Line 10 printed
Long animation frames during the rise: 1. Line 11 printedThe first one started with TimerHandler:setTimeout.
Ravi's pages had an observer like this too. Here is what it saw on the two busy +1 pages:
// The long animation frames during the +1, busy pages. Times in ms after the tap.const frames = [ { page: "first +1", startsAt: 160.1, duration: 410.2, renderStart: 561.3 }, { page: "last +1", startsAt: 151.7, duration: 400.6, renderStart: 0 },];for (const f of frames) { const drew = f.renderStart > 0 ? "then drew" : "drew nothing"; console.log(`${f.page}: one long frame of ${f.duration} ms, ${drew}`);}- Lines 3 and 4 hold each page's long animation frame: when it started after the tap, how long it lasted, and its
renderStart. That's when the frame began to draw, or 0 if it drew nothing. - Line 8 prints
first +1: one long frame of 410.2 ms, then drewandlast +1: one long frame of 400.6 ms, drew nothing.
Both pages had one long animation frame of about 400 ms: the ranking code. On the first page, the frame ended by drawing, at 561.3 ms. The main thread finally gave the +1 its new place, and it jumped. On the last page, renderStart was 0. The main thread had nothing to draw. The compositor had drawn every frame without it.
So the same long frame came with two very different Frames tracks. Why it matters: a long animation frame says the main thread was busy. It doesn't say an animation suffered. Look at both.
The café's cook keeps a log. One line says she spent ten minutes on one big order, and cooked nothing else. The log can't say if a diner noticed. That depends on what the diner was waiting for. Drinks from the bar kept coming. A plate from the kitchen didn't.
- In real life: The cook's log
- In JavaScript: Long animation frames, from the main thread
- In real life: One big order
- In JavaScript: Ravi's ranking code
- In real life: Drinks from the bar
- In JavaScript: The compositor's frames: the leaf, and the last +1
- In real life: A plate from the kitchen
- In JavaScript: The first +1, which needs the main thread
- In real life: What the diners got
- In JavaScript: The Frames track
The script it names
Which script did the first +1's long frame name?
// The script the first +1's long frame names.const script = { invokerType: "user-callback", invoker: "TimerHandler:setTimeout", sourceFunctionName: "", sourceURL: "", duration: 400.1,};console.log(`${script.invoker} ran for ${script.duration} ms.`);console.log(`Function name: "${script.sourceFunctionName}". File: "${script.sourceURL}".`);- Lines 3 and 4 say how the script started: a
user-callback, a function handed to a browser API. Its invoker is asetTimeouttimer. - Lines 5 and 6 are empty: no function name, and no file.
- Line 9 prints
TimerHandler:setTimeout ran for 400.1 ms.Line 10 printsFunction name: "". File: "".
Not rankReviews. Ravi's code waits for saveVote(), a promise a setTimeout resolves 150 ms later. Then rankReviews runs as its then callback, at the end of that timer's task. So the entry names the timer. The timer's function is the promise's own resolve function. It's built into JavaScript, so it has no name or file to give.
Lesson 11.5 warned about this: the entry names where the script started, not the slow part inside it. Why it matters: start at the timer, and follow what runs after it.
Testing at 120 Hz
Not every screen runs at 60 Hz. MDN says 60 Hz is the most common, "though 75hz, 120hz, and 144hz are also widely used."
The HTML Standard says the browser's chances to draw depend on "hardware constraints such as display refresh rates". So a 120 Hz screen gives it twice as many chances, each with half the time. Lesson 6.2 worked out the budget: one frame lasts 16.7 ms at 60 Hz, and 8.3 ms at 120 Hz.
What does a faster screen change for Ravi's first +1? On the calm page, every frame needed a task on the main thread: the frame callback, then style, layout and paint. The course timed each one:
// Ravi's first +1, calm: the main-thread task of each of its 50 frames.const shortestMs = 6.7;const longestMs = 12.4;const longer = { 60: 0, 120: 48 }; // tasks longer than one framefor (const hz of [60, 120]) { console.log(`${hz} Hz: ${(1000 / hz).toFixed(1)} ms a frame. ${longer[hz]} of 50 tasks took longer.`);}console.log(`Each task took ${shortestMs} to ${longestMs} ms.`);- Lines 2 and 3 hold the shortest and the longest task, from the 50 frames.
- Line 4 counts the tasks that took longer than one frame, at 60 Hz and at 120 Hz.
- Line 6 prints
60 Hz: 16.7 ms a frame. 0 of 50 tasks took longer.and120 Hz: 8.3 ms a frame. 48 of 50 tasks took longer. - Line 8 prints
Each task took 6.7 to 12.4 ms.
At 60 Hz every task fitted, and the Frames track showed 50 presented frames. At 120 Hz, 48 of the 50 tasks take longer than a frame lasts. They can't be ready by their frame's deadline.
And long animation frames wouldn't notice. Every task is far under 50 ms. The spec's limit stays at 50 ms on any screen: when a frame is "less than 50 milliseconds", it isn't reported. Why it matters: on a 120 Hz screen, an animation can miss most of its frames with no long animation frame at all. Watch the Frames track.
At the shop's packing table, a box comes down the belt every 16 seconds. Ravi needs 10 seconds to pack one, so he keeps up. Then the belt speeds up to a box every 8 seconds. Ravi still needs 10. Boxes start going past without their tea.
- In real life: A box every 16 seconds
- In JavaScript: A frame every 16.7 ms, at 60 Hz
- In real life: Ravi's 10 seconds per box
- In JavaScript: About 10 ms of main-thread work per frame
- In real life: The faster belt: a box every 8 seconds
- In JavaScript: A 120 Hz screen: a frame every 8.3 ms
- In real life: A box going past without its tea
- In JavaScript: A frame without the +1's new place
- In real life: A machine that packs by itself
- In JavaScript: The compositor, running the last +1
The ranking code changes too. At 60 Hz, its 401 ms covered 24 frames. At 120 Hz, the same work covers 48. Ravi's last +1 needs the main thread only to start and to end, as lesson 32.1 showed. While it moves, a shorter frame doesn't touch it.
One more thing changes: loops. A loop that moves something a fixed step each frame runs twice as fast at 120 Hz. Lesson 32.1 showed the fix: work out the position from the frame's timestamp. Try the same frames at other rates:
const frameMs = 1000 / 60; // 16.7 ms
const fit = tasks.filter((ms) => ms <= frameMs).length;
const coveredByRanking = Math.round(rankingMs / frameMs);16.7 ms50 of 500 of 5024none: the compositor moves itEvery one of the first +1's 50 frame tasks fits in one frame. The ranking code covers 24 frames.
Headless Chrome and 120 Hz
The course measured how often its headless Chrome began frames: the requestAnimationFrame timestamps for one second, on a nearly empty page. MDN says these callbacks "will generally match the display refresh rate."
// requestAnimationFrame timestamps for one second, in the course's headless Chrome.const runs = [ { flags: "no flags", callbacks: 62, gapMs: 16.7 }, { flags: "--disable-frame-rate-limit", callbacks: 57, gapMs: 18.5 },];for (const r of runs) console.log(`${r.flags}: a frame every ${r.gapMs} ms`);- Lines 3 and 4 hold two runs: Chrome with no flags, and Chrome started with
--disable-frame-rate-limit. Each holds how many callbacks came in a second, and the middle gap between them. - Line 6 prints
no flags: a frame every 16.7 msand--disable-frame-rate-limit: a frame every 18.5 ms.
Headless Chrome runs at 60 Hz. The closest switch is --disable-frame-rate-limit. Its source says it "Disables begin frame limiting". It doesn't choose a rate: with it, frames came no faster.
DevTools' Emulation tools fake a screen's size and a slower CPU, but not a refresh rate. So the playground works out its 120 Hz numbers from the 60 Hz recording, with an 8.3 ms budget for each frame.
Testing on a real 120 Hz screen
- Use a real phone: one with a 120 Hz screen, connected to DevTools on your computer with remote debugging. Then record in the Performance panel, as on a computer.
- Or a fast screen: a laptop or monitor that runs at 120 Hz, with the browser window on it.
- Check the rate first: run the playground below. Or look at the Frames track: at 120 Hz, its boxes are 8.3 ms wide.
- Measure the phone as it is: leave DevTools' CPU slowdown off, so the numbers are the phone's own.
Measure your own screen. Press the button, with or without a busy stretch in the middle:
const stamps = [];
requestAnimationFrame(function step(now) {
stamps.push(now);
if (now - stamps[0] < 1000) requestAnimationFrame(step);
else {
const gaps = stamps.slice(1).map((t, i) => t - stamps[i]).sort((a, b) => a - b);
const gap = gaps[Math.floor(gaps.length / 2)];
console.log(`A frame every ${gap.toFixed(1)} ms: about ${Math.round(1000 / gap)} Hz`);
}
});Press Measure framesThe lab asks for a frame callback before every frame, for one second, and notes each frame's timestamp.
What would the Frames track show?
For each one, ask: did every change reach the screen in time, some of them, none, or was nothing meant to change?
- Ravi's last +1 rises while the ranking code runs
- The leaf sways while Ravi's first +1 waits for the ranking code
- Chrome pauses rendering while a view transition's update callback runs
- Nothing on the page changes for a few seconds
- Ravi's first +1 rises on a calm page, on a 60 Hz screen
- The page scrolls in time, but a canvas animation on the main thread is late
Sort each moment by the kind of frame DevTools draws for it.
Then pick the tool. Read the table across: your question, where to look, and what it shows.
| Your question | Where to look | What it shows |
|---|---|---|
| Did frames come late during my animation? | The Performance panel's Frames track. | Each frame, as presented, partially presented, dropped or idle. |
| Is it smooth right now, while I click around? | The Rendering tab's Frame rendering stats. | A live plot of frames, and frames per second. |
| Which code kept the main thread busy? | Long animation frames, or the Main track. | Each long frame, with the scripts that started it. |
| How smooth was it, in one number? | A percent dropped, from the frames. | Late frames, out of the frames that weren't idle. |
| Is it smooth at 120 Hz? | A real 120 Hz screen, with remote debugging. | The same tracks, with frames 8.3 ms wide. |
Common mix-ups
- "If Chrome shows 60 frames a second, the animation is smooth." No. Chrome showed a frame every 16.7 ms during the ranking code. 24 of them came without the +1's new place.
- "A partially presented frame means half the screen was drawn." No. It means some of the changes arrived, usually the compositor's, and the main thread's didn't.
- "A dropped frame turns the screen black." No. The screen shows the last frame again.
- "A long animation frame means the animation stuttered." No. Ravi's last +1 had a 400.6 ms long frame, and every frame was presented.
- "No long animation frames means the animation is smooth." No. At 120 Hz, 48 of the first +1's 50 frame tasks wouldn't fit, and none of them is anywhere near 50 ms.
- "Counting requestAnimationFrame calls measures smoothness." No. web.dev calls that loop an anti-pattern. It misses updates the compositor makes on its own, and it gives the main thread work in every frame.
- "DevTools can test a 120 Hz screen." No. It can't set a refresh rate, and the course's headless Chrome stayed at 60 Hz. Test on a real 120 Hz screen.
Practice exercises
Answer first, then use the hints.
What does this code print? Then fix line 3, so it works out the percent dropped the way web.dev does.
const frames = { presented: 40, partiallyPresented: 6, dropped: 2, idle: 12 };
const late = frames.partiallyPresented + frames.dropped;
const counted = frames.presented + frames.partiallyPresented + frames.dropped + frames.idle;
console.log(`${late} of ${counted} late: ${Math.round((100 * late) / counted)}% dropped`);const frames = { presented: 40, partiallyPresented: 6, dropped: 2, idle: 12 };
const late = frames.partiallyPresented + frames.dropped;
const counted = frames.presented + frames.partiallyPresented + frames.dropped;
console.log(`${late} of ${counted} late: ${Math.round((100 * late) / counted)}% dropped`);It prints 8 of 60 late: 13% dropped. The 12 idle frames hide part of the problem. Leave them out, and it's 8 of 48: 17%.
Four frames need this much main-thread work. What does the second line print?
const work = [7.5, 9.2, 15.1, 18.0]; // ms of main-thread work, four frames
for (const hz of [60, 120]) {
const fit = work.filter((ms) => ms <= 1000 / hz).length;
console.log(`${hz} Hz: ${fit} of ${work.length} fit`);
}120 Hz: 1 of 4 fit. At 60 Hz, three fit in 16.7 ms. At 120 Hz, only the 7.5 ms frame fits in 8.3 ms.
In the playground, how many frames were dropped in the 1,300 ms after the tap on Ravi's first view transition?
37. More than the 29 during the long task itself: rendering stayed paused after the update callback ended, until Chrome had the new state, as lesson 32.3 showed.
Ravi's check prints nothing at all. What is missing from line 7?
const plus = document.querySelector(".plus");
const rise = plus.animate([{ transform: "none" }, { transform: "translateY(-40px)" }], 800);
setTimeout(() => busy(120), 150);
rise.finished.then(() => {
new PerformanceObserver((list) => {
console.log(`Long animation frames: ${list.getEntries().length}`);
}).observe({ type: "long-animation-frame" });
});const plus = document.querySelector(".plus");
const rise = plus.animate([{ transform: "none" }, { transform: "translateY(-40px)" }], 800);
setTimeout(() => busy(120), 150);
rise.finished.then(() => {
new PerformanceObserver((list) => {
console.log(`Long animation frames: ${list.getEntries().length}`);
}).observe({ type: "long-animation-frame", buffered: true });
});buffered: true. The long frame was written while the animation ran, before the observer existed. Without buffered, the observer waits for new entries, and none come. The course ran both in Chrome.
Open the course's copy of Ravi's first +1 page. With Frame rendering stats on, what title does the overlay show at its top?
Frame Rate. It's the title Chrome draws above the frames-per-second number, in heads_up_display_layer_impl.cc. The plot under it shows each frame's kind as you tap.
Asha's phone has a 120 Hz screen. Which address do you open in Chrome on your computer to find it for remote debugging?
chrome://inspect#devices. With USB debugging on and the phone plugged in, it lists the phone's tabs. Inspect opens DevTools for one, and you can record its frames at the phone's own refresh rate.
Check your understanding
For each question, ask: did every change reach the screen in time, and which thread was it waiting for?
Question 1 of 7What does the second line of Asha's tap example print?
Read the code, then predict// Asha taps Helpful. DevTools' Frames track, for 850 ms after her tap. const frames = { presented: 27, partiallyPresented: 24, dropped: 0 }; const ranking = { startsAt: 160.2, lastsMs: 401 }; const shown = frames.presented + frames.partiallyPresented + frames.dropped; console.log(`Chrome showed ${shown} frames.`); console.log(`${frames.partiallyPresented} of them were partially presented.`); console.log(`Ravi's ranking code ran for ${ranking.lastsMs} ms.`);Choose an answer to see the explanation.
Question 2 of 7DevTools draws a frame in yellow, with sparse, wide dashes. What happened in that frame?
Choose an answer to see the explanation.
Question 3 of 7While Chrome paused rendering for Ravi's first view transition, what did the Frames track show?
Choose an answer to see the explanation.
Question 4 of 7Why does the percent dropped leave idle frames out?
Choose an answer to see the explanation.
Question 5 of 7Ravi's last +1 page had a long animation frame during the ranking code, as long as the first +1's. What did its Frames track show?
Choose an answer to see the explanation.
Question 6 of 7Each frame of Ravi's first +1, on a calm page, needed more main-thread time than one frame lasts at 120 Hz. What would long animation frames report about those frames?
Choose an answer to see the explanation.
Question 7 of 7How did the course check whether its headless Chrome could run at 120 Hz?
Choose an answer to see the explanation.
Key takeaways
- Smoothness is whether each frame holds every change in time, not how many frames Chrome shows.
- The Frames track draws four kinds of frame: presented, partially presented, dropped and idle.
- A partially presented frame had some changes, often the compositor's. A dropped frame had nothing new.
- The percent dropped counts late frames out of the frames that weren't idle.
- Long animation frames name the busy code, but a long frame doesn't always mean a late frame. Read them with the Frames track.
- At 120 Hz a frame lasts 8.3 ms. Long animation frames still only report 50 ms or more.
- Headless Chrome and DevTools stay at 60 Hz. Test at 120 Hz on a real screen.
Remember the one-liner.
Count late frames, not frames: partly presented or dropped, out of the frames where something moved.
Sources
The facts on this page come from these specs, docs and source files:
- Performance features reference: the Frames section, Chrome for Developers.
- TimelineFlameChartDataProvider.ts: the Frames track's names and colours, Chrome DevTools source.
- FramesHandler.ts: how DevTools builds the Frames track from a trace, Chrome DevTools source.
- devtools_instrumentation.h: the DroppedFrame event and hasPartialUpdate, Chromium source.
- Discover issues with rendering performance: Frame rendering stats, Chrome for Developers.
- frame_info.h: how a frame can end, Chromium source.
- frame_info.cc: which late frames affect smoothness, Chromium source.
- Towards an animation smoothness metric, web.dev.
- Long Animation Frames: long animation frame timing, W3C.
- Long Animation Frames: the 50 ms threshold in the processing model, W3C.
- HTML Standard: rendering opportunities, WHATWG.
- Window: requestAnimationFrame() method, MDN.
- switches.cc: --disable-frame-rate-limit, Chromium source.
- Emulation.pdl: what DevTools can emulate, Chromium source.
- Remote debug Android devices, Chrome for Developers.
- heads_up_display_layer_impl.cc: the Frame rendering stats overlay, Chromium source.
Coming next: Canvas and WebGL performance. You'll keep a drawing smooth when JavaScript paints every frame itself.