From 5d687c962b8a4c2a2ef660628ff6f3d3ae2772d7 Mon Sep 17 00:00:00 2001 From: Botond Ballo Date: Fri, 17 Jun 2022 23:50:49 +0000 Subject: [PATCH] Bug 1771503 - Disable the 'two layers that scroll together' assertion for matrices with Inf or NaN elements. r=tnikkel Differential Revision: https://phabricator.services.mozilla.com/D149466 --- gfx/2d/Matrix.h | 12 ++++++++++++ gfx/layers/apz/src/APZCTreeManager.cpp | 19 ++++++++++++++----- layout/base/crashtests/1771503.html | 22 ++++++++++++++++++++++ layout/base/crashtests/crashtests.list | 1 + 4 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 layout/base/crashtests/1771503.html diff --git a/gfx/2d/Matrix.h b/gfx/2d/Matrix.h index 0d07eaf4c3aa..cdb2284188c2 100644 --- a/gfx/2d/Matrix.h +++ b/gfx/2d/Matrix.h @@ -1510,6 +1510,18 @@ class Matrix4x4Typed { _44 = UnspecifiedNaN(); } + // Verifies that the matrix contains no Infs or NaNs + bool IsFinite() const { + return mozilla::IsFinite(_11) && mozilla::IsFinite(_12) && + mozilla::IsFinite(_13) && mozilla::IsFinite(_14) && + mozilla::IsFinite(_21) && mozilla::IsFinite(_22) && + mozilla::IsFinite(_23) && mozilla::IsFinite(_24) && + mozilla::IsFinite(_31) && mozilla::IsFinite(_32) && + mozilla::IsFinite(_33) && mozilla::IsFinite(_34) && + mozilla::IsFinite(_41) && mozilla::IsFinite(_42) && + mozilla::IsFinite(_43) && mozilla::IsFinite(_44); + } + void SkewXY(double aXSkew, double aYSkew) { // XXX Is double precision really necessary here T tanX = SafeTangent(aXSkew); diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index eb06bcf28110..5f25273e1795 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -1322,8 +1322,10 @@ HitTestingTreeNode* APZCTreeManager::PrepareNodeForLayer( // In such cases, go with the one that does not include the perspective // component; the perspective transform is remembered and applied to the // children instead. - if (!aAncestorTransform.CombinedTransform().FuzzyEqualsMultiplicative( - apzc->GetAncestorTransform())) { + auto ancestorTransform = aAncestorTransform.CombinedTransform(); + auto existingAncestorTransform = apzc->GetAncestorTransform(); + if (!ancestorTransform.FuzzyEqualsMultiplicative( + existingAncestorTransform)) { typedef TreeBuildingState::DeferredTransformMap::value_type PairType; if (!aAncestorTransform.ContainsPerspectiveTransform() && !apzc->AncestorTransformContainsPerspective()) { @@ -1333,9 +1335,16 @@ HitTestingTreeNode* APZCTreeManager::PrepareNodeForLayer( // cases, it's expected that different instances can have different // transforms, since each page renders a different part of the item. if (!aLayer.Metadata().IsPaginatedPresentation()) { - MOZ_ASSERT(false, - "Two layers that scroll together have different ancestor " - "transforms"); + if (ancestorTransform.IsFinite() && + existingAncestorTransform.IsFinite()) { + MOZ_ASSERT( + false, + "Two layers that scroll together have different ancestor " + "transforms"); + } else { + MOZ_ASSERT(ancestorTransform.IsFinite() == + existingAncestorTransform.IsFinite()); + } } } else if (!aAncestorTransform.ContainsPerspectiveTransform()) { aState.mPerspectiveTransformsDeferredToChildren.insert( diff --git a/layout/base/crashtests/1771503.html b/layout/base/crashtests/1771503.html new file mode 100644 index 000000000000..de7c4990fb36 --- /dev/null +++ b/layout/base/crashtests/1771503.html @@ -0,0 +1,22 @@ + + + + + + + + +
+
+ +
+
+ + diff --git a/layout/base/crashtests/crashtests.list b/layout/base/crashtests/crashtests.list index a9e85ef7a762..d3b039ad800c 100644 --- a/layout/base/crashtests/crashtests.list +++ b/layout/base/crashtests/crashtests.list @@ -568,3 +568,4 @@ pref(layout.accessiblecaret.enabled,true) load 1746989.html load 1752649.html load 1753779.html pref(layout.css.backdrop-filter.enabled,true) load 1755790.html +load 1771503.html