Jul 26th

Firefox 4 and Direct2D on Windows 7

2010, 04:36 UTC | By | In Mozilla
Leave a comment | Trackback  | 4407 views

Firefox 4 and Direct2D on Windows 7

This is now outdated information. Firefox 4 has gone final and hardware acceleration is enabled by default if the hardware can support it. There is also a user-visible option in the preferences screen - tweaking via about:config variables is no longer necessary and not recommended.

Right now, I'm testing the 3rd beta of Firefox 4 and so far, I like what I'm seeing. I turned away from Firefox when it started to become more and more bloated - a development that culminated in version 3.5 and that made me switch to Google Chrome because of its more modern and sleeker design.

Now, after a while, I wanted to see what the next major Firefox version will bring and I'm pretty impressed. First of all, the UI is much improved, although it doesn't seem that FF will bring new innovations, it merely copies a few things from other browsers, especially Chrome and that was to be expected, because Chrome did introduce some new and fresh things to the browser world.

However, there is one feature that sets Firefox apart and will probably make it rival the next generation Internet Explorer when it comes to rendering performance. As we all know, IE9 will use Direct2D to dramatically improve rendering speed on image heavy pages and whoever has tried the tech preview would probably agree on that it can, in fact, make a major difference. This is the next major performance boost for browsers, after the ongoing fight for the fastest JavaScript implementation.

Font rendering with DirectWrite and performance improvements with Direct2D

Yes, that's a major thing which is already in FF 4 but is disabled by default, because it is not considered to be "production quality" at this time. To enable it, you MUST be using Windows 7 or Windows Vista SP2. Direct2D is only available on these operating systems and enabling it when running Firefox on Windows XP or Vista without SP2 will have no effect. Also, Direct2D relies in some ways on DirectX 10 and while you can enable it on older (non - DX10) hardware, you'll most likely only see benefits when you have a video card that supports DirectX 10.

How to enable it?

  • Open about:config
  • Set gfx.font_rendering.directwrite.enabled to true. This boolean value should already exist, but if it doesn't, you need to create it.
  • Set mozilla.widget.render-mode to 6. This is an integer value and the same as above applies (it should exist, but if it doesn't, then simply create it).
  • Restart the browser.

This thread on mozillazine explains everything with much more detail and also lists a number of possible issues related to Direct2D rendering. From my own experience, it is fairly stable in Beta 3, but I do not use a lot of extensions and it is a known fact, that enabling D2D rendering can cause problems with a number of popular extensions. To disable, you just have to revert the changes you've done in about:config - set gfx.font_rendering.directwrite.enabled to false and mozilla.widget.render-mode to its default value of -1.

There is also an article in the Mozilla Wiki describing the new feature in detail.

How to determine that it is working?

  • Look closely at the fonts. With DirectWrite font rendering enabled, normal fonts look much better. The antialiasing is better than standard Clear Type and generally, text just looks smoother. However, because of some issues in DirectWrite itself and the implementation in Firefox, some fonts, especially bold variants or light-colored fonts on dark backgrounds, are looking worse than with standard GDI font rendering. These are current issues and one can assume that they will be solved once the entire thing becomes more mature.
  • Some things will be A LOT faster, especially SVG graphics. Here is a nice page to test it - When Direct2D is enabled, the animation should run much smoother and the browser will consume less CPU at the same time. And here is an even more demanding stress test that should run at 20+ fps with Direct2D enabled. Without Direct2D it will probably not reach more than 1-3 fps, even on very fast systems. The Fishtank test by Microsoft is another Direct2D benchmark which MS put up to test the performance of the IE9 tech preview (which also supports D2D).
  • Smooth scrolling is smoother :) Yes, that's only noticeable with some pages, because in Firefox 4, smooth scrolling is generally smooth enough, even without Direct2D. But with some complex and image heavy pages, there is a difference.
  • Check GDI objects in the task manager. The GDI object count will be much lower when Direct2D rendering is active. Memory consumption, however, seems to be slightly higher.

This is definitely a nice step into the right direction. After focusing on JavaScript performance for a while, it's now time to speed up the rendering by using new technologies instead of the almost 20 years old and painfully slow GDI API. Even in its relatively early stage of implementation, the benefits are clearly visible and the remaining issues will certainly vanish over time.

1 Like Like
No comments yet.

Subject

  (this is optional)

Comment text

Allowed HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>