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

Error: No viewBox attribute found in SVG! #279

Closed
nc-at-sp opened this issue Jul 27, 2023 · 10 comments
Closed

Error: No viewBox attribute found in SVG! #279

nc-at-sp opened this issue Jul 27, 2023 · 10 comments

Comments

@nc-at-sp
Copy link

I get this issue when attempting to serve my site locally. My model is relatively large and complex. This error does not always happen; if I exit and re-execute multiple times it will eventually work. It feels like a race condition or some other kind of threading issue to me.

OS: WSL (Ubuntu)
Java: 20.0.1 2023-04-18
structurizr-site-generatr version v1.1.4

structurizr-site-generatr serve -w my-file.dsl

java.lang.IllegalStateException: java.lang.IllegalStateException: No viewBox attribute found in SVG!
        at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484)
        at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:540)
        at java.base/java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:567)
        at java.base/java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:670)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateParallel(ForEachOps.java:159)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(ForEachOps.java:173)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233)
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
        at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:765)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt.generateHtmlFiles(SiteGenerator.kt:158)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt.generateSite(SiteGenerator.kt:71)
        at nl.avisi.structurizr.site.generatr.ServeCommand.updateSite(ServeCommand.kt:82)
        at nl.avisi.structurizr.site.generatr.ServeCommand.execute(ServeCommand.kt:50)
        at kotlinx.cli.ArgParser.parse(ArgParser.kt:657)
        at kotlinx.cli.ArgParser.parse(ArgParser.kt:530)
        at nl.avisi.structurizr.site.generatr.AppKt.main(App.kt:13)
Caused by: java.lang.IllegalStateException: No viewBox attribute found in SVG!
        at nl.avisi.structurizr.site.generatr.site.model.DiagramViewModel$Companion.extractDiagramWidthInPixels(DiagramViewModel.kt:40)
        at nl.avisi.structurizr.site.generatr.site.model.DiagramViewModel$Companion.forView(DiagramViewModel.kt:28)
        at nl.avisi.structurizr.site.generatr.site.model.DiagramViewModel$Companion.forView(DiagramViewModel.kt:16)
        at nl.avisi.structurizr.site.generatr.site.model.SoftwareSystemComponentPageViewModel.<init>(SoftwareSystemComponentPageViewModel.kt:12)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt$generateHtmlFiles$1$8$4.invoke(SiteGenerator.kt:133)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt$generateHtmlFiles$1$8$4.invoke(SiteGenerator.kt:133)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt$generateHtmlFiles$2.invoke(SiteGenerator.kt:158)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt$generateHtmlFiles$2.invoke(SiteGenerator.kt:158)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt.generateHtmlFiles$lambda$17(SiteGenerator.kt:158)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
        at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:722)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:290)
        at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:754)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
@nc-at-sp
Copy link
Author

Also, I cannot share my model file as it contains proprietary data.

@dirkgroot
Copy link
Collaborator

dirkgroot commented Aug 11, 2023

Hi @nc-at-sp, thanks for reporting this issue.

I'm not sure what causes this. Could you try reproducing this issue and then see if there's SVG's in the build directory, that don't contain a viewBox attribute, or that have a viewBox attribute that does not match this regular expression: \d+ \d+ \d+ \d+ (that's what this tool is looking for).

@nc-at-sp
Copy link
Author

nc-at-sp commented Aug 11, 2023 via email

@dirkgroot
Copy link
Collaborator

Thanks! My regex had an error. It should have been 4 \d+'s. Are there instances where one of the first two numbers in a viewBox attribute is a negative number?

@nc-at-sp
Copy link
Author

At least in my instance they're always 0 0

@dirkgroot
Copy link
Collaborator

dirkgroot commented Sep 8, 2023

@nc-at-sp Okay, thanks. This looks like some kind of race condition indeed. I think I know where this occurs. Just for confirmation: Does your model contain diagrams that you have embedded in one or more documentation files using the ![](embed:diagram_key) syntax?

@dirkgroot
Copy link
Collaborator

@nc-at-sp I've set up a PR with a possible fix for this issue (#308). Could you test if that change solves this issue?

You can download the binaries produced by this PR using this link.

@nc-at-sp
Copy link
Author

nc-at-sp commented Sep 8, 2023

@dirkgroot that seems to have done the trick; attempted 10 or so reloads and didn't see the issue once. Seems to be generally faster as well. Thanks!

dirkgroot added a commit that referenced this issue Sep 11, 2023
@dirkgroot
Copy link
Collaborator

Thanks for testing, @nc-at-sp! I've merged the PR, and will create a release somewhere this week. I'm closing this issue.

@oneacik
Copy link

oneacik commented Sep 25, 2023

Hello @dirkgroot,
when the docker image will be available with this fix?
Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants