You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to accept or debug almost exact matches (failures) #97
All my tests were passing nicely up until the moment I upgraded (new computer, R 4.0 etc) and when I got back to development the new doppelgangers for ggplot graphs became ever so slightly different, with the majority of differences in sub-pixel text length differences, for example:
< my current Ubuntu (20.10)
> my previous results, older Ubuntu version, macOS-latest on GitHub and Travis CI
< <g clip-path='url(#cpMC4wMHw3MjAuMDB8NTc2LjAwfDAuMDA=)'><text transform='trans
: late(104.11,227.68) rotate(-90)' style='font-size: 11.00px; font-family: Liber
: ation Sans;' textLength='67.06px' lengthAdjust='spacingAndGlyphs'>MPAA Raiting
: </text></g>
> <g clip-path='url(#cpMC4wMHw3MjAuMDB8NTc2LjAwfDAuMDA=)'><text transform='trans
: late(104.11,227.69) rotate(-90)' style='font-size: 11.00px; font-family: Liber
: ation Sans;' textLength='67.08px' lengthAdjust='spacingAndGlyphs'>MPAA Raiting
: </text></g>
the difference here is in two places (104.11,227.68 vs 104.11,227.69, and 67.06px vs 67.08px). The difference is so small that when reviewing the changed doppelgangers I was not able to see any difference in the diff mode at all.
I cannot figure out what causes it (and I think that it is something wrong locally on my computer, because various OSes on Travis and GH Actions give old results, with both R 3.6 and R 4.0).
Three questions:
have you ever experienced such a (presumably) font-related issue?
how would you debug such a problem?
would it be possible to have some tolerance threshold so that subpixel differences would not trigger a failure?
even though the fontLiberation package version is the same both locally and on rdrr.io (0.1.0)...
This leads me to discover that my fontLiberation installation is lazy. It does not actually ship ttf fonts, it just symlinked them:
$ ls /usr/lib/R/site-library/fontLiberation/fonts/liberation-fonts/ -l
total 2364
-rw-r--r-- 1 root root 242 May 30 2020 AUTHORS
-rw-r--r-- 1 root root 806 May 30 2020 ChangeLog
lrwxrwxrwx 1 root root 80 May 30 2020 LiberationMono-BoldItalic.ttf -> ../../../../../../share/fonts/truetype/liberation2/LiberationMono-BoldItalic.ttf
-rw-r--r-- 1 root root 162884 May 30 2020 LiberationMono-BoldItalic.woff
lrwxrwxrwx 1 root root 74 May 30 2020 LiberationMono-Bold.ttf -> ../../../../../../share/fonts/truetype/liberation2/LiberationMono-Bold.ttf
-rw-r--r-- 1 root root 171036 May 30 2020 LiberationMono-Bold.woff
...
lrwxrwxrwx 1 root root 78 May 30 2020 LiberationSerif-Regular.ttf -> ../../../../../../share/fonts/truetype/liberation2/LiberationSerif-Regular.ttf
-rw-r--r-- 1 root root 207624 May 30 2020 LiberationSerif-Regular.woff
-rw-r--r-- 1 root root 1977 May 30 2020 README
-rw-r--r-- 1 root root 350 May 30 2020 TODO
Now, I guess it might suggest that Ubuntu 20.10 shipped with updated fonts.
@lionel- would it be possible to enforce that fontLiberation uses a consistent version of the font files across all installations? It might also explain the earlier issues, e.g. #93.
I tried down-grading fonts-liberation2 to 2.1.0-1 and to 2.00.1-5 but it did not help. It worked with Ubuntu 20.04 which had 2.1.0-1, so it is even more confusing now.
But I do believe it is a real problem (lack of reproducibility between installations was previously reported) and an important one. Any help would be appreciated.
Oddly enough all letters are of identical width. I probably should note that this issue does only appear for some strings, not all of them. I verified that all letters, digits and uppercase letters (and space) are of the same width with:
I downloaded fontLiberation_0.1.0.zip build for Windows from CRAN because it contains the fonts in tff format. I extracted the fonts to a local fonts directory and run the str_width with the obtained font file:
13.85938 although it should have produced 13.87500 according to the reference.
which provides another evidence suggesting that it is not because of a change in the fonts file, but due to another (potential) bug
in freetypeharfbuzz (which should have been reproducible but is not).
I presume that this is still the right place to report freetypeharfbuzz issues because it seems to have been created for vdiffr specifically (and it has no GitHub page mentioned on CRAN):
Unlike other tools that dynamically link to the 'Cairo' stack, 'freetypeharfbuzz' is statically linked to specific versions of the 'FreeType' and 'harfbuzz' libraries (2.9 and 1.7.6 respectively). This ensures deterministic computation of text box extents for situations where reproducible results are crucial (for instance unit tests of graphics).
I re-installed freetypeharfbuzz with: install.packages('freetypeharfbuzz')and the problem went away:
Maybe Ubuntu build used a a different version of static libraries that freetypeharfbuzz depends on?
The package lives here: r-cran-freetypeharfbuzz and was most recently updated on 2020-10-23 (0.2.5+dfsg-2build1), but as I only recently updated to Ubuntu 20.10 so I was not exposed to it earlier.
I'm glad you could solve it, hopefully that unblocks you.
FWIW the next version of vdiffr (to be released around the time R 4.1 will be released) will drop the freetypeharfbuzz dependency. We will only support ascii characters in vdiffr snapshots and the font extent computations will be fully hardcoded. This will make things much simpler and robest.
I reported this as a potential bug in the Ubuntu version of the package: 1906836. I guess we can close this issue, unless you wish to rename it ("Font width reproducibility issues on Ubuntu"?) and keep it open for visibility until the upstream issue is confirmed/fixed.
Activity
krassowski commentedon Dec 4, 2020
I checked versions of vdiffr, fontquiver, ggplot2, vdiffr-svg-engine, etc.
I'm seeing a similar flicker here: https://github.com/r-lib/svglite/pull/104/files#diff-42122f00f87a1a9ef5e54c7b7b15f8e19fc96156dcaafdfa4de045d2ccc98733 but I do not know if this is related. It seems that vdiffr does not depend on svglite, yet it uses its code in some version - is this correct?
krassowski commentedon Dec 4, 2020
I can reproduce the value of
67.06pxlocally with:Same with:
Where:
with:
More info:
krassowski commentedon Dec 4, 2020
Yet, when I run the same script on https://rdrr.io/snippets/, I get a different value:
while the path is the same:
the md5 checksum differs:
even though the
fontLiberationpackage version is the same both locally and on rdrr.io (0.1.0)...This leads me to discover that my
fontLiberationinstallation is lazy. It does not actually ship ttf fonts, it just symlinked them:Now, I guess it might suggest that Ubuntu 20.10 shipped with updated fonts.
@lionel- would it be possible to enforce that
fontLiberationuses a consistent version of the font files across all installations? It might also explain the earlier issues, e.g. #93.krassowski commentedon Dec 4, 2020
I tried down-grading
fonts-liberation2to 2.1.0-1 and to 2.00.1-5 but it did not help. It worked with Ubuntu 20.04 which had 2.1.0-1, so it is even more confusing now.But I do believe it is a real problem (lack of reproducibility between installations was previously reported) and an important one. Any help would be appreciated.
krassowski commentedon Dec 4, 2020
Oddly enough all letters are of identical width. I probably should note that this issue does only appear for some strings, not all of them. I verified that all letters, digits and uppercase letters (and space) are of the same width with:
I saved the result from rdrr.io as
reference.tsv, my local result aslocal.tsvand compared:which returns
TRUE.krassowski commentedon Dec 4, 2020
To investigate further I compared widths of all substrings:
I saved the result from rdrr.io as
reference.csv, my local result aslocal.csvand compared:which produces:
highlighting that
PAis a minimal reproducible example.krassowski commentedon Dec 4, 2020
I downloaded fontLiberation_0.1.0.zip build for Windows from CRAN because it contains the fonts in tff format. I extracted the fonts to a local
fontsdirectory and run thestr_widthwith the obtained font file:which produces:
13.85938although it should have produced13.87500according to the reference.which provides another evidence suggesting that it is not because of a change in the fonts file, but due to another (potential) bug
in
freetypeharfbuzz(which should have been reproducible but is not).krassowski commentedon Dec 4, 2020
I presume that this is still the right place to report
freetypeharfbuzzissues because it seems to have been created forvdiffrspecifically (and it has no GitHub page mentioned on CRAN):I re-installed
freetypeharfbuzzwith:install.packages('freetypeharfbuzz')and the problem went away:This suggests that the system-wide installation of
freetypeharfbuzzwas the culprit:$ apt list --installed | grep r-cran-freetypeharfbuzz r-cran-freetypeharfbuzz/groovy,now 0.2.5+dfsg-2build1 amd64 [installed,automatic]Maybe Ubuntu build used a a different version of static libraries that freetypeharfbuzz depends on?
The package lives here: r-cran-freetypeharfbuzz and was most recently updated on 2020-10-23 (0.2.5+dfsg-2build1), but as I only recently updated to Ubuntu 20.10 so I was not exposed to it earlier.
lionel- commentedon Dec 4, 2020
I'm glad you could solve it, hopefully that unblocks you.
FWIW the next version of vdiffr (to be released around the time R 4.1 will be released) will drop the freetypeharfbuzz dependency. We will only support ascii characters in vdiffr snapshots and the font extent computations will be fully hardcoded. This will make things much simpler and robest.
krassowski commentedon Dec 4, 2020
I reported this as a potential bug in the Ubuntu version of the package: 1906836. I guess we can close this issue, unless you wish to rename it ("Font width reproducibility issues on Ubuntu"?) and keep it open for visibility until the upstream issue is confirmed/fixed.
Re-render test graphics, see r-lib/vdiffr#97
lionel- commentedon Jun 8, 2021
Fixed by #106 which removes the freetypeharfbuzz dependency.