Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch SVG loading from the Batik library to JSVG #7941

Merged
merged 1 commit into from
Nov 16, 2024

Conversation

eirikbakke
Copy link
Contributor

Per our discussion in #7463 (comment) and #7938 , here is a PR that switches SVG loading routine in ImageUtilities from the Batik library to the much more lightweight JSVG library.

It's a draft that needs more testing, so I have added the do-not-merge label for now. But I'm leaving the work here since it might benefit #7938.

@eirikbakke eirikbakke added do not merge Don't merge this PR, it is not ready or just demonstration purposes. Platform [ci] enable platform tests (platform/*) UI User Interface labels Nov 7, 2024
@eirikbakke eirikbakke mentioned this pull request Nov 7, 2024
@matthiasblaesing
Copy link
Contributor

For testing the rendering you render render all svgs both with batik and jsvg and diff the two.

@eirikbakke
Copy link
Contributor Author

There's a lot of bugs that can happen in the full application context, rather than in an isolated script, so I prefer to test the full app. (Dimensions, hints, HiDPI scaling, ImageProducer/ImageObserver/ColorModel stuff, caching etc.)

@matthiasblaesing
Copy link
Contributor

There's a lot of bugs that can happen in the full application context, rather than in an isolated script, so I prefer to test the full app. (Dimensions, hints, HiDPI scaling, ImageProducer/ImageObserver/ColorModel stuff, caching etc.)

Sure, it was an idea and could catch the most obvious problem.

@eirikbakke eirikbakke force-pushed the pr-jsvg branch 5 times, most recently from 8110b4c to 0fa8094 Compare November 7, 2024 21:43
@mbien mbien added the ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) label Nov 7, 2024
@eirikbakke eirikbakke force-pushed the pr-jsvg branch 2 times, most recently from d510758 to 136a6a9 Compare November 8, 2024 00:04
@eirikbakke
Copy link
Contributor Author

Sorry for all the force-pushes... I was fidgeting to get the "paperwork" test to pass.

@mbien
Copy link
Member

mbien commented Nov 9, 2024

Sorry for all the force-pushes... I was fidgeting to get the "paperwork" test to pass.

no worries, thats what CI is for.

same comparison as in #7463 (comment)

svg-icons_impl_comparison

batik is on the left, jsvg on the right (I think). I can't tell the difference - so its either not working or it works perfectly ;)

@matthiasblaesing
Copy link
Contributor

First impression is good. I rebuild my "work" NetBeans with this applied and did not notice a difference.

@eirikbakke
Copy link
Contributor Author

Yes, looks rather identical. Just to verify that the JSVG library is actually being used, I inserted a drawLine right after the call to com.github.weisj.jsvg.SVGDocument.renderWithPlatform. Confirmed:

image

Note that the PR does not actually remove the platform/libs.batik.read module, just the dependency on it from platform/openide.util.ui.svg . Removing the batik library entirely could be done separately if desired.

@eirikbakke
Copy link
Contributor Author

eirikbakke commented Nov 9, 2024

I do see some cases where the icons for Undo, Redo, and Quick Search appear with the right shape, but a black fill, even though other icons look fine. Then in another case they looked OK. Will require some more investigation.

image

@eirikbakke
Copy link
Contributor Author

OK, the "black shapes" problem was only with some older SVG files that we no longer use. They were generated using a now-deprecated setting in Adobe Illustrator.

(Full details: The problem occurred only on an my private build of NetBeans, which had some older versions of the SVG files that were generated with other Adobe Illustrator settings. All of those SVG files were regenerated in #7463, and replaced with versions that appear to work with JSVG. The README file merged in apache/netbeans-tools#67 lists the correct settings to use when generating SVGs from Adobe Illustrator. I filed an issue at weisJ/jsvg#96 to document the all-black icon issue, but it's not actually a problem for us as SVG files are now generated in a different way, and the setting that caused problems is now deprecated in Adobe Illustrator anyway.)

@eirikbakke eirikbakke removed the do not merge Don't merge this PR, it is not ready or just demonstration purposes. label Nov 9, 2024
@eirikbakke
Copy link
Contributor Author

I have now tested the patch on a build of master, in my working IDE (which is a private build based on NetBeans 22), and in my NetBeans Platform application (which has a bunch of additional icons beyond those in the IDE). The rendering seems to be entirely equivalent to Batik for our particular SVG files.

I think the PR is ready for review now, so I remove the do-not-merge label.

Copy link
Contributor

@matthiasblaesing matthiasblaesing left a comment

Choose a reason for hiding this comment

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

Minimal nitpick, apart from these this looks good to me. Thank you.

I think it would be good to create an issue with target NB25 to remove batik library. It makes no sense to ship a library we don't use, on the other hand I think it would be good to give this some time in master before removing batik.

@eirikbakke
Copy link
Contributor Author

I think it would be good to create an issue with target NB25 to remove batik library.

Here, I created it: #7969 (Also happy to create the PR for it once this current PR is merged.)

Copy link
Contributor

@matthiasblaesing matthiasblaesing left a comment

Choose a reason for hiding this comment

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

Looks sane. Thanks again.

@eirikbakke
Copy link
Contributor Author

Thanks for reviewing! Squashing the changes into a single commit before merging.

@eirikbakke eirikbakke merged commit 12719ec into apache:master Nov 16, 2024
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) Platform [ci] enable platform tests (platform/*) UI User Interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants