Update
setInterval
has no problem. Only with requestAnimationFrame
. This, after all, makes such a sense. requestAnimationFrame
already throttles things to 60 frames per second, which I did not know and cannot find information that Chrome (others?) throttled it to 30 (60/2), and then 20 (60/3)) and probably , 15 (60/4) ... this synchronizes it with 60 Hz, so you never get 40 frames per second, which looks strange because it does not synchronize with the screen refresh rate.
That explains a lot. I really enjoy the processor savings that provides us.
Update
An example without my code ... http://www.goodboydigital.com/pixijs/canvas/bunnymark/ , if you run this in Chrome ... you will see a point when it jumps from ~ 60 frames per second right to 30 frames in give me a sec. You can continue to add more rabbits, pixy can handle this ... Chrome adjusts fps. This is not how Chrome should behave.
So, I realized what is going on here. It's not that the performance has changed, let's say I can get 4800 objects on the screen at 30 frames per second. It seems that the way Chrome tries to optimize the end-user experience has changed. In fact, it reduces the speed to 60 frames per second to ~ 30 frames per second (29.9 frames per second according to dev tools), which leads to if(fps>=30)
returns false:
stage.onEnterFrame=function(fps){
For some reason, about 2800 objects, Chrome throttles up to 30 frames per second instead of trying to go as fast as possible ... Therefore, if I run the benchmark with 4800 objects, it will be with perfectly matched 29.9fps.

(you can see here that its 60fps or 29.9fps does not have a real time span, the only thing that changes is how often it switches)
This is the code used to synchronize the scene ...
_s.Stage.prototype.updateFPS = function() { var then = this.ctx.then; var now = this.ctx.now = Date.now(); var delta = now - then; this.ctx.then = now; this.ctx.frameRatio = 60 / (1000 / delta); };
Hope this helps someone else along the way.