WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
151386
WKWebView does not render PDF pages in AirPrint
https://bugs.webkit.org/show_bug.cgi?id=151386
Summary
WKWebView does not render PDF pages in AirPrint
stkhapugin
Reported
2015-11-18 05:23:07 PST
Created
attachment 265744
[details]
Reproduction case. Summary: When one attempts to AirPrint a PDF open in WKWebView using [WKWebView viewPrintFormatter], the previews and the printed output are blank. Note that Safari on iOS prints normally. This is reproducible both with iOS 9.1 SDK's WebKit and a nightly checkout. Is there a workaround Safari uses? Steps to Reproduce: Unzip attached project, build & run. A pdf document will be loaded, and once it's loaded, the print dialog will open. Note that the repro is linked with iOS SDK's WebKit. You may want to relink it to your own WebKit.framework. Expected Results: Preview in print dialog shows a small PDF preview. PDF prints normally. Actual Results: Previews in print dialog shows a blank page. Printed page is blank. Version: iOS 9.1; tot. Notes: You can debug printing by downloading Hardware IO Tools for Xcode 7 on Apple Developer Portal and running an AirPrint simulator. Also filed
rdar://23556241
.
Attachments
Reproduction case.
(52.02 KB, application/zip)
2015-11-18 05:23 PST
,
stkhapugin
no flags
Details
Patch
(40.47 KB, patch)
2016-06-09 13:04 PDT
,
Andy Estes
no flags
Details
Formatted Diff
Diff
Patch
(40.46 KB, patch)
2016-06-09 13:22 PDT
,
Andy Estes
no flags
Details
Formatted Diff
Diff
Patch
(40.52 KB, patch)
2016-06-09 14:33 PDT
,
Andy Estes
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Andy Estes
Comment 1
2015-11-18 19:55:16 PST
One workaround is to set UIPrintInteractionController's printingItem to an NSData containing the PDF. Unfortunately this probably requires you to load the PDF a second time.
Eugene But
Comment 2
2015-11-18 20:15:58 PST
Thank you for providing a workaround. Downloading PDF may not always work, because WKWebView does not provide reliable API to get cookie (NSHTTPCookieStorage is not always up to date). However being broken only in cases when auth is required is better than being always broken. Please let us know if you see any alternative workarounds. Thanks!
Andy Estes
Comment 3
2016-01-22 15:18:12 PST
rdar://problem/22499157
Andy Estes
Comment 4
2016-01-23 01:18:47 PST
The issue here is that _WKWebViewPrintFormatter's _totalScaleFactor is 0 for PDFs. Setting it to 1 instead fixes the attached test case. We probably need to compute a per-page scale factor for PDFs.
Andy Estes
Comment 5
2016-06-09 13:04:34 PDT
Created
attachment 280935
[details]
Patch
WebKit Commit Bot
Comment 6
2016-06-09 13:06:02 PDT
Attachment 280935
[details]
did not pass style-queue: ERROR: Source/WebKit2/UIProcess/ios/WKContentView.mm:632: The parameter name "handle" adds no information, so it should be removed. [readability/parameter_name] [5] Total errors found: 1 in 17 files If any of these errors are false positives, please file a bug against check-webkit-style.
Tim Horton
Comment 7
2016-06-09 13:14:48 PDT
Comment on
attachment 280935
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=280935&action=review
> Source/WebKit2/UIProcess/WebPageProxy.h:260 > +using DrawToPDFCallback = GenericCallback<const IPC::DataReference&>;
Interesting! Why using instead of typedef like the others? Should we change the others?
> Source/WebKit2/UIProcess/WebPageProxy.h:910 > + uint32_t computePagesForPrintingAndDrawToPDF(uint64_t frameID, const PrintInfo&, DrawToPDFCallback::CallbackFunction&&);
indentation is weird.
Andy Estes
Comment 8
2016-06-09 13:18:34 PDT
(In reply to
comment #7
)
> Comment on
attachment 280935
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=280935&action=review
> > > Source/WebKit2/UIProcess/WebPageProxy.h:260 > > +using DrawToPDFCallback = GenericCallback<const IPC::DataReference&>; > > Interesting! Why using instead of typedef like the others? Should we change > the others?
using doesn't make me think about which order things go in like typedef does, and it's more C++11y, but I don't know if we should change the others!
> > > Source/WebKit2/UIProcess/WebPageProxy.h:910 > > + uint32_t computePagesForPrintingAndDrawToPDF(uint64_t frameID, const PrintInfo&, DrawToPDFCallback::CallbackFunction&&); > > indentation is weird.
Oops. Will fix. Thank you for the review!
Andy Estes
Comment 9
2016-06-09 13:22:16 PDT
Created
attachment 280939
[details]
Patch
WebKit Commit Bot
Comment 10
2016-06-09 13:24:59 PDT
Attachment 280939
[details]
did not pass style-queue: ERROR: Source/WebKit2/UIProcess/ios/WKContentView.mm:632: The parameter name "handle" adds no information, so it should be removed. [readability/parameter_name] [5] Total errors found: 1 in 17 files If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Commit Bot
Comment 11
2016-06-09 13:45:30 PDT
Comment on
attachment 280939
[details]
Patch Rejecting
attachment 280939
[details]
from commit-queue. Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-02', 'build', '--no-clean', '--no-update', '--build-style=release', '--port=mac']" exit_code: 2 cwd: /Volumes/Data/EWS/WebKit Last 500 characters of output: CompileC /Volumes/Data/EWS/WebKit/WebKitBuild/WebKit2.build/Release/WebKit.build/Objects-normal/x86_64/_WKWebViewPrintFormatter.o UIProcess/_WKWebViewPrintFormatter.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (1 failure) Failed to run "['Tools/Scripts/build-webkit', '--release']" exit_code: 65 d/Objects-normal/x86_64/_WKWebViewPrintFormatter.o UIProcess/_WKWebViewPrintFormatter.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (1 failure) Full output:
http://webkit-queues.webkit.org/results/1474107
Andy Estes
Comment 12
2016-06-09 14:33:02 PDT
Created
attachment 280951
[details]
Patch
WebKit Commit Bot
Comment 13
2016-06-09 14:43:23 PDT
Attachment 280951
[details]
did not pass style-queue: ERROR: Source/WebKit2/UIProcess/ios/WKContentView.mm:632: The parameter name "handle" adds no information, so it should be removed. [readability/parameter_name] [5] Total errors found: 1 in 17 files If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Commit Bot
Comment 14
2016-06-09 15:03:34 PDT
Comment on
attachment 280951
[details]
Patch Clearing flags on attachment: 280951 Committed
r201888
: <
http://trac.webkit.org/changeset/201888
>
WebKit Commit Bot
Comment 15
2016-06-09 15:03:39 PDT
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.
Top of Page
Format For Printing
XML
Clone This Bug