Silent test flaw hid cross-runtime game logic mismatch for months

A developer building a browser version of a shipped Android game discovered that the same seed and inputs produced entirely different outcomes across the JVM and TeaVM runtimes — a score of 9 versus 6 with one build dying early. The root cause was that java.util.Random's behavior, while documented as a specific linear congruential generator, is not guaranteed to be replicated identically by foreign runtimes like TeaVM. An existing determinism test had been passing throughout, but it was structurally flawed — it ran the engine twice within the same runtime, making it incapable of detecting disagreements between runtimes. The fix took just ten minutes: replacing java.util.Random with a hand-written LCG so both builds execute identical arithmetic. The developer notes that even a golden-file test pinning one runtime's output would have been equally blind, since only a direct cross-runtime diff can expose this category of bug.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in