Skip to content
This repository has been archived by the owner on Jul 28, 2020. It is now read-only.

not compatible with phantomjs 2.0.0 #11

Open
cupools opened this issue Nov 3, 2015 · 25 comments
Open

not compatible with phantomjs 2.0.0 #11

cupools opened this issue Nov 3, 2015 · 25 comments

Comments

@cupools
Copy link

cupools commented Nov 3, 2015

It performed well with phantomjs 1.9.8, but does not work with phantomjs 2.0.0. It does not throw an exception but the ‘result’ param is undefined. I have check my PATH environment variable and it is ok. Can give some helps? Thank You!
node v4.1.0
windows 10 x64

@twolfson
Copy link
Owner

twolfson commented Nov 3, 2015

It looks like nothing code relevant changed in 2.0.0. However, we have a pretty full queue of other tasks. Please stick to 1.9.8 for now =/

As a side note, is there any reason you aren't using pixelsmith?

@cupools
Copy link
Author

cupools commented Nov 3, 2015

Thanks. I found some problem when use the default engine. The output pictures sometimes have a significant amount of noise. The problem is serious in Windows platform but never appears in OS X.

some example
output
output

var spritesmith = require('spritesmith'),
    fs = require('fs');

// Generate our spritesheet
var sprites = [
    'images/0.png',
    'images/4.png',
    'images/2.png',
    'images/1.png',
    'images/5.png',
    'images/3.png',
];

spritesmith({
    src: sprites,
    padding: 10
}, function handleResult(err, result) {
    fs.writeFileSync(new Date().getTime() + '.png', result.image, 'binary');
});

@twolfson
Copy link
Owner

twolfson commented Nov 3, 2015

Yikes, we should definitely see where that problem originates. However, I'm still heads down for the tonight. I will take a look at triaging it by the end of this weekend.

@cupools
Copy link
Author

cupools commented Nov 3, 2015

Thanks very much :)

@twolfson
Copy link
Owner

twolfson commented Nov 6, 2015

I made a gist to reproduce the image issue but the output image seems to be the same when using the provided input image:

https://gist.github.com/twolfson/825275c84e8005ef4fa2

Input:

input

Output:

output

Can you provide the source images?

@twolfson
Copy link
Owner

twolfson commented Nov 6, 2015

Additionally looked into getting Travis CI set up to test PhantomJS@2.0.0. It seems to be working out of the box =/

https://travis-ci.org/twolfson/phantomjssmith/builds/89591652

Going to see if I can get something set up on my machine (need to build it).

@twolfson
Copy link
Owner

twolfson commented Nov 6, 2015

Ah, going to nope out of that one =/

Building PhantomJS from source takes a very long time, anywhere from 30
minutes to several hours (depending on the machine configuration).
We recommend you use the premade binary packages on supported operating
systems.

For details, please go the the web site: http://phantomjs.org/download.html.

Do you want to continue (y/n)?

@twolfson
Copy link
Owner

twolfson commented Nov 6, 2015

What OS are you using and what version of phantomjssmith are you on (npm ls phantomjssmith)?

@cupools
Copy link
Author

cupools commented Nov 6, 2015

First of all, here is the source images.
https://gist.github.com/cupools/6186ee161d4958cf0b5c

I'm using windows 10 now. The version of phantomjssmith is 0.7.0.

@twolfson
Copy link
Owner

twolfson commented Nov 6, 2015

Hmm, weird. Linux Mint 17.1 is still generating a good output image:

output

@twolfson
Copy link
Owner

twolfson commented Nov 6, 2015

Aaaand Windows 7 has no issues with the output image either:

output

@cupools
Copy link
Author

cupools commented Nov 6, 2015

And I get a good output image in OS X EI Capitan as well, but still bad in windows.

@twolfson
Copy link
Owner

twolfson commented Nov 6, 2015

Alright, going to download a Windows 10 VM via modern.ie / ievms

@cupools
Copy link
Author

cupools commented Nov 6, 2015

I just had a try on windows 7 and another PC with window 10, and both get a good output image. Maybe something get wrong in my PC.

@twolfson
Copy link
Owner

twolfson commented Nov 6, 2015

Ah, cool. Yea, maybe double check the node versions or reinstall the node_modules?

@cupools
Copy link
Author

cupools commented Nov 6, 2015

I have installed node v0.12.7 in windows 10 and now it performances well. So the problem is likely caused by nodev4.1.0 in windows 10. But it is also strange because the node version in OS X is v4.x.x. I will take a look tonight.

@twolfson
Copy link
Owner

twolfson commented Nov 6, 2015

If you isolate the issue and it's in pixelsmith, then please let me know =)

@twolfson
Copy link
Owner

twolfson commented Nov 6, 2015

On another note, I have reproduced the issue with PhantomJS@2.0.0 support on Windows. It's related to us using page.open to force a synchronous image load.

@cupools
Copy link
Author

cupools commented Nov 6, 2015

I will remember that :)

And another idea, can phantomjssmith support phantomjs in npm?
I have try to modify some codes in phantomjssmith to avoid installing phantomjs and adding environment PATH.

like this:
https://github.com/twolfson/phantomjssmith/blob/master/lib/image.js#L26

// change to
bufferedSpawn(require('phantomjs').path, [path.join(__dirname, 'scripts', 'stats.js'), filepath],

@twolfson
Copy link
Owner

twolfson commented Nov 6, 2015

Please see notes on #4 and #9 for that

#4

#9

@cupools
Copy link
Author

cupools commented Nov 6, 2015

Thanks :)

@twolfson
Copy link
Owner

twolfson commented Nov 6, 2015

Alright, it seems to be a deeper security issue that is unresolved in PhantomJS@2.0.0. The short of it is: we are using file:// locally access files however PhantomJS@2.0.0 isn't allowing it and resolving to about:blank.

ariya/phantomjs#13681

We could work around it by starting a server but that feels like major overkill for now. Going to leave this issue as open.

Hackish work can be found here:

twolfson:a152845...twolfson:ef68adc

@cupools
Copy link
Author

cupools commented Nov 7, 2015

Nice Job.
And I just install node v4.1.0 in OS X EI Captain and the output image is bad, but everything is well in node v4.1.1.

@cupools
Copy link
Author

cupools commented Nov 7, 2015

So does something wrong with node v4.1.0?

@twolfson
Copy link
Owner

twolfson commented Nov 7, 2015

Ah, yea. It looks like we were running into the Buffer issue -- we use an empty buffer for the basic canvas where we draw images:

https://github.com/nodejs/node/blob/v4.1.1/CHANGELOG.md#2015-09-22-version-411-stable-rvagg

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

2 participants