Browser differences cross platform
Hi, for my purpose, I need a deterministic simulation using different browsers and different platforms. I'm using the config isFixed = true. I made some tests using a simple simulation with lots of circle bodies. I found that on different systems and browsers the following different results A, B and C can be reproduced:
| Operating System | Chrome | Safari | Firefox | Edge |
|---|---|---|---|---|
| macOS | A | B | B | - |
| iOS | C | C | C | - |
| Android | A | - | - | - |
| Window 10 | A | - | - | A |
After some investigations, I discovered, that the trigonometric functions, like Math.sin() or Math.cos() could have different implementations, depending on browser and operating systems. This will lead into different results of the same simulation. Then I came across with the polyfill Trigfills (https://github.com/strainer/trigfills), which just overrides the trigonometric functions. After using this polyfill, MatterJS is running fully deterministic across all systems and browsers (which I tested). I had no performance differences with and without the polyfill.
This is not an issue, but I want to share my solution.
Thanks for sharing, helpful for multiplayer games especially.
Another browser consistency issue can sometimes be seen in the native array sort implementation (sort stability).
It feels like there would be accuracy / performance / consistency tradeoffs with this though, so probably best left a user decision to implement this I think.