Skip to content

Conversation

@OmarMesqq
Copy link
Contributor

@OmarMesqq OmarMesqq commented Jan 30, 2026

This PR attempts to fix #257 by using a more modern SVG renderer called resvg-js.

The problem

The original renderer used by jsroot is node-canvas which depends on
librsvg on Linux. The issue arises when the user runs npm install to install jsroot as this causes node-canvas
to 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-js was added as a npm dependency of jsroot, hence the changes in package.json and package-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-js and the second node-canvas.
However, the former shall be taken in all cases as the feature flag that mandates whether the module uses resvg-js is hardcoded to true.

Results

Before the change, the test of running demo/node/make_image.js yielded a lego.png without 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_FLAG to false.

I hope this helps!

@OmarMesqq OmarMesqq changed the title Fix problem to create png svg in node.js with 3D plots (issue #257) Fix problem to create png svg in node.js with 3D plots Jan 30, 2026
@OmarMesqq
Copy link
Contributor Author

@linev I am going to take a look at the failing tests on Ubuntu and commit a fix

@OmarMesqq
Copy link
Contributor Author

@linev i pushed 3 commits that apparently make CI pass. requesting feedback please

@linev linev self-assigned this Feb 2, 2026
@linev linev self-requested a review February 2, 2026 12:43
Copy link
Member

@linev linev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 linev merged commit f64c54c into root-project:dev Feb 2, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants