Ticket #1193 (new defect)
Replace SpiderMonkey's Math functions with platform consistent versions
| Reported by: | historic_bruno | Owned by: | quantumstate |
|---|---|---|---|
| Priority: | Should Have | Milestone: | Backlog |
| Component: | Core engine | Keywords: | spidermonkey |
| Cc: | Philip |
Description (last modified by historic_bruno) (diff)
As Philip reported on Bugzilla, there are differences in SpiderMonkey's floating point Math functions on different platforms. Even a small discrepancy can cause OOS errors in multiplayer games, if those functions are used in e.g. simulation, map generation, or AI code. We already use fixed point approximations for sin/cos and atan2 in the engine, but not yet for scripts. Currently no scripts appear to use atan, acos, or asin.
(There may also be differences in pow and exp which we do use rarely, but I wasn't able to reproduce them with the above test cases.)
Attachments
Change History
comment:2 Changed 15 months ago by historic_bruno
- Description modified (diff)
- Summary changed from Replace SpiderMonkey's trig functions with safe fixed-point versions to Replace SpiderMonkey's trig functions with platform consistent versions
Updated title and description since fixed point is no longer the focus.
Also [11220] is relevant, it introduced a new rmgen function GetAngle, which calls Math.acos. I don't know if acos is even a problem, I simply mentioned all the trig functions :)
comment:4 Changed 15 months ago by historic_bruno
This ticket is probably solved well enough for Alpha 9. Would be nice to add some tests eventually.
Changed 15 months ago by quantumstate
These changes should fix the ticket, will wait till after A9 to commit them
comment:7 Changed 13 months ago by leper
A slightly modified version of the last diff was applied in [11363].
comment:8 Changed 13 months ago by quantumstate
This is not closed because we were wanting to add some tests. I should get round to this sometime soon.
comment:10 Changed 12 months ago by historic_bruno
comment:11 Changed 11 months ago by ben
In 12056:
comment:12 Changed 8 weeks ago by historic_bruno
- Summary changed from Replace SpiderMonkey's trig functions with platform consistent versions to Replace SpiderMonkey's Math functions with platform consistent versions
Should also replace Math.pow and Math.exp at some point.

The sin/cos approximations which are accurate to about 10-9 have been added with commit http://trac.wildfiregames.com/changeset/11226 . I will look at writing a good approximation for atan2.