Tuesday, November 26, 2013

No more main-thread OpenGL in Firefox (important note for Linux users who use OpenGL)

Main-thread compositing with OpenGL is no more (bug 924403). The only option for OpenGL compositing is off-main-thread compositing (OMTC). This is the first big chunk of code removal following on from the layers refactoring, which began more than a year ago. It is very nice to finally be removing code and reducing the number of code paths in the graphics module.

Most users should not notice a difference. All supported configurations which use OpenGL (FirefoxOS, Android, modern OSX) already use OMTC. If you use OpenGL on Linux, however, read on.

OpenGL in Linux

OpenGL on Linux is not a supported configuration (i.e., fixing bugs is not a priority - we would love some volunteer help here, by the way, get in contact if you're keen). However, if you have good luck with your drivers, then it works pretty well and can be enabled by setting the 'layers.acceleration.force-enabled' pref to true. The main benefit is improved WebGL performance. OMTC on Linux also works pretty well, but is also not a supported configuration. If you want to continue using OpenGL on Linux for versions of Firefox 28 and later you will need to use OMTC. (Note that if you are considering trying OpenGL on Linux for the first time, you should use a new profile to make it easier to undo if your drivers are not cooperative. And be prepared for your system to crash, potentially).

Nightly users will automatically get OMTC, if they currently get OpenGL. That is, for Nightly users, setting 'layers.acceleration.force-enabled' on Linux will get you OpenGL with OMTC.

For Aurora, Beta, and Release users (once version 28 hits those channels), you will also need to set the environment variable 'MOZ_USE_OMTC' and the 'layers.offmainthreadcomposition.enabled' pref (as well as the 'layers.acceleration.force-enabled' pref) if you want OMTC. Otherwise, you will get basic layers (software composition, although usually hardware accelerated by X).

11 comments:

  1. Crap. So does that mean, if I'm making a game in WebGL with the intention of supporting Linux users (as I am, in fact, developing the game on Linux), they will have to manually switch this option from now on?

    If I knew a bit more about OpenGL I'd love to help fix this, but I'm afraid I haven't even read the spec.

    ReplyDelete
  2. Wes Johnston7:31 am

    I had to turn off hardware layers on Linux this week when I realized they were making panning awful for me (bug 942687). I'd be happy to work on that bug and dip my toes into OpenGL, but I'm not exactly sure where to go or start. Any chance you could help?

    ReplyDelete
  3. Jack: no. WebGL is still available for all users. Performance without HWA (e.g., Linux users who don't set the flags/prefs from the blog post) is worse than for users with HWA. Note that if Linux users weren't already setting the 'force' pref, then they do not currently get OpenGL either.

    ReplyDelete
  4. Wes: that doesn't sound like an OpenGL problem, although if turning OpenGL off helped, then obviously it is connected. Sounds like either Azure or image lib, both of which are out of my area. But I cc'ed some people on the bug and I'm sure they'd be happy to help you investigate

    ReplyDelete
  5. Thanks Nick- that clears things up a bit. Without these settings, the performance is good enough for what I'm making, but it's nice to see the FPS pick up a notch with these settings. I suppose I can note that as a recommendation for players if they happen to be using Firefox on Linux and aren't getting the smoothness they were hoping for.

    Here's hoping for a more permanent solution on the horizon. It's just nice to know this won't be an issue on Firefox OS. :)

    ReplyDelete
  6. Anonymous2:04 am

    Is WebGL on Linux supported, but not OpenGL on Linux? Is OpenGL == layers acceleration, so WebGL can run without that but it's just slower?

    ReplyDelete
  7. Anonymous: yes, exactly. WebGL is still around, that is something we present to the web. When I say OpenGL, I mean our use of OpenGL to implement the browser. Users should not notice any difference except (maybe) speed.

    ReplyDelete
  8. I guess there is no way to get OpenGL going on Windows?

    Setting the following to true enables D3D11 instead of D3D10 and there is no mention of OpenGL in about:support

    layers.offmainthreadcomposition.enabled
    layers.acceleration.force-enabled
    layers.prefer-opengl

    ReplyDelete
  9. geeknik: you should try d3d11 OMTC on Windows, you might like it :-) OpenGL does sort of work on Windows, but I think you need to hack the source to get it, it is not a maintained platform and was broken for a long time. I'm not sure about the current status. OMTC with d3d should work fine though.

    ReplyDelete
  10. Anonymous2:52 pm

    Awesome! I can now play BananaBread or the Unreal Engine demo full speed on Linux!

    ReplyDelete
  11. Computer problem solving is actually an art

    Wireless Cable Modems

    ReplyDelete