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

Cyclic dependency involving node 'white' detected while reading an SVG created by codecov. #91

Open
bric3 opened this issue Oct 3, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@bric3
Copy link
Contributor

bric3 commented Oct 3, 2024

Suppose the following SVG created by https://codecov.io tool

With JSVG 1.6.1, the following code fails with the cyclic dependency.

new SVGLoader().load(URI.create("https://camo.githubusercontent.com/ca6f04cc3d7d26ba9f9bce39862c3b44db4ffb93683580829f33b7940433d6d2/68747470733a2f2f636f6465636f762e696f2f67682f73706f636b6672616d65776f726b2f73706f636b2f70756c6c2f313235302f6772617068732f747265652e7376673f77696474683d363530266865696768743d313530267372633d707226746f6b656e3d786e773657457a64566f").toURL())
Oct 03, 2024 11:03:55 AM com.github.weisj.jsvg.parser.css.impl.SimpleCssParser$Parser expected
WARNING: Expected 'CURLY_OPEN' but got 'Token{type=CLASS_NAME, data='s'}'
Oct 03, 2024 11:03:55 AM com.github.weisj.jsvg.parser.css.impl.SimpleCssParser$Parser expected
WARNING: Expected 'CURLY_OPEN' but got 'Token{type=EOF, data='null'}'
Oct 03, 2024 11:03:55 AM com.github.weisj.jsvg.parser.SVGLoader load
WARNING: Could not load SVG 
java.lang.IllegalStateException: Cyclic dependency involving node 'white' detected.
	at com.github.weisj.jsvg.parser.ParsedElement.cyclicDependencyDetected(ParsedElement.java:126)
	at com.github.weisj.jsvg.parser.ParsedElement.nodeEnsuringBuildStatus(ParsedElement.java:83)
	at com.github.weisj.jsvg.parser.ParsedDocument.getElementById(ParsedDocument.java:53)
	at com.github.weisj.jsvg.parser.DefaultElementLoader.loadElement(DefaultElementLoader.java:56)
	at com.github.weisj.jsvg.parser.AttributeNode.getElementByUrl(AttributeNode.java:126)
	at com.github.weisj.jsvg.parser.AttributeNode.getPaint(AttributeNode.java:186)
	at com.github.weisj.jsvg.renderer.PaintContext.parse(PaintContext.java:78)
	at com.github.weisj.jsvg.nodes.ShapeNode.build(ShapeNode.java:84)
	at com.github.weisj.jsvg.parser.ParsedElement.build(ParsedElement.java:116)
	at com.github.weisj.jsvg.parser.ParsedElement.build(ParsedElement.java:114)
	at com.github.weisj.jsvg.parser.ParsedElement.build(ParsedElement.java:114)
	at com.github.weisj.jsvg.parser.ParsedElement.build(ParsedElement.java:114)
	at com.github.weisj.jsvg.parser.SVGDocumentBuilder.build(SVGDocumentBuilder.java:178)
	at com.github.weisj.jsvg.parser.StaxSVGLoader.load(StaxSVGLoader.java:169)
	at com.github.weisj.jsvg.parser.SVGLoader.load(SVGLoader.java:111)
	at com.github.weisj.jsvg.parser.SVGLoader.load(SVGLoader.java:62)
	at com.github.weisj.jsvg.parser.SVGLoader.load(SVGLoader.java:54)
	at com.github.weisj.jsvg.parser.SVGLoader.load(SVGLoader.java:49)
	at sandbox.swing.QuickImageViewer.main(QuickImageViewer.kt:35)

SVG attached : treemap

@weisJ
Copy link
Owner

weisJ commented Oct 3, 2024

From a quick glance I think the following is happening: The CSS parser is incorrectly applying the rect.s rule to the rect inside the pattern#white which tries to apply the mask referencing said pattern.

@bric3
Copy link
Contributor Author

bric3 commented Oct 5, 2024

I'm not sure on how to help fix that at this time 😵

@weisJ
Copy link
Owner

weisJ commented Oct 11, 2024

The current CSS parser is very rudimentary. I am currently working on a bit more advanced version which should support loads more selectors.

@weisJ
Copy link
Owner

weisJ commented Oct 24, 2024

See #93

@bric3
Copy link
Contributor Author

bric3 commented Oct 25, 2024

Thank you, I'll try to find some time to try code in #94.

@bric3
Copy link
Contributor Author

bric3 commented Oct 26, 2024

@weisJ Looks good with #94
image

On master the viewer fails with mentioned stack trace:

Oct 26, 2024 10:48:18 PM com.github.weisj.jsvg.parser.css.impl.SimpleCssParser$Parser expected
WARNING: Expected 'CURLY_OPEN' but got 'Token{type=CLASS_NAME, data='s'}'
Oct 26, 2024 10:48:18 PM com.github.weisj.jsvg.parser.css.impl.SimpleCssParser$Parser expected
WARNING: Expected 'CURLY_OPEN' but got 'Token{type=EOF, data='null'}'
Oct 26, 2024 10:48:18 PM com.github.weisj.jsvg.parser.SVGLoader load
WARNING: Could not load SVG 
java.lang.IllegalStateException: Cyclic dependency involving node 'white' detected.
	at com.github.weisj.jsvg.parser.ParsedElement.cyclicDependencyDetected(ParsedElement.java:126)
	at com.github.weisj.jsvg.parser.ParsedElement.nodeEnsuringBuildStatus(ParsedElement.java:83)
	at com.github.weisj.jsvg.parser.ParsedDocument.getElementById(ParsedDocument.java:53)
...

@bric3
Copy link
Contributor Author

bric3 commented Oct 26, 2024

I don't know if that's something that could interest you either for correctness or performance, but I tried the viewer with some d3js examples. Without noticing issues.

chart
chord-diagram
hierarchical-edge-bundling-II
stacked-bar chart-horizontal
streamgraph-transitions
sunburst
treemap
vector-tiles
watercolor
voronoi

@weisJ weisJ added the bug Something isn't working label Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants