Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UnifiedPDF] When an incremental PDF completes its load, blank pages are still visible #28318

Conversation

smfr
Copy link
Contributor

@smfr smfr commented May 9, 2024

7208a15

[UnifiedPDF] When an incremental PDF completes its load, blank pages are still visible
https://bugs.webkit.org/show_bug.cgi?id=273917
rdar://127713604

Reviewed by Tim Horton.

While loading an incremental PDF (potentially over a slow network connection), nothing
currently triggers repaints, so we never show pages as they load, nor do we repaint all
the pages when the load completes. This can leave you with blank pages until you scroll
or zoom.

Fix by hooking up some virtual functions on the plugin to give UnifiedPDFPlugin a way
to know when incremental loads progress, finish or cancel. While progressing, fire
a repeating timer every 1s to trigger repaints (we currently can't know which pages
become valid based on data ranges). Also trigger a repaint when the load completes.
This repaints use the coverage rect to only invalidate visible pages.

* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h:
(WebKit::PDFPluginBase::incrementalLoadingDidProgress):
(WebKit::PDFPluginBase::incrementalLoadingDidCancel):
(WebKit::PDFPluginBase::incrementalLoadingDidFinish):
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm:
(WebKit::PDFPluginBase::streamDidReceiveData):
(WebKit::PDFPluginBase::streamDidFinishLoading):
(WebKit::PDFPluginBase::streamDidFail):
(WebKit::PDFPluginBase::receivedNonLinearizedPDFSentinel):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/AsyncPDFRenderer.mm:
(WebKit::AsyncPDFRenderer::coverageRectDidChange):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.mm:
(WebKit::PDFDocumentLayout::contentsSize const):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::installPDFDocument):
(WebKit::UnifiedPDFPlugin::incrementalLoadingDidProgress):
(WebKit::UnifiedPDFPlugin::incrementalLoadingDidCancel):
(WebKit::UnifiedPDFPlugin::incrementalLoadingDidFinish):
(WebKit::UnifiedPDFPlugin::updatePageBackgroundLayers):
(WebKit::UnifiedPDFPlugin::incrementalLoadingRepaintTimerFired):
(WebKit::UnifiedPDFPlugin::repaintForIncrementalLoad):
(WebKit::UnifiedPDFPlugin::paintContents):

Canonical link: https://commits.webkit.org/278597@main

d648943

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug   πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ api-wpe
  πŸ§ͺ ios-wk2-wpt βœ… πŸ›  wpe-skia
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ›  gtk
βœ… πŸ›  tv   πŸ§ͺ mac-AS-debug-wk2 ⏳ πŸ§ͺ gtk-wk2
βœ… πŸ›  tv-sim βœ… πŸ§ͺ mac-wk2-stress ⏳ πŸ§ͺ api-gtk
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch
βœ… πŸ›  watch-sim

@smfr smfr requested a review from cdumez as a code owner May 9, 2024 02:18
@smfr smfr self-assigned this May 9, 2024
@smfr smfr added the PDF For bugs in WebKit's built-in PDF support. label May 9, 2024
@smfr smfr added merge-queue Applied to send a pull request to merge-queue and removed merge-queue Applied to send a pull request to merge-queue labels May 9, 2024
@smfr smfr force-pushed the eng/UnifiedPDF-When-an-incremental-PDF-completes-its-load-blank-pages-are-still-visible branch from 717b2af to 41b1367 Compare May 9, 2024 22:25
@smfr smfr force-pushed the eng/UnifiedPDF-When-an-incremental-PDF-completes-its-load-blank-pages-are-still-visible branch from 41b1367 to d648943 Compare May 9, 2024 22:31
@smfr smfr added the merge-queue Applied to send a pull request to merge-queue label May 10, 2024
…are still visible

https://bugs.webkit.org/show_bug.cgi?id=273917
rdar://127713604

Reviewed by Tim Horton.

While loading an incremental PDF (potentially over a slow network connection), nothing
currently triggers repaints, so we never show pages as they load, nor do we repaint all
the pages when the load completes. This can leave you with blank pages until you scroll
or zoom.

Fix by hooking up some virtual functions on the plugin to give UnifiedPDFPlugin a way
to know when incremental loads progress, finish or cancel. While progressing, fire
a repeating timer every 1s to trigger repaints (we currently can't know which pages
become valid based on data ranges). Also trigger a repaint when the load completes.
This repaints use the coverage rect to only invalidate visible pages.

* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h:
(WebKit::PDFPluginBase::incrementalLoadingDidProgress):
(WebKit::PDFPluginBase::incrementalLoadingDidCancel):
(WebKit::PDFPluginBase::incrementalLoadingDidFinish):
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm:
(WebKit::PDFPluginBase::streamDidReceiveData):
(WebKit::PDFPluginBase::streamDidFinishLoading):
(WebKit::PDFPluginBase::streamDidFail):
(WebKit::PDFPluginBase::receivedNonLinearizedPDFSentinel):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/AsyncPDFRenderer.mm:
(WebKit::AsyncPDFRenderer::coverageRectDidChange):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.mm:
(WebKit::PDFDocumentLayout::contentsSize const):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::installPDFDocument):
(WebKit::UnifiedPDFPlugin::incrementalLoadingDidProgress):
(WebKit::UnifiedPDFPlugin::incrementalLoadingDidCancel):
(WebKit::UnifiedPDFPlugin::incrementalLoadingDidFinish):
(WebKit::UnifiedPDFPlugin::updatePageBackgroundLayers):
(WebKit::UnifiedPDFPlugin::incrementalLoadingRepaintTimerFired):
(WebKit::UnifiedPDFPlugin::repaintForIncrementalLoad):
(WebKit::UnifiedPDFPlugin::paintContents):

Canonical link: https://commits.webkit.org/278597@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/UnifiedPDF-When-an-incremental-PDF-completes-its-load-blank-pages-are-still-visible branch from d648943 to 7208a15 Compare May 10, 2024 00:56
@webkit-commit-queue
Copy link
Collaborator

Committed 278597@main (7208a15): https://commits.webkit.org/278597@main

Reviewed commits have been landed. Closing PR #28318 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 7208a15 into WebKit:main May 10, 2024
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PDF For bugs in WebKit's built-in PDF support.
Projects
None yet
4 participants