Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Crash when rendering a web page as PDF #12500

Closed
ariya opened this issue Aug 25, 2014 · 8 comments
Closed

Crash when rendering a web page as PDF #12500

ariya opened this issue Aug 25, 2014 · 8 comments
Milestone

Comments

@ariya
Copy link
Owner

ariya commented Aug 25, 2014

This is a regression in master branch.

To reproduce it:

phantomjs examples/rasterize.js http://example.com example.pdf

PhantomJS will crash instead of producing the PDF file. Other formats (PNG, JPEG) don't have the problem.

Test on OS X.

@ariya ariya added this to the Release 2.0 milestone Aug 25, 2014
@ariya
Copy link
Owner Author

ariya commented Aug 25, 2014

An alternative self-contained test script:

var page = require('webpage').create();
page.open("about:blank", function() {
    page.render("test.pdf");
    phantom.exit()
});

ariya added a commit that referenced this issue Aug 25, 2014
Now that the failing tests are isolated (among other, PDF crashing of
#12500), more tests should be
enabled. Going from 270 specs to 316 specs.

#10448
@vitallium
Copy link
Collaborator

Can't confirm on Windows.

@ariya
Copy link
Owner Author

ariya commented Aug 25, 2014

@vitallium Good to know! Hopefully this is not a cross-platform bug.
Let me check on Linux...

@vitallium
Copy link
Collaborator

PhantomJS crashes due to a null pointer here: https://github.com/ariya/phantomjs/blob/master/src/qt/qtbase/src/plugins/printsupport/cocoa/main.cpp#L66
We have implemented our platform plugin, but we didn't implemented createPlatformPrinterSupport method (it's marked as virtual in QPlatformIntegration).
/cc @milianw

@ariya
Copy link
Owner Author

ariya commented Aug 27, 2014

I concur, the stack trace looks like this:

#0  0x000000010109d168 in QCocoaPrinterSupportPlugin::create ()
#1  0x00000001010aa8c8 in QPlatformPrinterSupportPlugin::get ()
#2  0x00000001010a1853 in QPrinterPrivate::initEngines ()
#3  0x00000001010a1ee2 in QPrinter::QPrinter ()
#4  0x00000001000154f8 in WebPage::renderPdf ()
#5  0x0000000100014cdc in WebPage::render ()
#6  0x0000000100064cd8 in WebPage::qt_static_metacall ()
#7  0x0000000100065fef in WebPage::qt_metacall ()
#8  0x00000001000e13ab in JSC::Bindings::QtRuntimeMethod::call ()
#9  0x0000000100d64a72 in JSC::JSCallbackFunction::call ()

@ariya
Copy link
Owner Author

ariya commented Aug 27, 2014

OTOH, there is also a closely related upstream bug:

https://bugreports.qt-project.org/browse/QTBUG-33109.

Particularly interesting is that it seems this is general Qt on OS X QPlatformPrinterSupportPlugin problem in any static build.

@ariya
Copy link
Owner Author

ariya commented Aug 27, 2014

I found a quick workaround. We simply need to implement PhantomIntegration::nativeInterface() that returns a dummy QPlatformNativeInterface instance (for now, it could be useful to extend this in the future). This will prevent QPlatformPrinterSupportPlugin::get() from crashing since it will not bother to load the Cocoa printer plugin (affected by the above upstream bug).

ariya added a commit that referenced this issue Aug 27, 2014
By implementing a dummy platform native interface (for now, it may be
extended in the near future), QPlatformPrinterSupportPlugin will avoid
the path of loading the printer support plugin
(QCocoaPrinterSupportPlugin on OS X).

Related upstream bug (QCocoaPrinterSupportPlugin problem with static build):
https://bugreports.qt-project.org/browse/QTBUG-33109

#12500
@kfix
Copy link

kfix commented Aug 30, 2014

this commit fixed rasterize.js for me on 10.9 via Homebrew install --HEAD. thanks!

@ariya ariya closed this as completed Sep 21, 2014
vitallium pushed a commit to vitallium/qtbase that referenced this issue Oct 10, 2015
By implementing a dummy platform native interface (for now, it may be
extended in the near future), QPlatformPrinterSupportPlugin will avoid
the path of loading the printer support plugin
(QCocoaPrinterSupportPlugin on OS X).

Related upstream bug (QCocoaPrinterSupportPlugin problem with static build):
https://bugreports.qt-project.org/browse/QTBUG-33109

ariya/phantomjs#12500
vitallium pushed a commit to vitallium/qtbase that referenced this issue Dec 12, 2015
See also the following commit in PhantomJS:

commit 7317724723639932f79c211ac40f5ca06f4d9e1a
Author: Ariya Hidayat <ariya.hidayat@gmail.com>
Date:   Tue Aug 26 23:25:01 2014 -0700

Fix consistent crash on OS X when rendering to PDF format.

By implementing a dummy platform native interface (for now, it may be
extended in the near future), QPlatformPrinterSupportPlugin will avoid
the path of loading the printer support plugin
(QCocoaPrinterSupportPlugin on OS X).

Related upstream bug (QCocoaPrinterSupportPlugin problem with static
build): https://bugreports.qt-project.org/browse/QTBUG-33109

ariya/phantomjs#12500
vitallium pushed a commit to vitallium/qtbase that referenced this issue Dec 12, 2015
See also the following commit in PhantomJS:

commit 7317724723639932f79c211ac40f5ca06f4d9e1a
Author: Ariya Hidayat <ariya.hidayat@gmail.com>
Date:   Tue Aug 26 23:25:01 2014 -0700

Fix consistent crash on OS X when rendering to PDF format.

By implementing a dummy platform native interface (for now, it may be
extended in the near future), QPlatformPrinterSupportPlugin will avoid
the path of loading the printer support plugin
(QCocoaPrinterSupportPlugin on OS X).

Related upstream bug (QCocoaPrinterSupportPlugin problem with static
build): https://bugreports.qt-project.org/browse/QTBUG-33109

ariya/phantomjs#12500
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants