| Reference | Downloads | Github

Reaction time in Firefox (but not Chrome!) is imprecise

Description of the problem:
I’m running into quite a strange issue, and I would like to figure out an immediate workaround if any is possible. The reaction time being logged from a keyboard response component works fine in Chrome, but when I test the task in Firefox, the logged RT is rounded to the nearest 1st decimal place (e.g. 0.123 is rounded to 0.1). As far as I know, this ONLY happens in Firefox (76.0.1 – 64-bit).

I attempted my own workaround/diagnosis but didn’t get very far. I used javascript to log the RT variable, and it comes out rounded in Firefox console. In Firefox, console.log(target_response.rt) returns 0.7000000000000028 or 1.2999999999999972 or 0.4000000000000057 or 0.5, etc. On the other hand, if I run in Chrome I get values like 0.7578500000527129, 0.24132999998982996, and 0.4257750000106171. So this rounding is present at the level of the initial logging of RT, not at the later stage or recording the trial data.

The linked experiment logs the RTs to the console, so you can take a look at the console yourself in both browsers. For each RT logged, I print the numeric representation and the string representation (I was hoping this was going to be a possible workaround). Is there some way around this issue? My plan is to take a look deeper into the PsychoJS API to see if I can manually log the RT’s without relying on the keyboard component’s RT value, but if someone could show me a quick fix I’d very much appreciate it!

How about using the PsychoPy variable t, which is the time since the beginning of the routine?

Thanks for this report Kevin, @jon and other developers discussed it today as an example of why we need more automated testing of PsychoJS (in the same way we currently do for PsychoPy), to more proactively capture issues that arise with browser updates.

Online performance was recently comprehensively studied across a range of browsers, as described in this reprint, and this effect was not seen in Firefox then:

so we need to look further into this.

I found the root of the issue, and it’s due to my particular Firefox settings!

EDIT: for those just interested in the solution to the issue: For precise timing in Firefox, privacy.resistFingerprinting needs to be false. This can be changed by going to about:config. As far as I know, this is the default setting for Firefox, so it shouldn’t be too much of a worry.

I logged timing manually with:

new Date().getTime()


Both logged values to the nearest 100 milliseconds in Firefox. So it’s clearly a Firefox issue, not a PsychoJS issue.

A bit of internet sleuthing revealed that this was implemented to provide user privacy by combatting fingerprinting techniques. The change was introduced to the Tor browser:
And Firefox:

It is enabled in Firefox when the user has changed privacy.resistFingerprinting to “true” in their about:config. I changed that setting to “false” on my end and the logs show millisecond precision now. I do not think this is true by default, so it’s unlikely to occur (but did for me, because I err on the side of internet privacy). Yet another thing to consider when testing online!

yes, as Mike says, we don’t see that in our measures of Firefox on any of the operatings systems. If you look at Win10/Firefox/PychoPy for instance you get the distribution below. So either this depends on the veriosn of firefox used, or there’s some setting in Firefox to turn of timing? :thinking:

Ah, OK, it’s that you logged the time manually! That might have been a thing to mention before! :wink:

Yes, you need to use performance timer. Preferably though, use the times coming out of PsychoPy’s own clocks for response objects. These are know how to synchronise with the screen refresh too so that the t=0 is based when the stimulus appears whereas your home-grown timing will probably be based on some arbitrary timepoint within the refresh cycle. Getting timing right is non-trivial and that’s why the different packages don’t all peform the same in this regard! :wink:

Note that this affects psychojs’s timing as well. The original issue was not with my own manual timing with javascript – I was doing that to diagnose the issue. If privacy.resistFingerprinting is “true” in Firefox settings, then javascript can NOT provide ms precision timing, even the default psychojs functions.

Oh, haha, I see. Sorry to cast aspersions! :slight_smile: And thanks for tracking it down