Black package background when transparent used for package and default background (ubuntu)

0 votes
asked Nov 22, 2020 in Bug by Fuhrmanator (1,700 points)

I'm using PlantUML on WSL running Ubuntu 20.04.1 LTS and I have a problem with package backgrounds showing up as black, but only when the backgroundColor is already transparent.

Here's my configuration info:

$ uname -a
Linux DESKTOP-CHAOS 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:        20.04
Codename:       focal
java --version
openjdk 11.0.9.1 2020-11-04
OpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)
$  java -jar ~/java/plantuml.jar -version
PlantUML version 1.2020.20 (Sat Nov 21 05:02:45 EST 2020)
(GPL source distribution)
Java Runtime: OpenJDK Runtime Environment
JVM: OpenJDK 64-Bit Server VM
Default Encoding: UTF-8
Language: en
Country: null

PLANTUML_LIMIT_SIZE: 4096

Dot version: dot - graphviz version 2.43.0 (0)
Installation seems OK. File generation OK

Sample file:

$ cat sample.puml
@startuml
skinparam backgroundcolor transparent
skinparam packagebackgroundcolor transparent
skinparam style strictuml
package a {
class B
}
@enduml

$ java -jar ~/java/plantuml.jar -tsvg -charset UTF-8 sample.puml

Here's the resulting image (screenshot from inkscape)

If I remove skinparam backgroundcolor transparent everything is OK.

1 Answer

+1 vote
answered Nov 23, 2020 by plantuml (295,000 points)
This is weird, because it seems to work under Chrome or Firefox

( see http://www.plantuml.com/plantuml/svg/ZSr13i9028NXFQVWA8qtULBIDANC19Y5CTxTqRXmsGsR_oDloKBKE8tosBqZSF8TScpHXg_Ih0LNm7CczVfJVIfiUWrdFKpdZLs-Oxzd1Zz939byenSjwkkdlW40 )

Maybe an inkscape issue ?

Could you manually edit the SVG file to tell more about it ? Inside this SVG file, "#00000000" should be interpreted as transparent (well, I think :-)
commented Nov 23, 2020 by Fuhrmanator (1,700 points)

I'm using Inkscape 1.0.x on Windows and Linux so it does appear to be related to that tool. 

Like you say, it previews well in my VSCode PlantUML plugin both on Windows and Linux (I'm not sure how they show previews under the hood), and Chrome/Firefox with this link.  

If I convert the SVG to PNG with the linux convert tool, the backgrounds are OK (but convert doesn't do a nice job with fonts, etc.). 

I found out a fix to the SVG (at least for inkscape), on the style of the package polygon, if I add "fill:none" to the end. That is,

$ diff sample.svg sample_fill_none.svg
2c2
< cluster a--><polygon fill="#00000000" points="16,6,31,6,38,28.2969,62,28.2969,62,97,16,97,16,6" style="stroke: #000000; stroke-width: 1.5;"/><line style="stroke: #000000; stroke-width: 1.5;" x1="16" x2="38" y1="28.2969" y2="28.2969"/><text fill="#000000" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="9" x="20" y="20.9951">a</text><!--MD5=[69c451c751c414e37549b782190fef46]
---
> cluster a--><polygon fill="#00000000" points="16,6,31,6,38,28.2969,62,28.2969,62,97,16,97,16,6" style="stroke: #000000; stroke-width: 1.5;fill:none"/><line style="stroke: #000000; stroke-width: 1.5;" x1="16" x2="38" y1="28.2969" y2="28.2969"/><text fill="#000000" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="9" x="20" y="20.9951">a</text><!--MD5=[69c451c751c414e37549b782190fef46]
20c20

Otherwise, I will need to pursue a bug report with Inkscape. I'm not sure when this started, as the file where I saw the problem I have not touched in more than a year.

commented Nov 23, 2020 by plantuml (295,000 points)

You can try last beta http://beta.plantuml.net/plantuml.jar

We now add "fill:none;" for polygon when fill is "#00000000."

It sounds like a hack, but if it helps Inkscape and does not bother other, we are ok with that.

Tell us if it's working for you and if you find regression !

Thanks

commented Nov 23, 2020 by Fuhrmanator (1,700 points)

I went a step further to diff the two SVG files produced (one with skinparam backgroundcolor transparent and the other without it), and here is what it looks like:

$ wdiff sample.svg sample-no-background.svg | colordiff
<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentScriptType="application/ecmascript" contentStyleType="text/css" height="104px" preserveAspectRatio="none" [-style="width:79px;height:104px;background:#00000000;"-] {+style="width:79px;height:104px;"+} version="1.1" viewBox="0 0 79 104" width="79px" zoomAndPan="magnify"><defs/><g><!--MD5=[03c9795141fffc1586b10a901fd13311]
cluster a--><polygon [-fill="#00000000"-] {+fill="#FFFFFF"+} points="16,6,31,6,38,28.2969,62,28.2969,62,97,16,97,16,6" style="stroke: #000000; stroke-width: 1.5;"/><line style="stroke: #000000; stroke-width: 1.5;" x1="16" x2="38" y1="28.2969" y2="28.2969"/><text fill="#000000" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="9" x="20" y="20.9951">a</text><!--MD5=[69c451c751c414e37549b782190fef46]
class B--><rect codeLine="5" fill="#FEFECE" height="39.9688" id="B" style="stroke: #A80036; stroke-width: 1.5;" width="14" x="32" y="41"/><text fill="#000000" font-family="sans-serif" font-size="12" lengthAdjust="spacingAndGlyphs" textLength="8" x="35" y="57.1387">B</text><line style="stroke: #A80036; stroke-width: 1.5;" x1="33" x2="45" y1="64.9688" y2="64.9688"/><line style="stroke: #A80036; stroke-width: 1.5;" x1="33" x2="45" y1="72.9688" [-y2="72.9688"/><!--MD5=[1a6d1374294d2653a55137f104111a40]-] {+y2="72.9688"/><!--MD5=[fe362aebce9f6af6177bd7bc421da198]+}
@startuml
[-skinparam-]
{+'skinparam+} backgroundcolor transparent
{+skinparam packagebackgroundcolor transparent
skinparam style strictuml
package a {
class B
}
@enduml

@startuml+}
skinparam packagebackgroundcolor transparent
skinparam style strictuml
package a {
class B
}
@enduml

PlantUML version 1.2020.20(Sat Nov 21 05:02:45 EST 2020)
(GPL source distribution)
Java Runtime: OpenJDK Runtime Environment
JVM: OpenJDK 64-Bit Server VM
Default Encoding: UTF-8
Language: en
Country: null
--></g></svg>

The diff gets the PlantUML source code wrong (at least it presents the diff badly, one line is commented out).

I'm surprised to see the fill="#FFFFFF" appearing in the package background on the version where skinparam backgroundcolor transparent is not specified. Shouldn't it still be "#000000" or is it deducing the background is white since nothing is specified?

I saw you posted another response - so I have not read it yet...

commented Nov 23, 2020 by Fuhrmanator (1,700 points)
Thanks for the quick turnaround! It is working for the example I have. I will try my other diagrams in my course notes and let you know.

As for the "hacks" with SVG, the transparency issue seems to be full of inconsistencies depending on library support and tools and when they were created: https://stackoverflow.com/questions/6042550/svg-fill-color-transparency-alpha
commented Nov 24, 2020 by Fuhrmanator (1,700 points)

I found one regression - if you use:

skinparam packageStyle rect

commented Nov 24, 2020 by Fuhrmanator (1,700 points)

Hello again - there are actually many more regressions. I haven't made an exhaustive list, but if you get a hold of Inkscape 1.0.x you can try the examples below.  

To find these bugs it could be useful to rebuild the PlantUML documentation using SVG/Inkscape in the toolchain rather than PNG? It's actually how I build my course notes. It's useful to keep the vector format, because PDF viewers can find the text in the PlantUML diagrams (not possible if they're PNG). 

As a potential work-around, I also tried using -tpdf with all its required libraries. But it's, too, crashing with exceptions like:

CSSEngine: exception property.syntax.error:org.w3c.css.sac.CSSParseException: Invalid RGB color: 00000000.

@startuml
skinparam BackgroundColor transparent
skinparam ClassBackgroundColor transparent
skinparam PackageBackgroundColor transparent
skinparam ComponentBackgroundColor transparent
skinparam NodeBackgroundColor transparent
skinparam PackageStyle rect

package "Some Group" {
HTTP - [First Component]
[Another Component]

}

node "Other Groups..." {
FTP - [Second Component]
[First Component]
 --> FTP
}
cloud {
[Example 1]
}
database "MySql" {
folder "This is my folder" {
[Folder 3]
}
frame "Foo" {
[Frame 4]
}
}
[Another Component] --> [Example 1]
[Example 1]
 --> [Folder 3]
[Folder 3]
 --> [Frame 4]
@enduml

@startuml
skinparam BackgroundColor transparent
skinparam ClassBackgroundColor transparent
skinparam PackageBackgroundColor transparent
skinparam PackageStyle rect

interface B

package a {
    class A
}

cloud c {
    class C
}

folder f {
    class F
}

folder f {
    class F
}

database {
    class D
}

frame "Frame" {
    class frame
}
@enduml

An apparent work-around is to use #transparent on each element, rather than the skinparam. I didn't try it in all the cases, but it works in a lot (except for when you have a namespace in a class, e.g., a.b.C, and PlantUML draws a package for it).

commented Nov 25, 2020 by plantuml (295,000 points)

This is weird: there shouldn't be any difference between using #transparent or skinparam.

I'm confused here :-)

Anyway , we figure out that it was useless in the generated SVG to put #00000000 to fill shapes. So here is a new beta http://beta.plantuml.net/plantuml.jar that may work better.

Tell us if it changes something!

commented Nov 25, 2020 by Fuhrmanator (1,700 points)

Thanks again for the quick reply - that new beta is working on all the examples I found. I hope this has a long-term benefit, too. smiley

...