Closed espadrine closed 10 years ago
Note: phantomjs doesn't support stdin, so we can either:
/dev/stdin
and fallback to launching the phantomjs process every time on OSes without that file.It's a bit of a Scylla and Charybdis situation, however choice 2 seems the most reasonable.
The reason for PhantomJS is to maintain consistency between SVG/PNG.
Listening to the end of the Conversation on Tuesday, and I'm still not crazy about using PhantomJS in-process to convert SVG to PNG.
Though I haven't done any profiling to back up my concern, I suspect it will use quite a bit of memory. Once we're production-ready and serving every badge on the Internet, how many GB of memory our our servers going to need?
Also, lets have a discussion about what level of consistency between SVG & PNG we require: https://github.com/badges/shields/issues/102#issuecomment-32046201
Though I haven't done any profiling to back up my concern, I suspect it will use quite a bit of memory.
Just measured it, about 35MB, 14 of which is shared.
That said, the phantomjs instance isn't run if the image is in the cache.
@nathany I don't know what you mean when you ask whether we can make phantomjs an offline conversion for a blank template badge without needing a browser engine. We can't run phantomjs without the engine inside of it.
Not too bad.
Especially if we are serving badges indirectly (and eg. Travis CI caches the handful of variations) it's probably not as big of a deal as I thought.
Travis CI would presumably occupy position 1, 2 and 3 of the cache, so phantomjs isn't an issue at all. What would fill the cache are npm versions, for instance.
I think I have understood what you meant: ask phantomjs to provide a generic bitmap output on top of which we place the color and text? Unfortunately I don't see how that can happen.
We can search for an alternative if phantomjs is too big, maybe inkscape or imagemagick. It is probably not fun to install on Heroku.
Closing this, as Phantom.js is not the bottleneck.
While SVG is simply a function call to generate, another to SVGO compress, and a last one to gzip, PNG follows all of those steps, loads phantomjs, converts the font to base64, includes it in the SVG, resizes the phantomjs window, takes a snapshot, converts it to PNG, and sends that.
I believe we can: