From c6d979bda0a0549e2109cf19f1e3078b1161e5b5 Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 5 Jan 2023 18:32:39 +0000 Subject: [PATCH 1/2] Remove strict equality check for SkMatrix comparison --- .../flutter/gfx_external_view_embedder.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/shell/platform/fuchsia/flutter/gfx_external_view_embedder.cc b/shell/platform/fuchsia/flutter/gfx_external_view_embedder.cc index c616ded3464a8..71917c93d48bb 100644 --- a/shell/platform/fuchsia/flutter/gfx_external_view_embedder.cc +++ b/shell/platform/fuchsia/flutter/gfx_external_view_embedder.cc @@ -328,15 +328,13 @@ void GfxExternalViewEmbedder::SubmitFrame( kScenicZElevationBetweenLayers * scenic_layer_index + embedded_views_height; - if (view_mutators.total_transform != view_params.transformMatrix()) { - FML_LOG(ERROR) << "Failed assertion: view_mutators.total_transform " - "!= view_params.transformMatrix()"; - FML_LOG(ERROR) << "view_mutators.total_transform:"; - view_mutators.total_transform.dump(); - FML_LOG(ERROR) << "view_params.transformMatrix():"; - view_params.transformMatrix().dump(); - FML_LOG(FATAL) << "view_mutators.total_transform " - "!= view_params.transformMatrix()"; + // Use built-in get method for SkMatrix to get values + // See: + // https://source.corp.google.com/piper///depot/google3/third_party/skia/HEAD/include/core/SkMatrix.h;l=391 + for (int index = 0; index < 9; index++) { + FML_CHECK(SkScalarNearlyEqual( + view_mutators.total_transform.get(index), + view_params.transformMatrix().get(index), 0.0005f)); } // Set clips for the platform view. From 0c7ac4445051c23d49ecc0957cc3dc613adcbd3f Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 5 Jan 2023 19:54:06 +0000 Subject: [PATCH 2/2] Address PR comments --- .../flutter/gfx_external_view_embedder.cc | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/shell/platform/fuchsia/flutter/gfx_external_view_embedder.cc b/shell/platform/fuchsia/flutter/gfx_external_view_embedder.cc index 71917c93d48bb..48816a428f0af 100644 --- a/shell/platform/fuchsia/flutter/gfx_external_view_embedder.cc +++ b/shell/platform/fuchsia/flutter/gfx_external_view_embedder.cc @@ -328,14 +328,28 @@ void GfxExternalViewEmbedder::SubmitFrame( kScenicZElevationBetweenLayers * scenic_layer_index + embedded_views_height; - // Use built-in get method for SkMatrix to get values + // Verify that we're unpacking the mutators' transform matrix correctly + // on debug builds Use built-in get method for SkMatrix to get values // See: // https://source.corp.google.com/piper///depot/google3/third_party/skia/HEAD/include/core/SkMatrix.h;l=391 +#ifdef NDEBUG for (int index = 0; index < 9; index++) { - FML_CHECK(SkScalarNearlyEqual( - view_mutators.total_transform.get(index), - view_params.transformMatrix().get(index), 0.0005f)); + const SkScalar mutators_transform_value = + view_mutators.total_transform.get(index); + const SkScalar params_transform_value = + view_params.transformMatrix().get(index); + if (!SkScalarNearlyEqual(mutators_transform_value, + params_transform_value, 0.0005f)) { + FML_LOG(FATAL) + << "Assertion failed: view_mutators.total_transform[" << index + << "] (" << mutators_transform_value + << ") != view_params.transformMatrix()[" << index << "] (" + << params_transform_value + << "). This likely means there is a bug with the " + << "logic for parsing embedded views' transform matrices."; + } } +#endif // Set clips for the platform view. if (view_mutators.clips != view_holder.mutators.clips) {