I have been running PhantomJS 1.9.6 happily on a turnkey Linux server for about 4 months now. Its purpose is to take an SVG file and create different sizes using the page.render function.
This has been doing this but since a few days ago has started to generate a black mono output.
Please see below:
The code:
var page = require('webpage').create(), system = require('system'), address, output, ext, width, height;
if ( system.args.length !== 4 ) {
console.log("{ \"result\": false, \"message\": \"phantomjs.rasterize: error need address, output, extension arguments\" }");
//console.log('phantomjs.rasterize: error need address, output, extension arguments');
phantom.exit(1);
}
else if( system.args[3] !== "jpg" && system.args[3] !== "png"){
console.log("{ \"result\": false, \"message\": \"phantomjs.rasterize: error \"jpg\" or \"png\" only please\" }");
//console.log('phantomjs.rasterize: error "jpg" or "png" only please');
phantom.exit(1);
}
else {
address = system.args[1];
output = system.args[2];
ext = system.args[3];
width = 1044;
height = 738;
page.viewportSize = { width: width, height: height }; //postcard size
page.open(address, function (status) {
if (status !== 'success') {
console.log("{ \"result\": false, \"message\": \"phantomjs.rasterize: error loading address ["+address+"]\" }");
//console.log('phantomjs.rasterize: error loading address ['+address+'] ');
phantom.exit();
} else {
window.setTimeout(function () {
//--> redner full size postcard
page.render( output + "." + ext );
//--> redner smaller postcard
page.zoomFactor = 0.5;
page.clipRect = {top:0, left:0, width:width*0.5, height:height*0.5};
page.render( output + ".50." + ext);
//--> redner postcard thumb
page.zoomFactor = 0.25;
page.clipRect = {top:0, left:0, width:width*0.25, height:height*0.25};
page.render( output + ".25." + ext);
//--> exit
console.log("{ \"result\": true, \"message\": \"phantomjs.rasterize: success ["+address+"]>>["+output+"."+ext+"]\" }");
//console.log('phantomjs.rasterize: success ['+address+']>>['+output+'.'+ext+']');
phantom.exit();
}, 100);
}
});
}
Does anyone know what can be causing this? There have been no server configuration changes that I know of.
Many thanks for your help.
UPDATE:
It appears the problem is not with PhantomJS but with an update made to the Google Chrome browser on the 20th May (http://googlechromereleases.blogspot.co.uk/2014/05/stable-channel-update_20.html). This effectively changed the way SVG files are built and obviously a change has been made that stops PhantomJS reading the SVG correctly.
The application we have runs correctly on Safari so as expected my first thought about the code not being the issue was correct.
I have logged a forum post in Google Groups (https://groups.google.com/forum/#!topic/google-chrome-techhelp/Y99OXOtikXI) to try and get some help on this, whether it be to roll back the Chrome browser or to provide a flag that enables me to turn off this breaking feature.
FURTHER UPDATE:
This is an issue with an update made to the Google Chrome browser. I have logged a bug report at the address below so hopefully it can be rectified as soon as possible. Thank you for all your help.