While debugging a canvas library I'm working on, i encountered, that chrome-devtools keep reporting "composite layers" and "update layer tree" every animationframe, without repainting or moving any objects.
An example:
var x = 0;
( function tick( ) {
window.requestAnimationFrame(tick);
x++;
}( ) )
These operations are not time intensive ( 0.005 - 0.05 ms each frame ), but I would like to know why this is happening.
The only idea coming to my mind, is that chrome uses something similar to:
console.time( "composite layers" );
// do compositing
for( var i = 0; i < compositedLayers.length; ++i ) {
// not triggered since compositedLayers.length = 0
// but takes some time to be checked
compositedLayers[i].composite();
}
console.timeEnd( "composite layers" );
So if this is the case, why "Paint", "Recalculate Style", "Layout",... are not triggered the same way?
Update:
- This happens in Chrome 36/37 (Windows)
- On Chromium 34 (Linux) it only displays composite layers
- other systems untested
Edit1:
This only occurs when using requestAnimationFrame
. setInterval
only shows timer fired, as expected.
Edit2:
Complete Source Code of the example: pastebin