This is exactly what it is, common issue on Roblox, happens also on just client-sided calculations that involve floating points for example. Regardless the math should be synced though.
I do not think this is a software issue. Floating point is handled by hardware, specifically the math coprocessor which is specifically designed to perform floating point math calculations. The IEEE 732 standard defines floating point math in all it’s gory details. What’s going on is either the server or the client has a faulty math coprocessor or one that does not conform to standards.
Since you are getting the same results in Studio from both the client and server, this makes sense since they are both running on the same hardware. However, on the live game, the client and server are running on completely different machines. Since Roblox uses cloud services to host their platform, I’m not sure that this is something that Roblox can fix as it’s a hardware issue. The best that you can do to help Roblox isolate which physical computer is doing it is to also print out the game.JobId on the server which uniquely identifies that game instance. From there, Roblox will have to issue a trouble ticket to the cloud host provider for them to figure out what’s going on. The CPU might need a microcode update. Or it could also be a problem with the way that the transistors on the CPU chip itself are physically wired together. Problems like this has happened before with badly designed hardware. In any case, it’s a physical CPU problem. Probably a bad version/stepping combination.
I tried to write some code that implements fromEulerAnglesYXZ in lua since that is where the bug lies, and it got the correct results both on the client and on the server, wouldn’t the lua code run into the same issue if it was an issue on the hardware?
The question that I have for you is did you do this in Studio or did you do this on the live server? If you did this in Studio, then of course the client and server results will match because both are running on the same hardware. However, Roblox employs literally THOUSANDS of individual servers in a data center. One server, or a group of servers is like finding a needle in a haystack when you have a whole datacenter of servers to search through for a bad CPU stepping that has a math problem.
When I look at the video, the mismatch starts to occur at the 7th decimal place. So in Roblox, the question is, does it really matter at that point? Considering it’s CFrame.FromEulerAnglesYXZ, it’s calling different trigonometry functions in the FPU (Floating Point Unit/Math Coprocessor). Trig functions are generally transcendental which means that they are using a polynomial of a few terms to get the result. So when I see that the error starts at the 7th decimal place, that tells me that the error is most likely the difference in the number of terms of the polynomial that the FPU is using between different die versions.
To calculate a transcendental function in software, the way that I have done it is that I performed a power series calculation until the result doesn’t change anymore via successive approximation. Then return that result which is at the limit of the precision of the floating point type. Faster methods use a fixed polynomial to calculate the result with reduced accuracy in exchange for performance. For day to day stuff like home or office type work, or even software development, this is acceptable. But if you’re doing something like serious number crunching, engineering, or scientific computing, that will be a problem. I would rather have this error on Roblox than on someone simulating protein folding for drug research.
With an FPU, the polynomial is engraved in hardware. The only way to fix it is either update the microcode, which is not always possible, or change the hardware.
I really doubt it’s an issue with the hardware the game servers run on. I’ve tried running the code on a variety of random games that I have, and the server always produces the same incorrect result. It would be incredibly unlikely for me to get the exact same potentially faulty server hardware on every single attempt.
Additionally, I’ve had a few of my friends who run different hardware join and report their results, and it always matched the result my machine calculated, which leads me to believe it’s not an issue with my hardware either.
Thank you for the report.
Unfortunately, many of the floating-point operation results are not guaranteed to be the same between different hardware or even on the same hardware when a complex operation is implemented in software (and can change over time with updates to the implementation).
Even when standards like IEEE 754 require specific precision for a conforming hardware, additional guarantees over combination of those operations (even for a * b + c) are not guaranteed to be followed by the programming languages (in this case, C++, used by both Roblox engine and Luau VM).
Historically, software which required reproducible results often had to switch over to things like fixed point arithmetic.
This brings up a very interesting question then. Why is the Roblox server platform not using hardware for floating point operations? Or are you and it’s a compiler issue? Just out of curiosity, what C++ compiler does Roblox use on the server? Microsoft VC++, gcc, LLVM, or something else? It sounds like a defective math library or a bad pattern in the compiler’s code generator.
@Troopermaan With this information, I’m inclined to agree that this is a software problem. I think it’s specifically with the compiler Roblox is using. I do not know how familiar you are with C/C++, but when you define a floating point type, the compiler automatically generates the code to involve the FPU in the calculation.