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

memomize leaflet(2.0.3) on shiny got Couldn't normalize path in addResourcePath #664

Closed
cywhale opened this issue Feb 3, 2020 · 2 comments

Comments

@cywhale
Copy link

cywhale commented Feb 3, 2020

leaflet 2.0.2 works on shiny-server, but when I upgrade to 2.0.3 got this error message:
Warning: Error in value[[3L]]: Couldn't normalize path in addResourcePath, with arguments: prefix = 'leaflet-providers-1.9.0'; directoryPath = '/tmp/RtmpMiDSq7'

I try to memoise leaflet map with points by R.cache and load cache then. Here I wrote a smaller example to reproduce this error (please change file name to app.R). It also works for leaflet 2.0.2 but got the same message for 2.0.3.

https://github.com/cywhale/ODB/blob/master/shiny_memoised_cache/app_test_leaflet_vers01.R

The first time running this app.R (i.e. save cache) should be ok.
But when starting a new session (or Restart R on Rstudio) and re-run this app.R (i.e. load cache) on shiny-server or Rstudio, got the aboving error. Not sure, but it seems that shiny or leaflet 2.0.3 will store some leaflet-providers-1.9.0 information in temporary fille ('/tmp/Rtmpxxxx'). After that (new session or maybe this Rtmpxxxx being cleared), loading cache got errors.

I also put it on my server, after cleaning cached data manually by me, and then can re-run it.
https://bio.odb.ntu.edu.tw/sample-apps/leaflet1/

The log file on /var/log/shiny-server (with whole message log)
https://github.com/cywhale/ODB/blob/master/shiny_memoised_cache/app_test_leaflet_vers_shinyserver.log

sessionInfo()

> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.6 LTS

Matrix products: default
BLAS/LAPACK: /opt/openblas/lib/libopenblas_nehalemp-r0.3.0.dev.so

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

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

other attached packages:
[1] magrittr_1.5   mapedit_0.5.0  mapview_2.7.0  leaflet_2.0.2  sf_0.8-0      
[6] R.cache_0.14.0 shiny_1.4.0   

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3         compiler_3.4.4     later_1.0.0        R.methodsS3_1.7.1 
 [5] R.utils_2.9.2      base64enc_0.1-3    class_7.3-14       tools_3.4.4       
 [9] digest_0.6.23      viridisLite_0.3.0  lifecycle_0.1.0    satellite_1.0.2   
[13] lattice_0.20-38    png_0.1-7          rlang_0.4.2        DBI_1.1.0         
[17] crosstalk_1.0.0    fastmap_1.0.1      e1071_1.7-3        raster_3.0-7      
[21] htmlwidgets_1.5.1  webshot_0.5.2      classInt_0.4-2     stats4_3.4.4      
[25] grid_3.4.4         R6_2.4.1           sp_1.3-2           scales_1.1.0      
[29] promises_1.1.0     codetools_0.2-15   htmltools_0.4.0    units_0.6-5       
[33] colorspace_1.4-1   mime_0.8           xtable_1.8-4       httpuv_1.5.2.9000 
[37] KernSmooth_2.23-15 munsell_0.5.0      R.oo_1.23.0    
@jcheng5
Copy link
Member

jcheng5 commented Feb 3, 2020

I would definitely encourage you not to persist leaflet objects this way! They're not designed for it, and we don't guarantee (or even attempt to maintain) backward compatibility of serialized leaflet objects.

Would it be possible to cache just the data itself, and turn it into a leaflet object only at runtime? If I'm understanding this code correctly, the difference in performance should be minimal, as I'd expect leaflet() %>% addProviderTiles() %>% setView() to be nearly instantaneous regardless of data.

@cywhale
Copy link
Author

cywhale commented Feb 3, 2020

In my original code, I also cache my data points along with leaflet map. But for your point of view about backward compatibility, I'll follow your suggestion. Thanks for the information.

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

2 participants