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

Reviewed by Wenson Hsieh.

* Source/WebCore/page/InteractionRegion.cpp:
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/
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:
git-svn-id: 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 =[&](auto rect) {
region.rectsInContentCoordinates = compactMap(rectsInContentCoordinates, [&](auto rect) -> std::optional<FloatRect> {
auto contentsRect = rect;

if (&frameView != &mainFrameView)

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))
auto enclosingFrame = enclosingIntRect(sublayer.frame);
if (enclosingFrame.isEmpty())
interactionRegionLayers.set(enclosingFrame, sublayer);

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

0 comments on commit 4c7524f

Please sign in to comment.