Skip to content

Instantly share code, notes, and snippets.

@Gankra
Created September 13, 2018 22:08
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gankra/013af66babdbf50428ac10450cb3ba8c to your computer and use it in GitHub Desktop.
Save Gankra/013af66babdbf50428ac10450cb3ba8c to your computer and use it in GitHub Desktop.

Properly Running MotionMark On Firefox

TL;DR: to get accurate/useful numbers for MotionMark in Firefox you must set these flags in about:config and restart your browser:

layers.offmainthreadcomposition.frame-rate = 0 (defaults to -1)
privacy.reduceTimerPrecision = false (defaults to true)

The first enables "ASAP mode" which tells the browser to paint frames as much as possible, and the second disables an important Spectre security mitigation that reduces the precision.

reduceTimePrecision likely also affects other browser-based benchmarks.

Be sure to turn these options off and restart again after running MotionMark!


MotionMark is a bit of a weird benchmark. Instead of trying to run a fixed load as fast as possible and checking how well you did, it tries to adaptively determine how heavy a load your browser can run at 60fps.

There are two ways this can go wrong: something interfering with how we generate frames, and something interfering with our time sampling.

As it turns out, out of the box, Firefox messes with both of these.

For frame generation, Firefox defaults to only trying to generate frames in tandem with vsync. For most computers this means Firefox will try to stick to 60fps. This is a problem for MotionMark because the only two signals it can get are "the framerate is low, this is too much" and "the framerate is just right, I can't handle any more". As such, it can easily get confused and continously ratchet down the difficulty of the test, producing minimum scores. When this happens it should be pretty obvious: the test will have a value around 1 to 3.

To mitigate this issue, you need to enable "ASAP mode", which tells firefox to try to render as fast as possible. This is done by setting layers.offmainthreadcomposition.frame-rate = 0 in about:config (0 is ASAP, -1 is match vsync, and all other values specify a specific target framerate). Note that this will make Firefox incredibly unpleasant to use, as it wasn't designed to run this way normally.

For time sampling, there is a less fundamental and relatively recent problem: Spectre forced browser developers to break precise timers. As of Firefox 60, timers are only precise to 2ms. This is a pretty significant limitation when you're trying to measure something on the order of 16ms. It has similar effects, causing MotionMark to get confused and death-spiral or thrash.

To mitigate this issue, you need to disable the mitigation by setting privacy.reduceTimerPrecision = false in about:config. Note that this will make your system less secure.

I believe both of these settings are only evaluated on startup, so you will need to restart the browser for these settings to stick.

On Mozilla Toronto's reference hardware, these two mitigations were the difference between tests coming back with ±135.72% variance (useless) and ±0.65% variance (pretty good).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment