Fix problem to create png svg in node.js with 3D plots#391
Conversation
|
@linev I am going to take a look at the failing tests on Ubuntu and commit a fix |
this returns the raw RGBA pixels made by `resvg-js`
|
@linev i pushed 3 commits that apparently make CI pass. requesting feedback please |
linev
left a comment
There was a problem hiding this comment.
I merging you changes into dev branch.
Seems to be several small adjustments need to be done, but this is cosmetics.
Thanks for looking into the problem and providing solution for it!
@linev |
There are no really urgent issues. |
This PR attempts to fix #257 by using a more modern SVG renderer called resvg-js.
The problem
The original renderer used by
jsrootisnode-canvaswhich depends onlibrsvgon Linux. The issue arises when the user runsnpm installto installjsrootas this causesnode-canvasto fetch and link its binary to an outdated (and broken) version of
librsvg.This causes SVG to PNG conversion to be buggy often rendering empty plots. See the full discussion.
The solution
resvg-jswas added as anpmdependency ofjsroot, hence the changes inpackage.jsonandpackage-lock.json.In order leverage it, a refactoring had to be made in
jsroot's painting base module (BasePainter.mjs).Now, the code has two branches for converting SVGs to PNGs: the first one uses
resvg-jsand the secondnode-canvas.However, the former shall be taken in all cases as the feature flag that mandates whether the module uses
resvg-jsis hardcoded totrue.Results
Before the change, the test of running
demo/node/make_image.jsyielded alego.pngwithout the 3D plot.Now, it correctly generates it. Further tests should be made to assure this change is safe. In any case, it can be readily turned off by setting
RESVG_FEATURE_FLAGtofalse.I hope this helps!