Please sign in to comment.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ImageAnalysisQueue should reanalyze image elements whose image source…
…s have changed https://bugs.webkit.org/show_bug.cgi?id=240371 rdar://93175651 Reviewed by Tim Horton. Currently, ImageAnalysisQueue maintains the set of all image elements that have been queued for analysis, and avoids re-queueing such image elements. However, on some websites, this leads to stale analysis results being shown in certain image elements that have changed image sources (and subsequently finished loaded the new image). To address this, we introduce a mechanism to remember the latest image URL for image elements that have been analyzed using the analysis queue; we only avoid reanalyzing these same image elements if the source URL is the same as the source URL when we last analyzed it. This allows us (for instance) to handle the scenario where a single image element periodically cycles between different `src` attribute values. Test: ImageAnalysisTests.AnalyzeImageAfterChangingSource * page/ImageAnalysisQueue.cpp: (WebCore::ImageAnalysisQueue::enqueueIfNeeded): Also avoid trying to prematurely analyze images whose cached images only contain the null image. This caused empty results to sometimes be incorrectly cached for some image elements, if analysis is triggered too early. (WebCore::ImageAnalysisQueue::resumeProcessing): * page/ImageAnalysisQueue.h: To aid with debugging similar issues in the future, plumb the image URL through to `requestImageAnalysisWithIdentifier`, which (if an engineering default is specified) will additionally reveal the URL in system logs. * Platform/cocoa/ImageAnalysisUtilities.h: * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::WebViewImpl::requestTextRecognition): * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView requestTextRecognition:imageData:identifier:completionHandler:]): Add an API test to exercise the scenario by verifying that the same image element is reanalyzed after setting the `src` to a different image URL. * TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/250546@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294179 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing with 110 additions and 6 deletions.
- +29 −0 Source/WebCore/ChangeLog
- +30 −1 Source/WebCore/page/ImageAnalysisQueue.cpp
- +3 −2 Source/WebCore/page/ImageAnalysisQueue.h
- +18 −0 Source/WebKit/ChangeLog
- +1 −1 Source/WebKit/Platform/cocoa/ImageAnalysisUtilities.h
- +1 −1 Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
- +1 −1 Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
- +14 −0 Tools/ChangeLog
- +13 −0 Tools/TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm