Skip to content

Chromote produces inconsistent screenshots for Shiny text outputs that have been updated #136

Closed

Description

@schloerke

Performing a $expect_screenshot() on a Shiny text output, update the output, then another $expect_screenshot().

The first $expect_screenshot() is consistent. Everything works great.

The second $expect_screenshot() has inconsistent border alias colors. 😞

Add $expect_screenshot() after each $expect_values() in ./tests/testthat/apps/widgets for an example.


I fear this will be hard to fix.

Activity

  1. added this to the v0.0.1 milestone on Mar 14, 2022
  2. schloerke commented on Mar 14, 2022

    @schloerke
    CollaboratorAuthor

    Ideas:

    • Add a CSS :before class to cause chrome to paint the element again
    • Remove the rounded corners
    • Try using the docker color profile from chromote::default_chrome_args()
      • --force-color-profile=srgb is already active by default
  3. added
    bug
    on Mar 18, 2022
  4. schloerke commented on Mar 31, 2022

    @schloerke
    CollaboratorAuthor

    @DivadNojnarg Have you run into this bug? ...Or is it just me

  5. DivadNojnarg commented on Apr 1, 2022

    @DivadNojnarg
    Contributor

    I don't see anything wrong.

    I checked with:

    library(shiny)
    app <- shinyApp(
      ui = basicPage(
        textInput("txt", "Enter the text to display below:"),
        textOutput("text")
      ),
      server = function(input, output) {
        output$text <- renderText({ input$txt })
      }
    )

    Test script:

    test_that("{shinytest2} recording: textOutput", {
      chrome <- shinytest2::AppDriver$new("../../", variant = shinytest2::platform_variant())
      chrome$expect_screenshot()
      chrome$set_inputs(txt = "Blabla")
      chrome$expect_screenshot()
      chrome$stop()
    })

    Res:

    ==> Testing R file using 'testthat'
    
    ℹ Loading shinytest2Test
    
    ══ Testing test-server.R ═══════════════════════════════════════════════════════
    
    [ FAIL 0 | WARN 0 | SKIP 0 | PASS 0 ]
    [ FAIL 0 | WARN 1 | SKIP 0 | PASS 0 ]
    [ FAIL 0 | WARN 1 | SKIP 0 | PASS 1 ]
    [ FAIL 0 | WARN 2 | SKIP 0 | PASS 1 ]
    [ FAIL 0 | WARN 2 | SKIP 0 | PASS 2 ]
    
    ── Warning (test-server.R:6:3): {shinytest2} recording: textOutput ─────────────
    Adding new file snapshot: 'tests/testhat/_snaps/001.png'
    
    ── Warning (test-server.R:8:3): {shinytest2} recording: textOutput ─────────────
    Adding new file snapshot: 'tests/testhat/_snaps/002.png'
    
    
    [ FAIL 0 | WARN 2 | SKIP 0 | PASS 2 ]
  6. schloerke commented on Apr 1, 2022

    @schloerke
    CollaboratorAuthor

    @DivadNojnarg Hmmm. I can not reprex my expected failure.

    Thank you for looking! I'll dig deeper later next week.

  7. schloerke commented on Apr 1, 2022

    @schloerke
    CollaboratorAuthor

    Larger reprex where I was expecting fail on the third screenshot on the second execution of test_app():

    shiny_app <- shinyApp(
      ui = basicPage(
        textInput("txt", "Enter the text to display below:"),
        wellPanel(
          textOutput("text")
        )
      ),
      server = function(input, output) {
        output$text <- renderText({ input$txt })
      }
    )
    
    test_that("{shinytest2} recording: textOutput", {
      chrome <- shinytest2::AppDriver$new(shiny_app, variant = shinytest2::platform_variant())
    
      chrome$expect_screenshot()
    
      chrome$set_inputs(txt = "Blabla")
      chrome$expect_screenshot()
    
      chrome$set_inputs(txt = "Qwerty")
      chrome$expect_screenshot()
    
      chrome$stop()
    })

    This did not fail. Even when removing the CSS Shim. 🤷‍♂️ Guess the bug is gone? So weird!?!


    • Remove CSS Shim
  8. bersbersbers commented on Apr 5, 2022

    @bersbersbers
    Contributor

    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:
    image

    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).

  9. schloerke commented on Apr 5, 2022

    @schloerke
    CollaboratorAuthor

    @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?

  10. bersbersbers commented on Apr 5, 2022

    @bersbersbers
    Contributor

    @bersbersbers

    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?

    magick convert image.png image.txt
    

    and then use the text diff tool of your choice.
    See also https://legacy.imagemagick.org/discourse-server/viewtopic.php?t=13104

    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).

  11. schloerke commented on Apr 5, 2022

    @schloerke
    CollaboratorAuthor

    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).

  12. added
    question
    on Apr 5, 2022
  13. bersbersbers commented on Apr 5, 2022

    @bersbersbers
    Contributor

    So I accepted all snapshots and reran the test, and I already see a couple of differences popping up:

    diff old.txt new.txt
    542717c542717
    < 1695,284: (184,184,184,255)  #B8B8B8FF  grey72
    ---
    > 1695,284: (183,183,183,255)  #B7B7B7FF  srgba(183,183,183,1)
    542894c542894
    < 1872,284: (184,184,184,255)  #B8B8B8FF  grey72
    ---
    > 1872,284: (183,183,183,255)  #B7B7B7FF  srgba(183,183,183,1)
    544621c544621
    < 1694,285: (197,197,197,255)  #C5C5C5FF  srgba(197,197,197,1)
    ---
    > 1694,285: (196,196,196,255)  #C4C4C4FF  grey77
    544800c544800
    < 1873,285: (197,197,197,255)  #C5C5C5FF  srgba(197,197,197,1)
    ---
    > 1873,285: (196,196,196,255)  #C4C4C4FF  grey77
    

    And different differences in the next run...

    Session info:

    sessioninfo::session_info()
    ─ Session info ─────────────────────────────────────────────────────────────────────
     setting  value
     version  R version 4.1.2 (2021-11-01)
     os       openSUSE Leap 15.2
     system   x86_64, linux-gnu
     ui       X11
     language (EN)
     collate  en_US.UTF-8
     ctype    en_US.UTF-8
     tz       Europe/Berlin
     date     2022-04-05
     pandoc   2.9.2.1 @ /usr/bin/ (via rmarkdown)
    
    ─ Packages ─────────────────────────────────────────────────────────────────────────
     package      * version    date (UTC) lib source
     assertthat     0.2.1      2019-03-21 [1] CRAN (R 4.1.2)
     backports      1.4.1      2021-12-13 [1] CRAN (R 4.1.2)
     bayestestR     0.11.5     2021-10-30 [1] CRAN (R 4.1.2)
     brio           1.1.3      2021-11-30 [1] CRAN (R 4.1.2)
     bslib          0.3.1      2021-10-06 [1] CRAN (R 4.1.2)
     callr          3.7.0      2021-04-20 [1] CRAN (R 4.1.2)
     checkmate      2.0.0      2020-02-06 [1] CRAN (R 4.1.2)
     chromote       0.0.0.9003 2022-03-31 [1] Github (rstudio/chromote@865e24e)
     cli            3.2.0      2022-02-14 [1] CRAN (R 4.1.2)
     colorspace     2.0-3      2022-02-21 [1] CRAN (R 4.1.2)
     crayon         1.5.1      2022-03-26 [1] CRAN (R 4.1.2)
     curl           4.3.2      2021-06-23 [1] CRAN (R 4.1.2)
     datawizard     0.4.0      2022-03-30 [1] CRAN (R 4.1.2)
     DBI            1.1.2      2021-12-20 [1] CRAN (R 4.1.2)
     desc           1.4.1      2022-03-06 [1] CRAN (R 4.1.2)
     digest         0.6.29     2021-12-01 [1] CRAN (R 4.1.2)
     dplyr          1.0.8      2022-02-08 [1] CRAN (R 4.1.2)
     ellipsis       0.3.2      2021-04-29 [1] CRAN (R 4.1.2)
     evaluate       0.15       2022-02-18 [1] CRAN (R 4.1.2)
     fansi          1.0.3      2022-03-24 [1] CRAN (R 4.1.2)
     fastmap        1.1.0      2021-01-25 [1] CRAN (R 4.1.2)
     fs             1.5.2      2021-12-08 [1] CRAN (R 4.1.2)
     generics       0.1.2      2022-01-31 [1] CRAN (R 4.1.2)
     ggplot2        3.3.5      2021-06-25 [1] CRAN (R 4.1.2)
     glue           1.6.2      2022-02-24 [1] CRAN (R 4.1.2)
     gtable         0.3.0      2019-03-25 [1] CRAN (R 4.1.2)
     htmltools      0.5.2      2021-08-25 [1] CRAN (R 4.1.2)
     htmlwidgets    1.5.4      2021-09-08 [1] CRAN (R 4.1.2)
     httpuv         1.6.5      2022-01-05 [1] CRAN (R 4.1.2)
     httr           1.4.2      2020-07-20 [1] CRAN (R 4.1.2)
     import         1.2.0      2020-09-24 [1] CRAN (R 4.1.2)
     insight        0.17.0     2022-03-29 [1] CRAN (R 4.1.2)
     jquerylib      0.1.4      2021-04-26 [1] CRAN (R 4.1.2)
     jsonlite       1.8.0      2022-02-22 [1] CRAN (R 4.1.2)
     knitr          1.38       2022-03-25 [1] CRAN (R 4.1.2)
     later          1.3.0      2021-08-18 [1] CRAN (R 4.1.2)
     lifecycle      1.0.1      2021-09-24 [1] CRAN (R 4.1.2)
     magrittr       2.0.3      2022-03-30 [1] CRAN (R 4.1.2)
     mime           0.12       2021-09-28 [1] CRAN (R 4.1.2)
     munsell        0.5.0      2018-06-12 [1] CRAN (R 4.1.2)
     pillar         1.7.0      2022-02-01 [1] CRAN (R 4.1.2)
     pkgconfig      2.0.3      2019-09-22 [1] CRAN (R 4.1.2)
     pkgload        1.2.4      2021-11-30 [1] CRAN (R 4.1.2)
     processx       3.5.3      2022-03-25 [1] CRAN (R 4.1.2)
     promises       1.2.0.1    2021-02-11 [1] CRAN (R 4.1.2)
     ps             1.6.0      2021-02-28 [1] CRAN (R 4.1.2)
     purrr          0.3.4      2020-04-17 [1] CRAN (R 4.1.2)
     R6             2.5.1      2021-08-19 [1] CRAN (R 4.1.2)
     Rcpp           1.0.8.3    2022-03-17 [1] CRAN (R 4.1.2)
     rlang          1.0.2      2022-03-04 [1] CRAN (R 4.1.2)
     rmarkdown      2.13       2022-03-10 [1] CRAN (R 4.1.2)
     rprojroot      2.0.3      2022-04-02 [1] CRAN (R 4.1.2)
     sass           0.4.1      2022-03-23 [1] CRAN (R 4.1.2)
     scales         1.1.1      2020-05-11 [1] CRAN (R 4.1.2)
     sessioninfo    1.2.2      2021-12-06 [1] CRAN (R 4.1.2)
     shiny        * 1.7.1      2021-10-02 [1] CRAN (R 4.1.2)
     shinytest2   * 0.0.0.9002 2022-04-05 [1] Github (rstudio/shinytest2@91ff4e5)
     shinythemes    1.2.0      2021-01-25 [1] CRAN (R 4.1.2)
     shinyWidgets   0.6.4      2022-02-06 [1] CRAN (R 4.1.2)
     stringi        1.7.6      2021-11-29 [1] CRAN (R 4.1.2)
     stringr        1.4.0      2019-02-10 [1] CRAN (R 4.1.2)
     testthat     * 3.1.3      2022-03-29 [1] CRAN (R 4.1.2)
     tibble         3.1.6      2021-11-07 [1] CRAN (R 4.1.2)
     tidyselect     1.1.2      2022-02-21 [1] CRAN (R 4.1.2)
     utf8           1.2.2      2021-07-24 [1] CRAN (R 4.1.2)
     vctrs          0.4.0      2022-03-30 [1] CRAN (R 4.1.2)
     websocket      1.4.1      2021-08-18 [1] CRAN (R 4.1.2)
     withr          2.5.0      2022-03-03 [1] CRAN (R 4.1.2)
     xfun           0.30       2022-03-02 [1] CRAN (R 4.1.2)
     xtable         1.8-4      2019-04-21 [1] CRAN (R 4.1.2)
     zeallot        0.1.0      2018-01-28 [1] CRAN (R 4.1.2)
    
     [1] /data2/bers/opt/R/4.1/library
     [2] /usr/lib64/R/library
    
    ────────────────────────────────────────────────────────────────────────────────────
    

    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).

  14. bersbersbers commented on Apr 6, 2022

    @bersbersbers
    Contributor

    Nice job getting the value of the pixel! What code are you using to extract the values?

    Addendum:

    ~/.gitattributes:

    *.png       diff=pix
    

    ~/.gitconfig:

    [diff "pix"]
    textconv = git_pixels.sh
    binary = true
    

    git_pixels.sh:

    #!/bin/bash
    magick convert -define txt:compliance=SVG "$@" txt:
    

    And then this is nicely integrated with git diff (after accepting snapshots).

  15. bersbersbers commented on Apr 6, 2022

    @bersbersbers
    Contributor

    And different differences in the next run...

    Here's an example of the same file switching back and forth in different runs (each time accepting the snapshot after running the test):

    --- old.png
    +++ new.png
    @@ -414082,7 +414082,7 @@
     695,217: (255,255,255,1)  #FFFFFFFF  white
     696,217: (255,255,255,1)  #FFFFFFFF  white
     697,217: (218,218,218,1)  #DADADAFF  srgba(218,218,218,1)
    -698,217: (183,183,183,1)  #B7B7B7FF  srgba(183,183,183,1)
    +698,217: (184,184,184,1)  #B8B8B8FF  grey72
     699,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
     700,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
     701,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
    @@ -414134,7 +414134,7 @@
     747,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
     748,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
     749,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
    -750,217: (183,183,183,1)  #B7B7B7FF  srgba(183,183,183,1)
    +750,217: (184,184,184,1)  #B8B8B8FF  grey72
     751,217: (218,218,218,1)  #DADADAFF  srgba(218,218,218,1)
     752,217: (255,255,255,1)  #FFFFFFFF  white
     753,217: (255,255,255,1)  #FFFFFFFF  white
    @@ -415079,7 +415079,7 @@
     1692,217: (255,255,255,1)  #FFFFFFFF  white
     1693,217: (255,255,255,1)  #FFFFFFFF  white
     1694,217: (218,218,218,1)  #DADADAFF  srgba(218,218,218,1)
    -1695,217: (183,183,183,1)  #B7B7B7FF  srgba(183,183,183,1)
    +1695,217: (184,184,184,1)  #B8B8B8FF  grey72
     1696,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
     1697,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
     1698,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
    @@ -415256,7 +415256,7 @@
     1869,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
     1870,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
     1871,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
    -1872,217: (183,183,183,1)  #B7B7B7FF  srgba(183,183,183,1)
    +1872,217: (184,184,184,1)  #B8B8B8FF  grey72
     1873,217: (218,218,218,1)  #DADADAFF  srgba(218,218,218,1)
     1874,217: (255,255,255,1)  #FFFFFFFF  white
     1875,217: (255,255,255,1)  #FFFFFFFF  white
    @@ -415986,7 +415986,7 @@
     694,218: (255,255,255,1)  #FFFFFFFF  white
     695,218: (255,255,255,1)  #FFFFFFFF  white
     696,218: (218,218,218,1)  #DADADAFF  srgba(218,218,218,1)
    -697,218: (196,196,196,1)  #C4C4C4FF  grey77
    +697,218: (197,197,197,1)  #C5C5C5FF  srgba(197,197,197,1)
     698,218: (241,241,241,1)  #F1F1F1FF  srgba(241,241,241,1)
     699,218: (255,255,255,1)  #FFFFFFFF  white
     700,218: (255,255,255,1)  #FFFFFFFF  white
    @@ -416040,7 +416040,7 @@
     748,218: (255,255,255,1)  #FFFFFFFF  white
     749,218: (255,255,255,1)  #FFFFFFFF  white
     750,218: (241,241,241,1)  #F1F1F1FF  srgba(241,241,241,1)
    -751,218: (196,196,196,1)  #C4C4C4FF  grey77
    +751,218: (197,197,197,1)  #C5C5C5FF  srgba(197,197,197,1)
     752,218: (217,217,217,1)  #D9D9D9FF  grey85
     753,218: (255,255,255,1)  #FFFFFFFF  white
     754,218: (255,255,255,1)  #FFFFFFFF  white
    @@ -416983,7 +416983,7 @@
     1691,218: (255,255,255,1)  #FFFFFFFF  white
     1692,218: (255,255,255,1)  #FFFFFFFF  white
     1693,218: (218,218,218,1)  #DADADAFF  srgba(218,218,218,1)
    -1694,218: (196,196,196,1)  #C4C4C4FF  grey77
    +1694,218: (197,197,197,1)  #C5C5C5FF  srgba(197,197,197,1)
     1695,218: (241,241,241,1)  #F1F1F1FF  srgba(241,241,241,1)
     1696,218: (255,255,255,1)  #FFFFFFFF  white
     1697,218: (255,255,255,1)  #FFFFFFFF  white
    @@ -417162,7 +417162,7 @@
     1870,218: (255,255,255,1)  #FFFFFFFF  white
     1871,218: (255,255,255,1)  #FFFFFFFF  white
     1872,218: (241,241,241,1)  #F1F1F1FF  srgba(241,241,241,1)
    -1873,218: (196,196,196,1)  #C4C4C4FF  grey77
    +1873,218: (197,197,197,1)  #C5C5C5FF  srgba(197,197,197,1)
     1874,218: (217,217,217,1)  #D9D9D9FF  grey85
     1875,218: (255,255,255,1)  #FFFFFFFF  white
     1876,218: (255,255,255,1)  #FFFFFFFF  white
    
    --- old.png
    +++ new.png
    @@ -414082,7 +414082,7 @@
     695,217: (255,255,255,1)  #FFFFFFFF  white
     696,217: (255,255,255,1)  #FFFFFFFF  white
     697,217: (218,218,218,1)  #DADADAFF  srgba(218,218,218,1)
    -698,217: (184,184,184,1)  #B8B8B8FF  grey72
    +698,217: (183,183,183,1)  #B7B7B7FF  srgba(183,183,183,1)
     699,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
     700,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
     701,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
    @@ -414134,7 +414134,7 @@
     747,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
     748,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
     749,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
    -750,217: (184,184,184,1)  #B8B8B8FF  grey72
    +750,217: (183,183,183,1)  #B7B7B7FF  srgba(183,183,183,1)
     751,217: (218,218,218,1)  #DADADAFF  srgba(218,218,218,1)
     752,217: (255,255,255,1)  #FFFFFFFF  white
     753,217: (255,255,255,1)  #FFFFFFFF  white
    @@ -415079,7 +415079,7 @@
     1692,217: (255,255,255,1)  #FFFFFFFF  white
     1693,217: (255,255,255,1)  #FFFFFFFF  white
     1694,217: (218,218,218,1)  #DADADAFF  srgba(218,218,218,1)
    -1695,217: (184,184,184,1)  #B8B8B8FF  grey72
    +1695,217: (183,183,183,1)  #B7B7B7FF  srgba(183,183,183,1)
     1696,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
     1697,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
     1698,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
    @@ -415256,7 +415256,7 @@
     1869,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
     1870,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
     1871,217: (170,170,170,1)  #AAAAAAFF  srgba(170,170,170,1)
    -1872,217: (184,184,184,1)  #B8B8B8FF  grey72
    +1872,217: (183,183,183,1)  #B7B7B7FF  srgba(183,183,183,1)
     1873,217: (218,218,218,1)  #DADADAFF  srgba(218,218,218,1)
     1874,217: (255,255,255,1)  #FFFFFFFF  white
     1875,217: (255,255,255,1)  #FFFFFFFF  white
    @@ -415986,7 +415986,7 @@
     694,218: (255,255,255,1)  #FFFFFFFF  white
     695,218: (255,255,255,1)  #FFFFFFFF  white
     696,218: (218,218,218,1)  #DADADAFF  srgba(218,218,218,1)
    -697,218: (197,197,197,1)  #C5C5C5FF  srgba(197,197,197,1)
    +697,218: (196,196,196,1)  #C4C4C4FF  grey77
     698,218: (241,241,241,1)  #F1F1F1FF  srgba(241,241,241,1)
     699,218: (255,255,255,1)  #FFFFFFFF  white
     700,218: (255,255,255,1)  #FFFFFFFF  white
    @@ -416040,7 +416040,7 @@
     748,218: (255,255,255,1)  #FFFFFFFF  white
     749,218: (255,255,255,1)  #FFFFFFFF  white
     750,218: (241,241,241,1)  #F1F1F1FF  srgba(241,241,241,1)
    -751,218: (197,197,197,1)  #C5C5C5FF  srgba(197,197,197,1)
    +751,218: (196,196,196,1)  #C4C4C4FF  grey77
     752,218: (217,217,217,1)  #D9D9D9FF  grey85
     753,218: (255,255,255,1)  #FFFFFFFF  white
     754,218: (255,255,255,1)  #FFFFFFFF  white
    @@ -416983,7 +416983,7 @@
     1691,218: (255,255,255,1)  #FFFFFFFF  white
     1692,218: (255,255,255,1)  #FFFFFFFF  white
     1693,218: (218,218,218,1)  #DADADAFF  srgba(218,218,218,1)
    -1694,218: (197,197,197,1)  #C5C5C5FF  srgba(197,197,197,1)
    +1694,218: (196,196,196,1)  #C4C4C4FF  grey77
     1695,218: (241,241,241,1)  #F1F1F1FF  srgba(241,241,241,1)
     1696,218: (255,255,255,1)  #FFFFFFFF  white
     1697,218: (255,255,255,1)  #FFFFFFFF  white
    @@ -417162,7 +417162,7 @@
     1870,218: (255,255,255,1)  #FFFFFFFF  white
     1871,218: (255,255,255,1)  #FFFFFFFF  white
     1872,218: (241,241,241,1)  #F1F1F1FF  srgba(241,241,241,1)
    -1873,218: (197,197,197,1)  #C5C5C5FF  srgba(197,197,197,1)
    +1873,218: (196,196,196,1)  #C4C4C4FF  grey77
     1874,218: (217,217,217,1)  #D9D9D9FF  grey85
     1875,218: (255,255,255,1)  #FFFFFFFF  white
     1876,218: (255,255,255,1)  #FFFFFFFF  white
    

    (For the record, all this never happened [to my knowledge] before updating from 6f195b1 to 1a116ab)

  16. schloerke commented on Apr 6, 2022

    @schloerke
    CollaboratorAuthor

    Thank you for the diff outputs! They are very helpful

    (For the record, all this never happened [to my knowledge] before updating from 6f195b1 to 1a116ab)

    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. 😃

  17. removed
    question
    on Apr 6, 2022
  18. wch commented on Apr 6, 2022

    @wch
    Collaborator

    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:

    old_data[idx]
    #>  [1] 0f 82 fe 0e 81 fe e6 e6 e6 d7 d7 d7 e6 e6 e6
    
    new_data[idx]
    #>  [1] 00 7b ff 00 7b ff e7 e7 e7 d8 d8 d8 e7 e7 e7

    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.

  19. bersbersbers commented on Apr 6, 2022

    @bersbersbers
    Contributor

    @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?

  20. schloerke commented on Apr 6, 2022

    @schloerke
    CollaboratorAuthor

    @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})

  21. bersbersbers commented on Apr 6, 2022

    @bersbersbers
    Contributor
  22. schloerke commented on Apr 20, 2022

    @schloerke
    CollaboratorAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions