tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 91f23690161b3d166ec9007e45ee110248c9a390
parent 7112776b715293423fa43a15654d41cb88c7adf9
Author: David Shin <dshin@mozilla.com>
Date:   Tue, 14 Oct 2025 18:25:40 +0000

Bug 1987809: Don't panic on rotate3d quaternion being out-of-range. r=firefox-style-system-reviewers,boris

User-defined values can cause this. Instead, clamp the value fed into `acos`
so we can progress.

Differential Revision: https://phabricator.services.mozilla.com/D268145

Diffstat:
Alayout/style/crashtests/1987809.html | 13+++++++++++++
Mlayout/style/crashtests/crashtests.list | 1+
Mservo/components/style/values/animated/transform.rs | 5+++--
3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/layout/style/crashtests/1987809.html b/layout/style/crashtests/1987809.html @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<script> +window.addEventListener("load", () => { + document.body.animate( + [ + {"transform": "rotate(8e9grad)"}, + {"transform": "rotate3d(25.9, 266.6, 272.7, 6.235554664rad)"}, + ], + 987.35 + ) +}) +</script> +<body></body> diff --git a/layout/style/crashtests/crashtests.list b/layout/style/crashtests/crashtests.list @@ -320,3 +320,4 @@ pref(layout.css.scroll-driven-animations.enabled,true) load 1821416.html load 1872309.html pref(layout.css.scroll-driven-animations.enabled,true) load 1944977.html pref(dom.viewTransitions.enabled,true) load 1966679.html +load 1987809.html diff --git a/servo/components/style/values/animated/transform.rs b/servo/components/style/values/animated/transform.rs @@ -1509,12 +1509,13 @@ impl Animate for ComputedRotate { Quaternion::animate(&fq, &tq, procedure)? }; - debug_assert!(rq.3 <= 1.0 && rq.3 >= -1.0, "Invalid cosine value"); let (x, y, z, angle) = transform::get_normalized_vector_and_angle( rq.0 as f32, rq.1 as f32, rq.2 as f32, - rq.3.acos() as f32 * 2.0, + // Due to floating point precision issues, the quaternion may contain values + // slightly larger out of the [-1.0, 1.0] range - Clamp to avoid NaN. + rq.3.clamp(-1.0, 1.0).acos() as f32 * 2.0, ); Ok(Rotate::Rotate3D(x, y, z, Angle::from_radians(angle)))