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
Chromote produces inconsistent screenshots for Shiny text outputs that have been updated #136
fyi, I just updated from 6f195b1 to 1a116ab (which includes little more than #166) and 2 of my (some 200) snapshots changed by the tiniest amount (single pixel, colors different by 1/256):
***** new.txt
660,757: (255,255,255) #FFFFFF white
661,757: (223,228,228) #DFE4E4 srgb(223,228,228)
662,757: (172,185,186) #ACB9BA srgb(172,185,186)
***** old.txt
660,757: (255,255,255) #FFFFFF white
661,757: (224,229,229) #E0E5E5 srgb(224,229,229) # <-- this is different
662,757: (172,185,186) #ACB9BA srgb(172,185,186)
*****
The single red pixel here shows where the difference is:
It's fine if that is expected, and I will then simply update my shapshots. However, I am reading this issue ("inconsistent border alias colors") and #166 as if you are looking for a way to repro effects like this, and it seems I can (even if in a big app).
So #166 removed "remove rounded corners" in the CSS.
Your single red pixel is what was happening to me earlier and does not look like changes made in #166. Do you mind accepting the images and seeing if the new images are consistent?
If they are not consistent, may I have your sessioninfo::session_info() output and possibly the app you are using? I don't mind if it is a larger app.
Nice job getting the value of the pixel! What code are you using to extract the values?
If it is a rounding issue by chrome, then having a tolerance of 1/256 for each color channel, per pixel is perfectly fine by me.
We can override the compare function when looking at expect_screenshot to read the pixel values and compare the numbers with a small tolerance. Does this seem fair?
So #166 removed "remove rounded corners" in the CSS.
I see - since I don't have those (at least not explicitly), I guess my expectation was correct that I should not see a change then.
Your single red pixel is what was happening to me earlier and does not look like changes made in #166. Do you mind accepting the images and seeing if the new images are consistent?
Will do over the course of the next few days (one full run takes ~30 minutes). By the way, this effect concerns almost all of my snapshots, not just 2 - no idea what I misinterpreted earlier. But having hundreds of these cases should give a good idea of the consistency after just a few runs.
If they are not consistent, may I have your sessioninfo::session_info() output and possibly the app you are using? I don't mind if it is a larger app.
I'll let you know.
Nice job getting the value of the pixel! What code are you using to extract the values?
If it is a rounding issue by chrome, then having a tolerance of 1/256 for each color channel, per pixel is perfectly fine by me.
We can override the compare function when looking at expect_screenshot to read the pixel values and compare the numbers with a small tolerance. Does this seem fair?
I would be fine with that, yes! But let's see if it is required at all.
By the way, another possible source of inconsistency that I just encountered is the version of shiny. Having shiny installed from CRAN, installing shinytest2 offers to upgrade shiny to the latest GitHub version; and when installing shinytest2 non-interactively, it does so without asking. I am aware of R_REMOTES_UPGRADE now, but that gave me some headaches trying to understand why seemingly unrelated updates to shinytest2 were changing my snapshots (in particular, the JSON ordering, which turned out to be rstudio/shiny@ac84be9 which is on GitHub but not on CRAN).
I would be fine with that, yes! But let's see if it is required at all.
👍
By the way, another possible source of inconsistency that I just encountered is the version of shiny. Having shiny installed from CRAN, installing shinytest2 offers to upgrade shiny to the latest GitHub version; and when installing shinytest2 non-interactively, it does so without asking. I am aware of R_REMOTES_UPGRADE now, but that gave me some headaches trying to understand why seemingly unrelated updates to shinytest2 were changing my snapshots (in particular, the JSON ordering, which turned out to be rstudio/shiny@ac84be9 which is on GitHub but not on CRAN).
The JSON ordering using the GitHub version of Shiny is a stable ordering and will be the ordering used going forward. Switching between the orderings is a breaking change, but hopefully it is easy to resolve.
Shiny will be released to CRAN in a couple months (for rstudio::conf). {shinytest2} will hopefully released to CRAN within the month (for Appsilon's shiny conf).
It's not an app I can share yet, but if there is a need, I might try to isolate a small test case (I have example differences on the home page of the app). So far, all differences do indeed look like rounding errors (max. diff. of 1 unit in each channel).
But it is still a game of wack-a-mole and produces different UI from what is normally displayed. I believe it is much more robust to have a tolerance in rounding.
Working on a PR for a new image compare function. 😃
Some of them differ by one, but some do not. Notably, the pixel values for the blue circles at the top are off by much larger amounts -- up to 15 in one case.
EDIT: It is possible that the stuff with the blue circles was fixed by forcing Chrome to use a SRGB color profile: rstudio/chromote#58
I believe that the grey pixels in the corner was a separate issue.
@nstrayer says that it may have something to do with the window resizing that's done by the $screenshot() method.
@nstrayer says that it may have something to do with the window resizing that's done by the $screenshot() method.
That is interesting. Is that resizing related to setVisibleSize? If it is, note that in rstudio/chromote#81 (comment), I have been able to replace the setVisibleSize calls by captureBeyondViewport. Maybe that helps avoid the issue in the first place?
Activity
schloerke commentedon Mar 14, 2022
Ideas:
:beforeclass to cause chrome to paint the element againTry using the docker color profile fromchromote::default_chrome_args()--force-color-profile=srgbis already active by defaultschloerke commentedon Mar 31, 2022
@DivadNojnarg Have you run into this bug? ...Or is it just me
DivadNojnarg commentedon Apr 1, 2022
I don't see anything wrong.
I checked with:
Test script:
Res:
schloerke commentedon Apr 1, 2022
@DivadNojnarg Hmmm. I can not reprex my expected failure.
Thank you for looking! I'll dig deeper later next week.
schloerke commentedon Apr 1, 2022
Larger reprex where I was expecting fail on the third screenshot on the second execution of
test_app():This did not fail. Even when removing the CSS Shim. 🤷♂️ Guess the bug is gone? So weird!?!
bersbersbers commentedon Apr 5, 2022
fyi, I just updated from 6f195b1 to 1a116ab (which includes little more than #166) and 2 of my (some 200) snapshots changed by the tiniest amount (single pixel, colors different by 1/256):
The single red pixel here shows where the difference is:

It's fine if that is expected, and I will then simply update my shapshots. However, I am reading this issue ("inconsistent border alias colors") and #166 as if you are looking for a way to repro effects like this, and it seems I can (even if in a big app).
schloerke commentedon Apr 5, 2022
@bersbersbers
So #166 removed "remove rounded corners" in the CSS.
Your single red pixel is what was happening to me earlier and does not look like changes made in #166. Do you mind accepting the images and seeing if the new images are consistent?
If they are not consistent, may I have your
sessioninfo::session_info()output and possibly the app you are using? I don't mind if it is a larger app.Nice job getting the value of the pixel! What code are you using to extract the values?
If it is a rounding issue by chrome, then having a tolerance of 1/256 for each color channel, per pixel is perfectly fine by me.
We can override the compare function when looking at expect_screenshot to read the pixel values and compare the numbers with a small tolerance. Does this seem fair?
bersbersbers commentedon Apr 5, 2022
I see - since I don't have those (at least not explicitly), I guess my expectation was correct that I should not see a change then.
Will do over the course of the next few days (one full run takes ~30 minutes). By the way, this effect concerns almost all of my snapshots, not just 2 - no idea what I misinterpreted earlier. But having hundreds of these cases should give a good idea of the consistency after just a few runs.
I'll let you know.
and then use the text diff tool of your choice.
See also https://legacy.imagemagick.org/discourse-server/viewtopic.php?t=13104
I would be fine with that, yes! But let's see if it is required at all.
By the way, another possible source of inconsistency that I just encountered is the version of
shiny. Havingshinyinstalled from CRAN, installingshinytest2offers to upgradeshinyto the latest GitHub version; and when installingshinytest2non-interactively, it does so without asking. I am aware ofR_REMOTES_UPGRADEnow, but that gave me some headaches trying to understand why seemingly unrelated updates toshinytest2were changing my snapshots (in particular, the JSON ordering, which turned out to be rstudio/shiny@ac84be9 which is on GitHub but not on CRAN).schloerke commentedon Apr 5, 2022
👍
The JSON ordering using the GitHub version of Shiny is a stable ordering and will be the ordering used going forward. Switching between the orderings is a breaking change, but hopefully it is easy to resolve.
Shiny will be released to CRAN in a couple months (for rstudio::conf).
{shinytest2}will hopefully released to CRAN within the month (for Appsilon's shiny conf).bersbersbers commentedon Apr 5, 2022
So I accepted all snapshots and reran the test, and I already see a couple of differences popping up:
And different differences in the next run...
Session info:
It's not an app I can share yet, but if there is a need, I might try to isolate a small test case (I have example differences on the home page of the app). So far, all differences do indeed look like rounding errors (max. diff. of 1 unit in each channel).
bersbersbers commentedon Apr 6, 2022
Addendum:
~/.gitattributes:~/.gitconfig:git_pixels.sh:And then this is nicely integrated with
git diff(after accepting snapshots).bersbersbers commentedon Apr 6, 2022
Here's an example of the same file switching back and forth in different runs (each time accepting the snapshot after running the test):
(For the record, all this never happened [to my knowledge] before updating from 6f195b1 to 1a116ab)
schloerke commentedon Apr 6, 2022
Thank you for the diff outputs! They are very helpful
The only change in that range that should make any differences in the screenshots is 6f195b1...1a116ab#diff-ba8577762c5f39401b58569371dcb979a01bb2b270cd3b2daefa0357cccbc838
But it is still a game of wack-a-mole and produces different UI from what is normally displayed. I believe it is much more robust to have a tolerance in rounding.
Working on a PR for a new image compare function. 😃
wch commentedon Apr 6, 2022
FYI, allowing a difference of one in each RGB channel might not be sufficient to avoid these problems. See r-lib/diffviewer#9.
The important part of that issue are these RGB value differences:
Some of them differ by one, but some do not. Notably, the pixel values for the blue circles at the top are off by much larger amounts -- up to 15 in one case.
EDIT: It is possible that the stuff with the blue circles was fixed by forcing Chrome to use a SRGB color profile: rstudio/chromote#58
I believe that the grey pixels in the corner was a separate issue.
@nstrayer says that it may have something to do with the window resizing that's done by the
$screenshot()method.bersbersbers commentedon Apr 6, 2022
That is interesting. Is that resizing related to
setVisibleSize? If it is, note that in rstudio/chromote#81 (comment), I have been able to replace thesetVisibleSizecalls bycaptureBeyondViewport. Maybe that helps avoid the issue in the first place?schloerke commentedon Apr 6, 2022
@bersbersbers Do you mind making a
{chromote}PR for the changes to screenshot.R in rstudio/chromote#81 (comment) ? Thank you!Avoiding resizing would also prevent plots and other reactive values re-rending given a window size change. (Good for
{shinytest2})bersbersbers commentedon Apr 6, 2022
@schloerke done, rstudio/chromote#83
schloerke commentedon Apr 20, 2022
Fixed in rstudio/chromote#83