rstudio / shiny

Easy interactive web applications with R
https://shiny.posit.co/
Other
5.37k stars 1.86k forks source link

Unicode characters display correctly in ggplot when ShinyApp runs locally, but not on shinyapps.io or in docker container #3759

Open dkori opened 1 year ago

dkori commented 1 year ago

System details

Browser Version:

Output of sessionInfo() when run locally):

R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 21

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_3.3.5 tidyr_1.2.1   shiny_1.7.3  

loaded via a namespace (and not attached):
 [1] tidyselect_1.2.0  xfun_0.34         bslib_0.4.0       purrr_0.3.5       colorspace_2.0-2  vctrs_0.5.0      
 [7] generics_0.1.3    htmltools_0.5.3   utf8_1.2.2        rlang_1.0.6       jquerylib_0.1.4   later_1.3.0      
[13] pillar_1.8.1      glue_1.6.2        withr_2.5.0       DBI_1.1.2         rappdirs_0.3.3    lifecycle_1.0.3  
[19] stringr_1.4.1     munsell_0.5.0     gtable_0.3.0      ragg_1.2.1        memoise_2.0.1     labeling_0.4.2   
[25] knitr_1.40        fastmap_1.1.0     httpuv_1.6.6      curl_4.3.2        fansi_1.0.3       Rcpp_1.0.8       
[31] xtable_1.8-4      openssl_2.0.4     promises_1.2.0.1  scales_1.1.1      cachem_1.0.6      jsonlite_1.8.3   
[37] mime_0.12         farver_2.1.0      systemfonts_1.0.4 textshaping_0.3.6 askpass_1.1       digest_0.6.30    
[43] stringi_1.7.8     dplyr_1.0.10      icons_0.2.0       grid_4.1.2        cli_3.4.1         tools_4.1.2      
[49] magrittr_2.0.3    sass_0.4.2        tibble_3.1.8      pkgconfig_2.0.3   ellipsis_0.3.2    rsconnect_0.8.28 
[55] assertthat_0.2.1  rstudioapi_0.14   R6_2.5.1          compiler_4.1.2   

Session info when running on shinyapps.io:

R version 4.1.2 (2021-11-01)
2022-12-16T03:09:24.539123+00:00 shinyapps[7889593]: Platform: x86_64-pc-linux-gnu (64-bit)
2022-12-16T03:09:24.539127+00:00 shinyapps[7889593]: Running under: Ubuntu 20.04.5 LTS
2022-12-16T03:09:24.539133+00:00 shinyapps[7889593]: Matrix products: default
2022-12-16T03:09:24.539136+00:00 shinyapps[7889593]: BLAS:   /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
2022-12-16T03:09:24.539139+00:00 shinyapps[7889593]: LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3
2022-12-16T03:09:24.539153+00:00 shinyapps[7889593]: locale:
2022-12-16T03:09:24.539177+00:00 shinyapps[7889593]:  [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
2022-12-16T03:09:24.539196+00:00 shinyapps[7889593]:  [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
2022-12-16T03:09:24.539202+00:00 shinyapps[7889593]:  [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
2022-12-16T03:09:24.539223+00:00 shinyapps[7889593]: [10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   
2022-12-16T03:09:24.539233+00:00 shinyapps[7889593]: attached base packages:
2022-12-16T03:09:24.539257+00:00 shinyapps[7889593]: [1] stats     graphics  grDevices utils     datasets  methods   base     
2022-12-16T03:09:24.539265+00:00 shinyapps[7889593]: other attached packages:
2022-12-16T03:09:24.539309+00:00 shinyapps[7889593]: [1] ggplot2_3.3.5 tidyr_1.2.1   shiny_1.7.3  
2022-12-16T03:09:24.539333+00:00 shinyapps[7889593]: loaded via a namespace (and not attached):
2022-12-16T03:09:24.539553+00:00 shinyapps[7889593]:  [1] Rcpp_1.0.8       magrittr_2.0.3   munsell_0.5.0    tidyselect_1.2.0
2022-12-16T03:09:24.539561+00:00 shinyapps[7889593]:  [5] colorspace_2.0-2 xtable_1.8-4     R6_2.5.1         rlang_1.0.6     
2022-12-16T03:09:24.539564+00:00 shinyapps[7889593]:  [9] fastmap_1.1.0    fansi_1.0.3      dplyr_1.0.10     tools_4.1.2     
2022-12-16T03:09:24.539582+00:00 shinyapps[7889593]: [13] grid_4.1.2       gtable_0.3.0     utf8_1.2.2       cli_3.4.1       
2022-12-16T03:09:24.539589+00:00 shinyapps[7889593]: [17] withr_2.5.0      htmltools_0.5.3  ellipsis_0.3.2   digest_0.6.30   
2022-12-16T03:09:24.539593+00:00 shinyapps[7889593]: [21] tibble_3.1.8     lifecycle_1.0.3  purrr_0.3.5      later_1.3.0     
2022-12-16T03:09:24.539609+00:00 shinyapps[7889593]: [25] vctrs_0.5.0      promises_1.2.0.1 glue_1.6.2       mime_0.12       
2022-12-16T03:09:24.539614+00:00 shinyapps[7889593]: [29] compiler_4.1.2   pillar_1.8.1     scales_1.1.1     generics_0.1.3  
2022-12-16T03:09:24.539620+00:00 shinyapps[7889593]: [33] httpuv_1.6.6     pkgconfig_2.0.3 
2022-12-16T03:09:24.615414+00:00 shinyapps[7889593]: Listening on http://127.0.0.1:44319

Output of SessionInfo() when run in docker container:

R version 4.2.2 (2022-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.1 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_3.4.0 tidyr_1.2.1   shiny_1.7.3  

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9       pillar_1.8.1     compiler_4.2.2   later_1.3.0     
 [5] tools_4.2.2      digest_0.6.30    lifecycle_1.0.3  tibble_3.1.8    
 [9] gtable_0.3.1     pkgconfig_2.0.3  rlang_1.0.6      cli_3.4.1       
[13] DBI_1.1.3        fastmap_1.1.0    withr_2.5.0      dplyr_1.0.10    
[17] generics_0.1.3   vctrs_0.5.0      grid_4.2.2       tidyselect_1.2.0
[21] glue_1.6.2       R6_2.5.1         fansi_1.0.3      purrr_0.3.5     
[25] magrittr_2.0.3   scales_1.2.1     promises_1.2.0.1 ellipsis_0.3.2  
[29] htmltools_0.5.3  assertthat_0.2.1 mime_0.12        xtable_1.8-4    
[33] colorspace_2.0-3 httpuv_1.6.6     utf8_1.2.2       munsell_0.5.0 

Example application or steps to reproduce the problem

Code that displays correctly when run on my local machine, but fails when run on shinyapps.io or from a docker container ```R library(shiny) library(tidyr) library(ggplot2) print(sessionInfo()) ui<-fluidPage(plotOutput("plot"), plotOutput("plot2")) server <- function(input, output, session) { df<-data.frame(x=0:10, y=0:10) # plot using unicode symbols as shapes output$plot<-renderPlot({ df%>% ggplot()+ geom_point(aes(x=x,y=y),shape="\U0001F37C",size=20)+ scale_shape_manual(values="\U0001F37C")+ labs(title="using geom_point shapes") }) # plot using built in ggplot shapes output$plot2<-renderPlot({ df%>% ggplot()+ geom_text(aes(x=x,y=y),label="\U0001F37C",size=20, family = "Lucida Sans Unicode")+ labs(title="using geom_text with font specified in family") }) } shinyApp(ui, server) ``` Example dockerfile for building the app that's also failing: ``` # get shiny server and R from the rocker project FROM rocker/shiny-verse RUN apt-get update && apt-get install -y \ libcurl4-gnutls-dev \ libssl-dev RUN apt-get install -y locales locales-all ENV LC_ALL en_US.UTF-8 ENV LANG en_US.UTF-8 ENV LANGUAGE en_US.UTF-8 RUN R -e 'install.packages(c(\ "shiny", \ "tidyr", \ "ggplot2"\ ))' # copy all files into a directory called app COPY . /app CMD ["R", "-e", "shiny::runApp('/app', host = '0.0.0.0', port = 5050)"] ``` ### Describe the problem in detail The code example above runs and displays fine when I run the shinyapp on my local machine, but the unicode shapes do not display in the plot either when I deploy the app to shinyapps.io, or when I build the app into a docker container and run it from the container. I believe unicode display issues usually have to do with the font so I tried specifying a font in geom_text, but it still doesn't work. How it looks in browser when I run the app locally: ![working_local](https://user-images.githubusercontent.com/10734057/208014540-a5147eac-1390-41bd-bd2a-aa5bcbae9ce4.png) How it looks when I run the app on shinyapps.io and open the link in the same browser: ![failing_shinyio](https://user-images.githubusercontent.com/10734057/208015693-4f8019e2-619e-4186-a304-62eee9ae7715.png) When I containerize the app with docker, the display looks the same as it does on shinyapps.io (square icons instead of the correct icons) if I import from `rocker/shiny`, and it doesn't display any icons at all if I import from `rocker/shiny-verse`. I'm sorry if this isn't the right place to post this issue, I'm at a total loss as to what the issue could be so I wasn't sure if I should create this with rocker, ggplot, here, or somewhere else.
cpsievert commented 1 year ago

Try adding library(ragg) to your app and redeploying

dkori commented 1 year ago

Try adding library(ragg) to your app and redeploying

Tried this, now I'm seeing empty rectangles instead of the ones with numbers in them, but still not the correct symbols. with_ragg

Session info on shinyapps.io after adding ragg:

2022-12-16T05:13:07.414539+00:00 shinyapps[7889593]: R version 4.1.2 (2021-11-01)
2022-12-16T05:13:07.414563+00:00 shinyapps[7889593]: Platform: x86_64-pc-linux-gnu (64-bit)
2022-12-16T05:13:07.414568+00:00 shinyapps[7889593]: Running under: Ubuntu 20.04.5 LTS
2022-12-16T05:13:07.414576+00:00 shinyapps[7889593]: Matrix products: default
2022-12-16T05:13:07.414581+00:00 shinyapps[7889593]: BLAS:   /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
2022-12-16T05:13:07.414587+00:00 shinyapps[7889593]: LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3
2022-12-16T05:13:07.414605+00:00 shinyapps[7889593]: locale:
2022-12-16T05:13:07.414608+00:00 shinyapps[7889593]:  [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
2022-12-16T05:13:07.414611+00:00 shinyapps[7889593]:  [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
2022-12-16T05:13:07.414614+00:00 shinyapps[7889593]:  [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
2022-12-16T05:13:07.414648+00:00 shinyapps[7889593]: [10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   
2022-12-16T05:13:07.414689+00:00 shinyapps[7889593]: attached base packages:
2022-12-16T05:13:07.414694+00:00 shinyapps[7889593]: [1] stats     graphics  grDevices utils     datasets  methods   base     
2022-12-16T05:13:07.414723+00:00 shinyapps[7889593]: other attached packages:
2022-12-16T05:13:07.414759+00:00 shinyapps[7889593]: [1] ragg_1.2.1    ggplot2_3.3.5 tidyr_1.2.1   shiny_1.7.3  
2022-12-16T05:13:07.414785+00:00 shinyapps[7889593]: loaded via a namespace (and not attached):
2022-12-16T05:13:07.415025+00:00 shinyapps[7889593]:  [1] Rcpp_1.0.8        pillar_1.8.1      compiler_4.1.2    later_1.3.0      
2022-12-16T05:13:07.415036+00:00 shinyapps[7889593]:  [5] tools_4.1.2       digest_0.6.30     lifecycle_1.0.3   tibble_3.1.8     
2022-12-16T05:13:07.415061+00:00 shinyapps[7889593]:  [9] gtable_0.3.0      pkgconfig_2.0.3   rlang_1.0.6       cli_3.4.1        
2022-12-16T05:13:07.415067+00:00 shinyapps[7889593]: [13] fastmap_1.1.0     withr_2.5.0       dplyr_1.0.10      generics_0.1.3   
2022-12-16T05:13:07.415093+00:00 shinyapps[7889593]: [17] vctrs_0.5.0       systemfonts_1.0.4 grid_4.1.2        tidyselect_1.2.0 
2022-12-16T05:13:07.415100+00:00 shinyapps[7889593]: [21] glue_1.6.2        R6_2.5.1          textshaping_0.3.6 fansi_1.0.3      
2022-12-16T05:13:07.415124+00:00 shinyapps[7889593]: [25] purrr_0.3.5       magrittr_2.0.3    scales_1.1.1      promises_1.2.0.1 
2022-12-16T05:13:07.415135+00:00 shinyapps[7889593]: [29] ellipsis_0.3.2    htmltools_0.5.3   mime_0.12         xtable_1.8-4     
2022-12-16T05:13:07.415147+00:00 shinyapps[7889593]: [33] colorspace_2.0-2  httpuv_1.6.6      utf8_1.2.2        munsell_0.5.0    
2022-12-16T05:13:07.460982+00:00 shinyapps[7889593]: Listening on http://127.0.0.1:40591