Layout paint flashing in Firefox
1 February, 2012 § 26 Comments
Writing efficient and responsive websites are important to providing a great user experience. Some website layouts cause inefficient rendering, hurting the experience of the users that we try so hard to please.
Starting in Firefox 11 (currently in the beta channel), there is a hidden preference (nglayout.debug.paint_flashing) to enable what we call “paint flashing”.
- Make sure that you have Firefox 11 or higher installed (Beta, Aurora, or Nightly).
- Go to about:config
- Accept the warning
- Right-click and select New -> Boolean
- Type nglayout.debug.paint_flashing
- Set the option to true
To disable, just set the option to false
Whenever the layout engine determines that a region of the browser requires repainting, the region is tinted with a random color value. Regions experiencing heavy paint flashing can turn your browser in to a fun rave, but also show web developers (and browser developers too!) areas of the code that aren’t being as optimal as possible.
For example, there is currently a bug on file for Firefox where the HTML5 video controls cause unnecessary paint flashing (bug 722261). Modifying the markup for the controls can fix this and improve the performance of the controls. Paint flashing was required to find this inefficiency, and it will also be the tool that we will thank for finding many other inefficiencies as we move forward.
To enable this feature in Firefox, go to about:config and create a new Boolean preference with the name of nglayout.debug.paint_flashing and set the preference to true.
Looks like debug builds prior to Firefox 4 had some support for paint flashing although I’ve never tried it.
[…] Layout paint flashing in Firefox – Detect when a region of the web browser requires repainting. […]
Thanks! I will definitely recommend this to all my developer friends. Keep up the superb work and innovation at Mozilla 🙂
Thanks for editing the post with some instructions, much appreciated
[…] I (@weinjared) demoed how to make bullet-time screen captures of Firefox and paint flashing. […]
Nice! Lookin good.
Dang it, I’m having no luck at all getting this going 😦 I just tried a nightly since it didn’t seem to be working in 10.6 and it blew up (BSOD) my computer!! Hardware acceleration seemed to be the problem even though all I did was open about:memory for a quick look at new features in there. Nuts!
Gosh I finally got it working. Very interesting but alas very limited. It’s hard to sit there and count how many flashes are required for various elements and even hard to analyze how these paint flashes can be reduced to speed up layout. Very interested idea though however how about someone build this feature into something more helpful for devs? Or is there some way I can already hook into this preference with JS from Firebug or something?
The feature was implemented for people working on the browser, so it hasn’t been fine-tuned for people working on websites. I have filed bug 723281 to make the necessary adjustments to make it a web developer tool (http://bugzil.la/723281).
[…] https://msujaws.wordpress.com/2012/02/01/layout-paint-flashing-in-firefox/ RedditBufferShareEmailPrintFacebookDiggStumbleUpon […]