RESOLVED FIXED 182083
REGRESSION(r217236): [iOS] PDFDocumentImage does not update its cached ImageBuffer if it has a sub-rectangle of the image
https://bugs.webkit.org/show_bug.cgi?id=182083
Summary REGRESSION(r217236): [iOS] PDFDocumentImage does not update its cached ImageB...
Said Abou-Hallawa
Reported 2018-01-24 19:16:54 PST
The PDFKit currently does not respect the context clipping rectangle. That means to draw a sub-recatnge of the PDF document image, the whole PDF document has to be rendered. This why the PDFDocumentImage draws the PDF document in an ImageBuffer first and then draws this ImageBuffer to the context. The ImageBuffer is cached and reused as long as the scaling factor does not change. In <http://trac.webkit.org/changeset/203378>, the PDFDocumentImage cached ImageBuffer was bounded to a certain limit (64MB) to avoid a jetsam from the system. The check for keeping the cached ImageBuffer was extended to include the fact that the cached ImageBuffer includes only a sub-rectangle from the PDF document and not all of it. In PDFDocumentImage::cacheParametersMatch(), the condition below was added: boo PDFDocumentImage::cacheParametersMatch() { >> if (!m_cachedImageRect.contains(context.clipBounds())) >> return false; } m_cachedImageRect is in context coordinates and we check if the whole clipping rectangle is inside the drawing of the cached ImageBuffer. This condition is valid if the page is a standalone PDF image document. But if the image is inside an HTML page, this condition will be too restricted if the clipping rectangle includes more than the image rectangle even if the whole image drawing is cached in the ImageBuffer. In <https://trac.webkit.org/changeset/224719>, this condition was removed to fix the issue of throwing the cached ImageBuffer needlessly because of moving the image. But removing this condition causes not updating the cached ImageBuffer when it has a sub-rectangle of the image and the new clipping rectangle is not the same as the one the ImageBuffer was cached for.
Attachments
Patch (10.02 KB, patch)
2018-01-24 19:21 PST, Said Abou-Hallawa
no flags
Patch (10.19 KB, patch)
2018-01-24 19:41 PST, Said Abou-Hallawa
no flags
Archive of layout-test-results from ews102 for mac-sierra (2.24 MB, application/zip)
2018-01-24 20:41 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews113 for mac-sierra (2.91 MB, application/zip)
2018-01-24 21:08 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews206 for win-future (12.03 MB, application/zip)
2018-01-24 21:38 PST, EWS Watchlist
no flags
Patch (11.69 KB, patch)
2018-01-25 10:01 PST, Said Abou-Hallawa
no flags
Patch (15.03 KB, patch)
2018-01-25 16:12 PST, Said Abou-Hallawa
no flags
Patch (15.14 KB, patch)
2018-01-25 18:54 PST, Said Abou-Hallawa
no flags
Said Abou-Hallawa
Comment 1 2018-01-24 19:21:25 PST
Said Abou-Hallawa
Comment 2 2018-01-24 19:22:39 PST
Said Abou-Hallawa
Comment 3 2018-01-24 19:41:23 PST
EWS Watchlist
Comment 4 2018-01-24 20:41:24 PST
Comment on attachment 332221 [details] Patch Attachment 332221 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/6203135 New failing tests: fast/images/pdf-as-image-dest-rect-change.html
EWS Watchlist
Comment 5 2018-01-24 20:41:25 PST
Created attachment 332227 [details] Archive of layout-test-results from ews102 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews102 Port: mac-sierra Platform: Mac OS X 10.12.6
EWS Watchlist
Comment 6 2018-01-24 21:08:23 PST
Comment on attachment 332221 [details] Patch Attachment 332221 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/6203319 New failing tests: fast/images/pdf-as-image-dest-rect-change.html
EWS Watchlist
Comment 7 2018-01-24 21:08:24 PST
Created attachment 332229 [details] Archive of layout-test-results from ews113 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews113 Port: mac-sierra Platform: Mac OS X 10.12.6
EWS Watchlist
Comment 8 2018-01-24 21:37:59 PST
Comment on attachment 332221 [details] Patch Attachment 332221 [details] did not pass win-ews (win): Output: http://webkit-queues.webkit.org/results/6203531 New failing tests: fast/images/pdf-as-image-dest-rect-change.html
EWS Watchlist
Comment 9 2018-01-24 21:38:10 PST
Created attachment 332230 [details] Archive of layout-test-results from ews206 for win-future The attached test failures were seen while running run-webkit-tests on the win-ews. Bot: ews206 Port: win-future Platform: CYGWIN_NT-6.1-2.9.0-0.318-5-3-x86_64-64bit
Said Abou-Hallawa
Comment 10 2018-01-25 10:01:01 PST
Simon Fraser (smfr)
Comment 11 2018-01-25 13:04:52 PST
Comment on attachment 332276 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=332276&action=review > Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp:116 > + if (dstRect != m_cachedImageRect && !m_cachedImageRect.contains(context.clipBounds())) Are m_cachedImageRect and context.clipBounds() really in the same coordinate system? > Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp:207 > + // Clipped option is for testing only. Force recaching the PDF with each draw. Maybe re-caching. If the testing-only comment is accurate, the option should have "ForTesting" in the name.
Said Abou-Hallawa
Comment 12 2018-01-25 16:12:50 PST
Said Abou-Hallawa
Comment 13 2018-01-25 16:14:57 PST
Comment on attachment 332276 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=332276&action=review >> Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp:116 >> + if (dstRect != m_cachedImageRect && !m_cachedImageRect.contains(context.clipBounds())) > > Are m_cachedImageRect and context.clipBounds() really in the same coordinate system? Yes m_cachedImageRect and context.clipBounds() are in viewport coordinates. >> Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp:207 >> + // Clipped option is for testing only. Force recaching the PDF with each draw. > > Maybe re-caching. > > If the testing-only comment is accurate, the option should have "ForTesting" in the name. Yes it is for testing only. But PDFImageCachingDisabled is also for testing. Should both be prefixed with "ForTesting"?
Simon Fraser (smfr)
Comment 14 2018-01-25 18:36:22 PST
Comment on attachment 332331 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=332331&action=review > Source/WebCore/ChangeLog:10 > + Revert the change r217236 back and fix the issue of throwing the cached "throwing"? Do you mean throwing out? > Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp:122 > + // movedCachedImageRect has to inlcude the dirty rectangle. inlcude -> include
Said Abou-Hallawa
Comment 15 2018-01-25 18:54:10 PST
WebKit Commit Bot
Comment 16 2018-01-25 19:42:07 PST
The commit-queue encountered the following flaky tests while processing attachment 332343 [details]: http/tests/xmlhttprequest/redirect-cross-origin-tripmine.html bug 179840 (authors: ap@webkit.org and rniwa@webkit.org) The commit-queue is continuing to process your patch.
WebKit Commit Bot
Comment 17 2018-01-25 19:42:46 PST
Comment on attachment 332343 [details] Patch Clearing flags on attachment: 332343 Committed r227651: <https://trac.webkit.org/changeset/227651>
WebKit Commit Bot
Comment 18 2018-01-25 19:42:47 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.