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

recordTest produces "subscript out of bounds" error #165

Closed
rstub opened this issue Dec 11, 2017 · 15 comments
Closed

recordTest produces "subscript out of bounds" error #165

rstub opened this issue Dec 11, 2017 · 15 comments

Comments

@rstub
Copy link
Member

rstub commented Dec 11, 2017

When I run recordTest() for an example shiny application I get the following error:

shinytest::recordTest("~/devel/shiny_showcase/shiny_dashboard/")
#> No encoding supplied: defaulting to UTF-8.
#> Error in cont[["value"]]: subscript out of bounds

I am using ce89ac0.

@wch
Copy link
Collaborator

wch commented Dec 11, 2017

Can you provide the output of devtools::session_info(). Does this happen with any other applications?

@rstub
Copy link
Member Author

rstub commented Dec 11, 2017

Here you are. I have tried several shiny apps and they all show this error:

devtools::session_info()
#> Session info -------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.4.3 (2017-11-30)
#>  system   x86_64, linux-gnu           
#>  ui       X11                         
#>  language (EN)                        
#>  collate  C.UTF-8                     
#>  tz       Europe/Berlin               
#>  date     2017-12-11
#> Packages -----------------------------------------------------------------
#>  package    * version    date       source                                
#>  assertthat   0.2.0      2017-04-11 CRAN (R 3.4.2)                        
#>  backports    1.1.1      2017-09-25 CRAN (R 3.4.2)                        
#>  base       * 3.4.3      2017-12-07 local                                 
#>  base64enc    0.1-3      2015-07-28 CRAN (R 3.4.2)                        
#>  compiler     3.4.3      2017-12-07 local                                 
#>  crayon       1.3.4      2017-09-16 CRAN (R 3.4.2)                        
#>  curl         3.0        2017-10-06 CRAN (R 3.4.2)                        
#>  datasets   * 3.4.3      2017-12-07 local                                 
#>  debugme      1.1.0.9000 2017-12-11 Github (gaborcsardi/debugme@f4a116a)  
#>  devtools     1.13.4     2017-11-09 CRAN (R 3.4.2)                        
#>  digest       0.6.12     2017-01-27 CRAN (R 3.4.2)                        
#>  evaluate     0.10.1     2017-06-24 CRAN (R 3.4.2)                        
#>  graphics   * 3.4.3      2017-12-07 local                                 
#>  grDevices  * 3.4.3      2017-12-07 local                                 
#>  htmltools    0.3.6      2017-04-28 CRAN (R 3.4.2)                        
#>  httpuv       1.3.5      2017-07-04 CRAN (R 3.4.2)                        
#>  httr         1.3.1      2017-08-20 CRAN (R 3.4.2)                        
#>  jsonlite     1.5        2017-06-01 CRAN (R 3.4.2)                        
#>  knitr        1.17       2017-08-10 CRAN (R 3.4.2)                        
#>  magrittr     1.5        2014-11-22 CRAN (R 3.4.2)                        
#>  memoise      1.1.0      2017-04-21 CRAN (R 3.4.2)                        
#>  methods    * 3.4.3      2017-12-07 local                                 
#>  mime         0.5        2016-07-07 CRAN (R 3.4.2)                        
#>  parsedate    1.1.3      2017-03-02 CRAN (R 3.4.3)                        
#>  pingr        1.1.2      2017-03-02 CRAN (R 3.4.3)                        
#>  png          0.1-7      2013-12-03 CRAN (R 3.4.2)                        
#>  processx     3.0.1      2017-12-11 Github (r-lib/processx@709a4bd)       
#>  R6           2.2.2      2017-06-17 CRAN (R 3.4.2)                        
#>  Rcpp         0.12.14    2017-11-23 CRAN (R 3.4.2)                        
#>  rematch      1.0.1      2016-04-21 CRAN (R 3.4.2)                        
#>  rmarkdown    1.8.3      2017-12-11 Github (rstudio/rmarkdown@07f7d8e)    
#>  rprojroot    1.2        2017-01-16 CRAN (R 3.4.2)                        
#>  shiny        1.0.5      2017-08-23 CRAN (R 3.4.2)                        
#>  shinytest    1.2.0.9001 2017-12-11 Github (rstudio/shinytest@ce89ac0)    
#>  showimage    1.0.0      2017-12-11 Github (MangoTheCat/showimage@d9000f0)
#>  stats      * 3.4.3      2017-12-07 local                                 
#>  stringi      1.1.6      2017-11-17 CRAN (R 3.4.2)                        
#>  stringr      1.2.0      2017-02-18 CRAN (R 3.4.2)                        
#>  testthat     1.0.2      2016-04-23 CRAN (R 3.4.2)                        
#>  tools        3.4.3      2017-12-07 local                                 
#>  utils      * 3.4.3      2017-12-07 local                                 
#>  webdriver    1.0.2.9002 2017-12-11 Github (rstudio/webdriver@2ccad63)    
#>  withr        2.1.0      2017-11-01 CRAN (R 3.4.2)                        
#>  xtable       1.8-2      2016-02-05 CRAN (R 3.4.2)                        
#>  yaml         2.1.15     2017-12-01 CRAN (R 3.4.3)

@wch
Copy link
Collaborator

wch commented Dec 11, 2017

Hm, what version of phantomJS do you have installed? You can find out with:

system2(webdriver:::find_phantom(), args ="--version")

@rstub
Copy link
Member Author

rstub commented Dec 12, 2017

The one from Debian stretch (stable):

system2(webdriver:::find_phantom(), args ="--version")
#> 2.1.1

@prubin73
Copy link

prubin73 commented Jan 6, 2018

Same problem here (Linux Mint 18.3, shinytest 1.2.0.900, phantomJS 2.1.1).

  Session info --------------------------------------------------------------
   setting  value                       
   version  R version 3.4.3 (2017-11-30)
   system   x86_64, linux-gnu           
   ui       RStudio (1.1.383)           
   language (EN)                        
   collate  en_US.UTF-8                 
   tz       posixrules                  
   date     2018-01-06                  
  
  Packages ------------------------------------------------------------------
   package    * version    date       source                                
   assertthat   0.2.0      2017-04-11 CRAN (R 3.4.0)                        
   base       * 3.4.3      2017-12-01 local                                 
   base64enc    0.1-3      2015-07-28 CRAN (R 3.4.0)                        
   compiler     3.4.3      2017-12-01 local                                 
   crayon       1.3.4      2017-09-16 CRAN (R 3.4.2)                        
   curl         3.1        2017-12-12 CRAN (R 3.4.3)                        
   datasets   * 3.4.3      2017-12-01 local                                 
   debugme      1.1.0.9000 2018-01-03 Github (gaborcsardi/debugme@f4a116a)  
   devtools     1.13.4     2017-11-09 CRAN (R 3.4.2)                        
   digest       0.6.13     2017-12-14 CRAN (R 3.4.3)                        
   graphics   * 3.4.3      2017-12-01 local                                 
   grDevices  * 3.4.3      2017-12-01 local                                 
   htmltools    0.3.6      2017-04-28 CRAN (R 3.4.0)                        
   httpuv       1.3.5      2017-07-04 CRAN (R 3.4.1)                        
   httr         1.3.1      2017-08-20 CRAN (R 3.4.1)                        
   jsonlite     1.5        2017-06-01 CRAN (R 3.4.0)                        
   magrittr     1.5        2014-11-22 CRAN (R 3.4.0)                        
   memoise      1.1.0      2017-04-21 CRAN (R 3.4.0)                        
   methods    * 3.4.3      2017-12-01 local                                 
   mime         0.5        2016-07-07 CRAN (R 3.4.0)                        
   parsedate    1.1.3      2017-03-02 cran (@1.1.3)                         
   pingr        1.1.2      2017-03-02 cran (@1.1.2)                         
   png          0.1-7      2013-12-03 cran (@0.1-7)                         
   processx     3.0.3      2018-01-03 Github (r-lib/processx@adac837)       
   R6           2.2.2      2017-06-17 CRAN (R 3.4.0)                        
   Rcpp         0.12.14    2017-11-23 CRAN (R 3.4.2)                        
   rematch      1.0.1      2016-04-21 CRAN (R 3.4.0)                        
   rlang        0.1.6      2017-12-21 CRAN (R 3.4.3)                        
   rstudioapi   0.7        2017-09-07 CRAN (R 3.4.1)                        
   shiny        1.0.5      2017-08-23 CRAN (R 3.4.1)                        
   shinytest  * 1.2.0.9001 2018-01-06 Github (rstudio/shinytest@ce89ac0)    
   showimage    1.0.0      2018-01-03 Github (MangoTheCat/showimage@d9000f0)
   stats      * 3.4.3      2017-12-01 local                                 
   testthat     2.0.0      2017-12-13 cran (@2.0.0)                         
   tools        3.4.3      2017-12-01 local                                 
   utils      * 3.4.3      2017-12-01 local                                 
   webdriver    1.0.2.9002 2018-01-03 Github (rstudio/webdriver@2ccad63)    
   withr        2.1.1      2017-12-19 CRAN (R 3.4.3)                        
   xtable       1.8-2      2016-02-05 CRAN (R 3.4.0)                        
   yaml         2.1.16     2017-12-12 CRAN (R 3.4.3)    

@rstub
Copy link
Member Author

rstub commented Feb 12, 2018

Is there anything we can do to debug this issue? I have tried to reproduce it using a Docker image:

FROM rocker/rstudio

RUN apt-get update \
 && apt-get install --yes --no-install-recommends libpng-dev phantomjs \
 && install2.r remotes \
 && Rscript -e "remotes::install_github('rstudio/shinytest')" \
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/* \
 && rm -rf /tmp/*

However, I am getting the error

> shinytest::recordTest(system.file("examples", "01_hello", package = "shiny"))
Error in process_get_error_connection(self, private) : 
  stderr is not a pipe.

when I try to run shinytest inside the Docker container.

@wch
Copy link
Collaborator

wch commented Feb 12, 2018

@rstub I've pushed a fix to the webdriver package so that it correctly reports errors in starting up PhantomJS. Now it shows this when I try it in your Docker container:

> shinytest::recordTest(system.file("examples", "01_hello", package = "shiny"))
Error in run_phantomjs(timeout = timeout) : 
  Failed to start phantomjs. Error: QXcbConnection: Could not connect to displayPhantomJS has crashed. Please read the bug reporting guide at<http://phantomjs.org/bug-reporting.html> and file a bug report.

The problem seems to be related to something specific about the version of phantomjs that comes with Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=817277

Running phantomjs from the command line gives the above error, but the following works fine.

QT_QPA_PLATFORM=offscreen phantomjs

I'll add a workaround for this issue.

@wch
Copy link
Collaborator

wch commented Feb 12, 2018

@rstub I've added a workaround for your issue in rstudio/webdriver@b66d9bc.

@rstub
Copy link
Member Author

rstub commented Feb 13, 2018

I have rebuild my Docker image and am now getting the same error there as I am getting on my local machine:

shinytest::recordTest(system.file("examples", "01_hello", package = "shiny"))
#> No encoding supplied: defaulting to UTF-8.
#> Error in cont[["value"]]: subscript out of bounds
Session info
devtools::session_info()
#> Session info -------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.4.3 (2017-11-30)
#>  system   x86_64, linux-gnu           
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  tz       UTC                         
#>  date     2018-02-13
#> Packages -----------------------------------------------------------------
#>  package    * version    date       source                              
#>  assertthat   0.2.0      2017-04-11 CRAN (R 3.4.3)                      
#>  backports    1.1.2      2017-12-13 CRAN (R 3.4.3)                      
#>  base       * 3.4.3      2018-02-12 local                               
#>  base64enc    0.1-3      2015-07-28 CRAN (R 3.4.3)                      
#>  callr        2.0.2      2018-02-11 CRAN (R 3.4.3)                      
#>  compiler     3.4.3      2018-02-12 local                               
#>  crayon       1.3.4      2017-09-16 CRAN (R 3.4.3)                      
#>  curl         3.1        2017-12-12 CRAN (R 3.4.3)                      
#>  datasets   * 3.4.3      2018-02-12 local                               
#>  debugme      1.1.0.9000 2018-02-13 Github (gaborcsardi/debugme@f4a116a)
#>  devtools     1.13.4     2017-11-09 CRAN (R 3.4.3)                      
#>  digest       0.6.15     2018-01-28 CRAN (R 3.4.3)                      
#>  evaluate     0.10.1     2017-06-24 CRAN (R 3.4.3)                      
#>  graphics   * 3.4.3      2018-02-12 local                               
#>  grDevices  * 3.4.3      2018-02-12 local                               
#>  htmltools    0.3.6      2017-04-28 CRAN (R 3.4.3)                      
#>  httpuv       1.3.5      2017-07-04 CRAN (R 3.4.3)                      
#>  httr         1.3.1      2017-08-20 CRAN (R 3.4.3)                      
#>  jsonlite     1.5        2017-06-01 CRAN (R 3.4.3)                      
#>  knitr        1.19       2018-01-29 CRAN (R 3.4.3)                      
#>  magrittr     1.5        2014-11-22 CRAN (R 3.4.3)                      
#>  memoise      1.1.0      2017-04-21 CRAN (R 3.4.3)                      
#>  methods    * 3.4.3      2018-02-12 local                               
#>  mime         0.5        2016-07-07 CRAN (R 3.4.3)                      
#>  parsedate    1.1.3      2017-03-02 CRAN (R 3.4.3)                      
#>  pingr        1.1.2      2017-03-02 CRAN (R 3.4.3)                      
#>  png          0.1-7      2013-12-03 CRAN (R 3.4.3)                      
#>  R6           2.2.2      2017-06-17 CRAN (R 3.4.3)                      
#>  Rcpp         0.12.15    2018-01-20 CRAN (R 3.4.3)                      
#>  rematch      1.0.1      2016-04-21 CRAN (R 3.4.3)                      
#>  rlang        0.1.6      2017-12-21 CRAN (R 3.4.3)                      
#>  rmarkdown    1.8.10     2018-02-13 Github (rstudio/rmarkdown@b49b7eb)  
#>  rprojroot    1.3-2      2018-01-03 CRAN (R 3.4.3)                      
#>  shiny        1.0.5      2017-08-23 CRAN (R 3.4.3)                      
#>  shinytest    1.2.0.9001 2018-02-13 Github (rstudio/shinytest@1f0698c)  
#>  showimage    1.0.0      2018-01-24 CRAN (R 3.4.3)                      
#>  stats      * 3.4.3      2018-02-12 local                               
#>  stringi      1.1.6      2017-11-17 CRAN (R 3.4.3)                      
#>  stringr      1.2.0      2017-02-18 CRAN (R 3.4.3)                      
#>  testthat     2.0.0      2017-12-13 CRAN (R 3.4.3)                      
#>  tools        3.4.3      2018-02-12 local                               
#>  utils      * 3.4.3      2018-02-12 local                               
#>  webdriver    1.0.4.9000 2018-02-13 Github (rstudio/webdriver@b66d9bc)  
#>  withr        2.1.1      2017-12-19 CRAN (R 3.4.3)                      
#>  xtable       1.8-2      2016-02-05 CRAN (R 3.4.3)                      
#>  yaml         2.1.16     2017-12-12 CRAN (R 3.4.3)

Both QT_QPA_PLATFORM=offscreen phantomjs and phantomjs --platform offscreen run fine within the docker image.

@wch
Copy link
Collaborator

wch commented Feb 13, 2018

I've made another fix to webdriver so that it correctly grabs the error message. This is what it says now when I rebuild your Docker container:

Error in session_makeRequest(self, private, endpoint, data, params, headers) : 
  Error - Unable to load Atom 'execute_script' from file ':/ghostdriver/./third_party/webdriver-atoms/execute_script.js'

The problem is that the version of PhantomJS that is in the Debian repos isn't complete -- it doesn't include ghostdriver. See:
https://stackoverflow.com/questions/36770303/unable-to-load-atom-find-element
https://github.com/detro/ghostdriver/issues/473

The build of phantomjs that you get with webdriver::install_phantomjs() does include these components. I'll try to get it to automatically detect if the components are needed, and if so, prompt to run webdriver::install_phantomjs().

@rstub
Copy link
Member Author

rstub commented Feb 14, 2018

Thanks a lot! With webdriver::install_phantomjs() it now works both locally and in Docker:

FROM rocker/rstudio

RUN apt-get update \
 && apt-get install --yes --no-install-recommends bzip2 libpng-dev \
 && install2.r remotes \
 && installGithub.r 'rstudio/shinytest' \
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/* \
 && rm -rf /tmp/*

USER rstudio
RUN Rscript -e "webdriver::install_phantomjs()"
USER root

@prubin73 Does that solve the issue on your side as well?

@wch
Copy link
Collaborator

wch commented Feb 14, 2018

I've added the check and a more useful error message in rstudio/webdriver@52facdb. I'm glad it works for you!

@wch wch closed this as completed Feb 14, 2018
@rstub
Copy link
Member Author

rstub commented Feb 15, 2018

For reference, the issue in Debian is already know: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=860485

@prubin73
Copy link

Confirming that the fix works for me as well.

@wch
Copy link
Collaborator

wch commented Feb 20, 2018

Good to hear!

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