Rendering Multiple Leaflet Maps on Single tabPanel Crashes Shiny App

805 views
Skip to first unread message

Ashish Kulshrestha

unread,
Jun 8, 2016, 3:18:45 PM6/8/16
to Shiny - Web Framework for R
Hi All,
I am trying to render multiple leaflet plot on on tab panel of my shiny app and that is causing the app/R studio) to crash. 

Individually each of the leaflet plot is rendered correctly (i.e., displaying only one at a time) but not when I try all of them together.

I am doing something like this (map1, map2 and all are leaflet maps) 

tabPanel("Leaflet Maps",
               leafletOutput
("map1", width = 800, height = 500), br(),
               leafletOutput
("map2", width = 800, height = 500), br().
               leafletOutput
("map3", width = 800, height = 500), br(),
               leafletOutput
("map4", width = 800, height = 500), br(),
               leafletOutput
("map5", width = 800, height = 500)
             
)
...
...
...

output$map1<- renderLeaflet({
   
... lines of code creating leaflet map
})


Has anyone faced this problem before or know what it is I could be doing wrong? I will provide more code snippet from my app if needed. 

Any help you can provide would be much appreciated. 

Thanks,
AK

Joe Cheng

unread,
Jun 8, 2016, 6:02:54 PM6/8/16
to Ashish Kulshrestha, Shiny - Web Framework for R
A reproducible sample would be great, as well as a detailed description of what precisely you mean by "crash".

Thanks!

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/23222305-9dca-490c-b495-cdc624211031%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ashish Kulshrestha

unread,
Jun 8, 2016, 7:00:10 PM6/8/16
to Shiny - Web Framework for R, ashish.ku...@gmail.com
Rstudio crashes if I run the app from there (Rstudio has stopped working..., see attached)
Browser (chrome) crashes when I start the app in the browser (see attached)

I can try to create a reproducible sample. I will work on isolating the required code from my app and create a sample shiny app with required inputs. 

Ashish

Ashish Kulshrestha

unread,
Jun 8, 2016, 7:48:59 PM6/8/16
to Shiny - Web Framework for R, ashish.ku...@gmail.com
Hi Joe,
Here is the link (https://drive.google.com/open?id=0Byn3NtvHyj_JT3ZRM3JzSlhXTlE) to get sample app that tries to render multiple leaflet plots. I've also included the required input data.

Thanks,
Ashish

Ashish Kulshrestha

unread,
Jun 10, 2016, 1:39:40 AM6/10/16
to Shiny - Web Framework for R, ashish.ku...@gmail.com
Any help guys? I am really stuck with issue and don't know what to do.

Thanks,
Ashish
Message has been deleted

Joe Cheng

unread,
Jun 15, 2016, 3:42:22 PM6/15/16
to Ashish Kulshrestha, Shiny - Web Framework for R
It looks to me like the browser is simply choking when trying to digest so much data. Can you separate the maps onto different tabs or something?

On Wed, Jun 15, 2016 at 12:24 PM Ashish Kulshrestha <ashish.ku...@gmail.com> wrote:
Still looking for help on this. Anyone?

Thanks.

Ashish Kulshrestha

unread,
Jun 15, 2016, 8:26:55 PM6/15/16
to Joe Cheng, Shiny - Web Framework for R
hmm.. OK, thanks! I am going to try and plot them in separate tabs and see how it goes. 

Thanks again for replying, 
Ashish

Ashish Kulshrestha

unread,
Jun 16, 2016, 1:48:26 PM6/16/16
to Shiny - Web Framework for R, j...@rstudio.com
I tried the maps onto different tabs (one leaflet on one tab) but I still have the same crash problem!! I don't think its about plotting the maps in same tab or different tabs.

Joe, you are right that the browser is probably choking when digesting so much data but what I don't understand is that if I start the shiny application from Rstudio (not in the browser), rstudio also crashes, so there must be something else (in Shiny, Leaflet, HtmlWidgets etc) that's causing this. The browser/app is crashing after plotting 2 (sometimes 3) leaflet maps. 

I am plotting 7 plots and each of them (map object) is about 60-70 MB. Is there a total max limit or something?

I am not able to find a work-around for this problem. I don't want to go to the client and say that I chose Shiny to build this application but now there is an issue and Shiny can't plot all the maps you need :(

Ashish
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discuss+unsubscribe@googlegroups.com.

Joe Cheng

unread,
Jun 16, 2016, 2:34:59 PM6/16/16
to Ashish Kulshrestha, Shiny - Web Framework for R
Shiny should not actually plot any maps that aren't on a visible tab. Do you get the crash right away or only after you click through a bunch of the tabs?

(RStudio itself is actually just a browser, basically; we disguise it as a desktop app. If you load web content into RStudio that would crash Chrome, you'll almost certainly crash RStudio.)

Ashish Kulshrestha

unread,
Jun 16, 2016, 5:46:07 PM6/16/16
to Joe Cheng, Shiny - Web Framework for R
I don't get the crash right away, only when I click through few tabs, i.e., it will show the plots for first two tabs then crash after a while when I click on third tab. Any suggestions?

Thanks for clarifying the browser thing.

Joe Cheng

unread,
Jun 16, 2016, 6:17:35 PM6/16/16
to Ashish Kulshrestha, Shiny - Web Framework for R
I just realized the vast majority of the data here is in the shapes themselves. (I'm sorry, I should have thought of it right away as it's not uncommon, but my head's not currently in the GIS space...)

If you have ArcGIS, QGIS, etc. I'd try simplifying the .shp before doing anything else.


If that doesn't help I have something else you can try, but simplifying the shapes is by far the best thing to try first.

Ashish Kulshrestha

unread,
Jun 17, 2016, 6:05:42 PM6/17/16
to Shiny - Web Framework for R, ashish.ku...@gmail.com
Thanks Joe! Your suggestion of simplifying the shape helped a lot but the problem is still not completely solved. 

Earlier, the browser was crashing after 2-3 plots and now the browser was able to render about 5 plots and then crashes when I try 6th or 7th. Simplifying the shape reduced the size of map objects significantly. There is a tolerance we specify while simplifying shapes and I don't think the shape can be simplified even further without loosing the polygon information. I am almost there but still need something in addition to simplify to resolve the issue.

Ashish
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discuss+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages