Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b82feba1824ebd42478f2ad9eecb7c112a24db49
      
https://github.com/WebKit/WebKit/commit/b82feba1824ebd42478f2ad9eecb7c112a24db49
  Author: Wenson Hsieh <wenson_hs...@apple.com>
  Date:   2025-04-04 (Fri, 04 Apr 2025)

  Changed paths:
    M Source/WebKit/WebProcess/WebPage/ViewGestureGeometryCollector.cpp

  Log Message:
  -----------
  [watchOS] Occasional crash in 
ViewGestureGeometryCollector::computeTextLegibilityScales when double-tapping
https://bugs.webkit.org/show_bug.cgi?id=288407
rdar://145501290

Reviewed by Abrar Rahman Protyasha.

Avoid hash table lookup and mutation in `computeTextLegibilityScales`, in the 
case where the font
size is not a valid `unsigned` hash key; this would correspond to either 0 or 
an extremely large
value anyways, which can safely be ignored for the purposes of this heuristic, 
which attempts to
estimate a good scale to set when double-tapping to zoom that makes most of the 
text on the webpage
legible, based on a histogram of sampled font sizes for visible text in the DOM.

To make this code a bit easier to reason about, we also replace the 
`HashMap<unsigned, unsigned>`
with `HashCountedSet<unsigned>`, and use `add(…)` to increment the counter per 
bucket. Importantly,
we can also use `HashCountedSet::isValidValue` to avoid any attempts to perform 
hash table lookup/
mutations against invalid keys (note that the `ValueType` for a 
`HashCountedSet` corresponds to the
hash key, not the internal count which is always `unsigned`).

* Source/WebKit/WebProcess/WebPage/ViewGestureGeometryCollector.cpp:
(WebKit::ViewGestureGeometryCollector::computeTextLegibilityScales):

Originally-landed-as: 289651.168@safari-7621-branch (fa20ee9ef67f). 
rdar://148057968
Canonical link: https://commits.webkit.org/293235@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to