Closed
Bug 1310165
Opened 8 years ago
Closed 8 years ago
mozPrintCallback stopped producing vector output when printing via the parent on OS X
Categories
(Core :: Printing: Output, defect, P3)
Tracking
()
RESOLVED
FIXED
mozilla53
Tracking | Status | |
---|---|---|
firefox49 | --- | unaffected |
firefox50 | --- | unaffected |
firefox51 | --- | unaffected |
firefox52 | --- | fixed |
firefox53 | --- | fixed |
People
(Reporter: bobowen, Assigned: jwatt)
References
Details
(Keywords: regression, Whiteboard: [pdfjs-d-printing])
Attachments
(5 files, 1 obsolete file)
23.13 KB,
text/html
|
Details | |
72.09 KB,
image/png
|
Details | |
3.24 KB,
patch
|
Details | Diff | Splinter Review | |
275.83 KB,
image/png
|
Details | |
2.63 KB,
patch
|
mstange
:
review+
jcristau
:
approval-mozilla-aurora+
|
Details | Diff | Splinter Review |
We have a fix for bug 1308259 for non-e10s and e10s without printing via the parent, but there still seems to be a problem for printing via the parent.
It could be to do with the setting up of the dummy off screen surface for recording.
That might be the issue in bug 1301765 as well.
I wonder if we ought to turn off printing via the parent in Fx51 as we only need it for sandboxing.
Original details below.
+++ This bug was initially created as a clone of Bug #1308259 +++
After bug 1258609, the PDF viewer stopped producing high quality output during printing. STR:
1. Open the attached test case
2. Print it to a PDF file
3. Inspect PDF output
Actual result:
The "Test" text at "... loading print" sections is rasterized
Expected result:
The "Test" text at "... loading print" sections must be vectorized and selectable.
As result any document printed by PDF Viewer with low quality.
Flags: needinfo?(haftandilian)
Reporter | ||
Updated•8 years ago
|
Reporter | ||
Updated•8 years ago
|
Updated•8 years ago
|
Flags: needinfo?(tschneider)
Comment 1•8 years ago
|
||
(In reply to Bob Owen (:bobowen) from comment #0)
> I wonder if we ought to turn off printing via the parent in Fx51 as we only
> need it for sandboxing.
That might be a good idea until we resolve this, but I'd like to understand the severity of the problem better first. Leaving needinfo for now.
Safari and Chrome both fail to generate the PDF correctly (or rather fail to print it like we do, either with or without the fix for 1308259) omitting the "Test" text entirely.
Comment 2•8 years ago
|
||
(In reply to Haik Aftandilian [:haik] from comment #1)
> Safari and Chrome both fail to generate the PDF correctly (or rather fail to
> print it like we do, either with or without the fix for 1308259) omitting
> the "Test" text entirely.
mozPrintCallback is implemented only on Firefox (and was created to replace rasterized canvas output vs vector, current user is PDF.js)
Comment 3•8 years ago
|
||
Is it a regression of bug 1258609 since FF51 ? I can see the rasterized output on FF50 beta as well.
Updated•8 years ago
|
Priority: -- → P3
Reporter | ||
Comment 4•8 years ago
|
||
(In reply to Astley Chen [:astley] (UTC+8) from comment #3)
> Is it a regression of bug 1258609 since FF51 ? I can see the rasterized
> output on FF50 beta as well.
There was a similar problem caused by bug 1258609, but a fix for that is on inbound from bug 1308259 (I'll request uplift once it has been merged).
I filed this as a separate issue because turning on printing via the parent causes the same problem, even with that fix.
Updated•8 years ago
|
status-firefox49:
--- → unaffected
status-firefox50:
--- → unaffected
Comment 5•8 years ago
|
||
(In reply to Bob Owen (:bobowen) from comment #4)
> (In reply to Astley Chen [:astley] (UTC+8) from comment #3)
> > Is it a regression of bug 1258609 since FF51 ? I can see the rasterized
> > output on FF50 beta as well.
> I filed this as a separate issue because turning on printing via the parent
> causes the same problem, even with that fix.
Got it. Thanks for prompt feedback.
Comment 6•8 years ago
|
||
[Tracking Requested - why for this release]: `print.print_via_parent` had been flipped on on macOS since FF51. The issue would be seen on macOS after merging FF51 to beta.
[1] http://searchfox.org/mozilla-central/source/modules/libpref/init/all.js#1116
tracking-firefox51:
--- → ?
Comment 7•8 years ago
|
||
I filed bug 1310804 (Limit Mac remote printing to Nightly) to workaround this problem. It will have to be uplifted to build 51. We'll still need to resolve this bug so that vector output works properly with remote printing which is still enabled on Nightly. I'll take this bug.
Flags: needinfo?(haftandilian)
Updated•8 years ago
|
Assignee: nobody → haftandilian
Comment 9•8 years ago
|
||
Cancelling the tracking-firefox51 request because bug 1310804 "Limit Mac remote printing to Nightly" prevents this problem on releases other than Nightly and will go into 51. This bug will still be a problem in Nightly where Mac remote printing is enabled.
tracking-firefox51:
+ → ---
See Also: → 1310804
Comment 10•8 years ago
|
||
Based on bug 1310804, the regression is limited to nightly only. Update status flag to reflect current result.
Updated•8 years ago
|
Summary: mozPrintCallback stopped producing vector output when printing via the parent. → mozPrintCallback stopped producing vector output when printing via the parent on OS X
Comment 11•8 years ago
|
||
Tracy, please figure out how to reproduce this rasterized print to pdf bug and post some screen shots of the difference.
Flags: needinfo?(twalker)
Comment 12•8 years ago
|
||
Saved to PDF from Release 49.0.2 is on the left. Saved to PDF from Nightly is on the right. In neither case is the test text selectable as demonstrated by the selection spanning across the Test text. But there is a difference in font of the Test text.
Flags: needinfo?(twalker)
Updated•8 years ago
|
Flags: needinfo?(tschneider)
Assignee | ||
Comment 13•8 years ago
|
||
Taking, as discussed with Haik or IRC.
Assignee: haftandilian → jwatt
Assignee | ||
Comment 14•8 years ago
|
||
Here's my analysis of what's going wrong:
Early on during printing we end up under this call stack on the parent process:
PrintTargetCG::CreateOrNull
nsDeviceContextSpecX::MakePrintTarget
nsDeviceContext::InitForPrinting
RemotePrintJobParent::InitializePrintDevice
RemotePrintJobParent::RecvInitializePrint
PRemotePrintJobParent::OnMessageReceived
In nsDeviceContextSpecX::MakePrintTarget the ::PMSessionGetCGGraphicsContext() call fails (because we haven't called ::PMSessionBeginPage() yet, and PMSessionGetCGGraphicsContext will only succeed between PMSessionBeginPage/PMSessionEndPage calls). As a result nsDeviceContextSpecX::MakePrintTarget call PrintTargetCG::CreateOrNull(size, SurfaceFormat::A8R8G8B8_UINT32) which creates a PrintTargetCG that wrapps a raster backed CGContext. This is the PrintTarget that is stored in nsDeviceContext->mPrintTarget for now.
Shortly after this, we create our PrintTranslator under the stack:
PrintTarget::GetReferenceDrawTarget
nsDeviceContext::CreateRenderingContextCommon
nsDeviceContext::CreateReferenceRenderingContext
PrintTranslator::PrintTranslator
RemotePrintJobParent::RecvInitializePrint
PRemotePrintJobParent::OnMessageReceived
PrintTarget::GetReferenceDrawTarget creates a similar cairo_surface_t to the one that it wraps, so it too wraps a raster backed CGContext. This DrawTarget is stored by PrintTranslator's constructor in its mBaseDT.
Shortly after that we end up under nsDeviceContext::BeginPage:
mozilla::gfx::PrintTargetCG::CreateOrNull
nsDeviceContextSpecX::MakePrintTarget <- PMSessionGetCGGraphicsContext works
nsDeviceContext::BeginPage
mozilla::layout::RemotePrintJobParent::PrintPage
mozilla::layout::RemotePrintJobParent::RecvProcessPage
It calls nsDeviceContextSpecX::MakePrintTarget to replace nsDeviceContext->mPrintTarget now that calling ::PMSessionGetCGGraphicsContext() will succeed and provide a vector backed CGContext. Unfortunately we have no mechanism to replace PrintTranslator->mBaseDT.
When we later end up under stacks like:
RecordedCreateSimilarDrawTarget::PlayEvent
PrintTranslator::TranslateRecording
RemotePrintJobParent::PrintPage
RemotePrintJobParent::RecvProcessPage
PRemotePrintJobParent::OnMessageReceived
we end up calling things like aTranslator->GetReferenceDrawTarget()->CreateSimilarDrawTarget(mSize, mFormat) and the aTranslator->GetReferenceDrawTarget() call returns aTranslator->mBaseDT. Since that still wraps a raster backed CGContext, we end up creating another raster backed CGContext, and hence why we can fail to vectorize things.
Assignee | ||
Comment 15•8 years ago
|
||
I think ideally the way to fix this would be to give RecordedCreateSimilarDrawTarget::PlayEvent access to the DrawTarget on the parent process side that corresponds to the DrawTarget that CreateSimilarDrawTarget was called on on the content process side. Unfortunately this attempt to do that fails because the LookupDrawTarget(mBaseDT) call fails to find that DrawTarget. I'm not familiar enough with the fine details of the record and replay Moz2D stuff to understand why.
Assignee | ||
Comment 16•8 years ago
|
||
This is another way to fix the issue by making sure that when GetReferenceDrawTarget is called on a PrintTargetCG we always return a PDF CGContext backed DrawTarget. This appears to work, but needs a little cleaning up.
Comment 17•8 years ago
|
||
(In reply to Jonathan Watt [:jwatt] from comment #16)
> Created attachment 8810895 [details] [diff] [review]
> patch - Add a GetReferenceDrawTarget overload to PrintTargetCG to return a
> PDF CGContext backed DrawTarget
>
> This is another way to fix the issue by making sure that when
> GetReferenceDrawTarget is called on a PrintTargetCG we always return a PDF
> CGContext backed DrawTarget. This appears to work, but needs a little
> cleaning up.
This works for me. See attached screenshot. The text added for printing was vector and selectable.
Comment 18•8 years ago
|
||
Updated•8 years ago
|
status-firefox53:
--- → affected
Assignee | ||
Comment 19•8 years ago
|
||
Assignee | ||
Updated•8 years ago
|
Attachment #8813348 -
Attachment is patch: true
Attachment #8813348 -
Flags: review?(mstange)
Assignee | ||
Updated•8 years ago
|
Attachment #8810895 -
Attachment is obsolete: true
Comment 20•8 years ago
|
||
Comment on attachment 8813348 [details] [diff] [review]
patch - add a GetReferenceDrawTarget overload to PrintTargetCG to return a PDF CGContext backed DrawTarget
Review of attachment 8813348 [details] [diff] [review]:
-----------------------------------------------------------------
::: gfx/thebes/PrintTargetCG.cpp
@@ +72,5 @@
> +{
> + if (!mRefDT) {
> + const IntSize size(1, 1);
> +
> + CGRect pageRect;
could just make this
CGRect pageRect = { {0, 0}, {size.width, size.height} };
@@ +82,5 @@
> + CFMutableDataRef mutableData = CFDataCreateMutable(NULL, 0);
> + CGDataConsumerRef dataConsumer = CGDataConsumerCreateWithCFData(mutableData);
> + CFRelease(mutableData);
> + CGContextRef pdfContext = CGPDFContextCreate(dataConsumer, &pageRect, NULL);
> + CGDataConsumerRelease(dataConsumer);
Here's code that does something similar:
http://searchfox.org/mozilla-central/source/gfx/2d/PathCG.cpp#338-353
Not sure what's preferable. Either is fine probably.
Attachment #8813348 -
Flags: review?(mstange) → review+
Comment 21•8 years ago
|
||
Pushed by jwatt@jwatt.org:
https://hg.mozilla.org/integration/mozilla-inbound/rev/9a01c1474537
Add a GetReferenceDrawTarget overload to PrintTargetCG to return a PDF CGContext backed DrawTarget. r=mstange
Comment 22•8 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
Assignee | ||
Comment 23•8 years ago
|
||
Comment on attachment 8813348 [details] [diff] [review]
patch - add a GetReferenceDrawTarget overload to PrintTargetCG to return a PDF CGContext backed DrawTarget
Requesting approval to uplift to v52 in order to get the initial content process sandboxing turned on.
Approval Request Comment
[Feature/regressing bug #]: bug 1314056
[User impact if declined]: less security
[Describe test coverage new/current, TreeHerder]: now merged to m-c
[Risks and why]: low risk
[String/UUID change made/needed]: none
Attachment #8813348 -
Flags: approval-mozilla-aurora?
Comment 24•8 years ago
|
||
Comment on attachment 8813348 [details] [diff] [review]
patch - add a GetReferenceDrawTarget overload to PrintTargetCG to return a PDF CGContext backed DrawTarget
fix printing issue on osx with sandboxing, take in aurora52
Attachment #8813348 -
Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Comment 25•8 years ago
|
||
bugherder uplift |
You need to log in
before you can comment on or make changes to this bug.
Description
•