Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit d552fa3

Browse files
authored
[flatland] Reduce size of hit-region. (#36447)
Currently, the hit-region is size FLT_MAX which is susceptible to numerical overflow when rotating or translating (or any other modification to the value).
1 parent e08c292 commit d552fa3

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

shell/platform/fuchsia/flutter/flatland_external_view_embedder.cc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
#include "third_party/skia/include/core/SkSurface.h"
1111

1212
namespace flutter_runner {
13+
namespace {
14+
15+
// Since the flatland hit-region can be transformed (rotated, scaled or
16+
// translated), we must ensure that the size of the hit-region will not cause
17+
// overflows on operations (like FLT_MAX would).
18+
constexpr float kMaxHitRegionSize = 1'000'000.f;
19+
20+
} // namespace
1321

1422
FlatlandExternalViewEmbedder::FlatlandExternalViewEmbedder(
1523
fuchsia::ui::views::ViewCreationToken view_creation_token,
@@ -312,11 +320,12 @@ void FlatlandExternalViewEmbedder::SubmitFrame(
312320
child_transforms_.emplace_back(
313321
flatland_layers_[flatland_layer_index].transform_id);
314322

315-
// Attach full-screen hit testing shield.
323+
// Attach full-screen hit testing shield. Note that since the hit-region
324+
// may be transformed (translated, rotated), we do not want to set
325+
// width/height to FLT_MAX. This will cause a numeric overflow.
316326
flatland_->flatland()->SetHitRegions(
317327
flatland_layers_[flatland_layer_index].transform_id,
318-
{{{0, 0, std::numeric_limits<float>::max(),
319-
std::numeric_limits<float>::max()},
328+
{{{0, 0, kMaxHitRegionSize, kMaxHitRegionSize},
320329
fuchsia::ui::composition::HitTestInteraction::
321330
SEMANTICALLY_INVISIBLE}});
322331
}

0 commit comments

Comments
 (0)