Skip to content
Permalink
Browse files
REGRESSION (r294160): Occasional infinite loops under updateLayersFor…
…InteractionRegions

https://bugs.webkit.org/show_bug.cgi?id=240610
<rdar://problem/93507791>

Reviewed by Wenson Hsieh.

* Source/WebCore/page/InteractionRegion.cpp:
(WebCore::regionForElement):
Avoid emitting empty rects for interaction regions, and avoid emitting the region
at all if this results in an empty set of rects.

* Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeInteractionRegionLayers.mm:
(WebKit::updateLayersForInteractionRegions):
Never re-use a layer with empty bounds; we should never get here, but I'd rather
re-create the layer if we do than corrupt the hash table.

Canonical link: https://commits.webkit.org/250729@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294467 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
hortont424 committed May 19, 2022
1 parent 3fb9514 commit 4c7524f6d1f842c64ce732f1f50d52d1d4c80b57
Showing 2 changed files with 14 additions and 7 deletions.
@@ -107,23 +107,26 @@ static std::optional<InteractionRegion> regionForElement(Element& element)
return rect;
});

if (rectsInContentCoordinates.isEmpty())
return std::nullopt;

if (is<RenderBox>(*renderer)) {
RoundedRect::Radii borderRadii = downcast<RenderBox>(*renderer).borderRadii();
region.borderRadius = borderRadii.minimumRadius();
}

region.rectsInContentCoordinates = rectsInContentCoordinates.map([&](auto rect) {
region.rectsInContentCoordinates = compactMap(rectsInContentCoordinates, [&](auto rect) -> std::optional<FloatRect> {
auto contentsRect = rect;

if (&frameView != &mainFrameView)
contentsRect.intersect(frameClipRect);

if (contentsRect.isEmpty())
return std::nullopt;

return contentsRect;
});


if (region.rectsInContentCoordinates.isEmpty())
return std::nullopt;

return region;
}

@@ -87,8 +87,12 @@ void updateLayersForInteractionRegions(CALayer *layer, const RemoteLayerTreeTran

HashMap<IntRect, CALayer *> interactionRegionLayers;
for (CALayer *sublayer in layer.sublayers) {
if (isInteractionRegionLayer(sublayer))
interactionRegionLayers.set(enclosingIntRect(sublayer.frame), sublayer);
if (!isInteractionRegionLayer(sublayer))
continue;
auto enclosingFrame = enclosingIntRect(sublayer.frame);
if (enclosingFrame.isEmpty())
continue;
interactionRegionLayers.set(enclosingFrame, sublayer);
}

bool applyBackgroundColorForDebugging = [[NSUserDefaults standardUserDefaults] boolForKey:@"WKInteractionRegionDebugFill"];

0 comments on commit 4c7524f

Please sign in to comment.