• Mikel Astiz's avatar
    Avoid unnecessary favicon downloads on desktop · e9abde5a
    Mikel Astiz authored
    Prior to this patch, desktop favicon downloading would only stop when
    a truly ideal icon is found, which means a favicon with perfect bitmaps
    sizes for all supported screen densities (often a .ico file with a
    16x16 AND a 32x32 bitmap). This often leaded to all icons being
    downloaded, even for cases where it's obviously unnecessary.
    
    The patch adopts the logic we currently use on mobile within
    FaviconHandler::UpdateFaviconCandidate() in order to stop processing
    favicon candidates if there is little hope that the next ones will be
    any better.
    
    This requires some smartness for favicon candidates without an explicit
    'sizes' attribute, which would score very low prior to this patch and
    hence would rarely be processed (if other candidates exist). Hence,
    we special-case them for desktop and score them highest during initial
    sorting, which mimics the behavior prior to this patch and guarantees
    they will be processed unless an ideal favicon is found before.
    
    It's rather trivial to rule out regressions for the following common
    scenarios:
    A. Mobile platforms: no behavioral changes as score stays zero for
       candidates without explicit 'sizes' attribute.
    B. A single favicon is listed by the page.
    C. Multiple favicons are listed and none have a 'sizes' attribute
       (sorting does nothing and all are processed unless an ideal one is
       found).
    D. Multiple favicons are listed and they all have an accurate 'sizes'
       attribute (scenario improved in this patch).
    
    The more complex scenario is when a web page lists multiple favicons
    and only some have a 'sizes' attribute. In this case, there is some
    minor risk for regressions given that the patch scores highest the
    favicons without a 'sizes' attribute, so they will be downloaded and
    processed earlier.
    
    Bug: 895175,705900,672076
    Change-Id: I8216652ede25f55332cacc54d3e0a806fd8b7bc3
    Reviewed-on: https://chromium-review.googlesource.com/c/1323551
    Commit-Queue: Mikel Astiz <mastiz@chromium.org>
    Reviewed-by: default avatarPeter Kotwicz <pkotwicz@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#610800}
    e9abde5a
favicon_handler.cc 27.3 KB