glitchy's

blog

privacy.resistFingerprinting

2020-02-06 | kahootzreverse engineeringthree.js


So there's an obscure bug which I've spent the longest time trying to fix, that causes performance issues on Kahootz club. But it only occurs in incredibly specific instances on Firefox. I've tried reconfiguring everything in the engine, making the site use high-performance mode, reducing graphics and testing other renderers, but nothing worked...

Then, when I added animations to kahootz, I noticed something strange - Looking around with the mouse cursor was smooth, but the animations were lagging weirdly. This didn't make sense to me, like why would those things be lagging but everything else performing normally? There's no framerate issues as far as I can tell.

I gave up on it for a while, until one day when I was messing around with my browser settings I noticed the same performance issues my friend was getting.

a configuration screen that shows 'privacy.resistFingerprinting equals true'

I went through and tested all the settings individually, and eventually found the culprit. But why would fingerprinting resistance cause lag in a webgl environment in the browser?

Well, it's not even related to WebGL. While resistFingerprinting does change some webgl specific settings, it still runs fine. There's plenty of webgl-based sites that don't have the same issues.

Eventually after looking around for a while and trying to find a list of all the things that firefox does to hide it's identity, I came across the Performance API, which I happened to be using for delta timing.

By default, it returns timestamps with a 1ms precision, but enabling fingerprinting changes that to be a 100ms precision, or 1/10th of a second. This means that every 1/10th of a second when the main() loop would run, it would update the meshes and camera location. If it hadn't been 1/10th of a second there was no update, making it appear as if the game wasn't performing well.

some really ugly javascript code containing a solution to the performance issues

So how did I fix it? Well it's not really fixed, there's no way for me to get accurate time when the privacy settings are enabled, and there's no way for me to get the browser FPS so I can't tell what framerate to run the program at.

Instead, there's some code that checks if the performance API is only returning timestamps every 100ms. If it detects this, it will disable delta-timing, and the timers for animations and movement speed will be locked to approx. 66.66 frames per second.

Why 66.66? Because it's slightly above 60 fps, and for some reason it runs much better on most machines. Probably another timing precision thing, but I won't be making a post on that.

A scifi looking digital world with lots of gizmos everywhere. The walls and floor have grid patterns on them, and there's some red balls floating around a core reactor.

Before you go, please be sure to check out kahootz club. I've been working hard at it for a while, and there's already 13 environments to fly around. Some of them are even animated!

That's all for today. Thanks for reading! :)