Closed psimm closed 2 years ago
This appears to be related to the presence of an html dependency. The same slowdown happens with sliderInput
, which attaches an htmlDependency
object to the HTML.
For example, this shows about 6500 milliseconds of CPU time on my computer
library(bslib)
library(shiny)
library(profvis)
ui <- fluidPage(
theme = bs_theme(bootswatch = "slate"),
do.call("tagList", lapply(1:200, function(x) {
sliderInput(paste0("id", x), "Another input", 1, 100, 50)
}))
)
app <- shinyApp(ui, server = function(input, output, session) {})
profvis(runApp(app))
If the sliderInput
is replaced with something that doesn't have an htmlDependency
, like textInput
, then it is fast (250ms):
ui <- fluidPage(
theme = bs_theme(bootswatch = "slate"),
do.call("tagList", lapply(1:200, function(x) {
textInput(paste0("id", x), "Another input")
}))
)
app <- shinyApp(ui, server = function(input, output, session) {})
profvis(runApp(app))
Similarly, if we keep the sliderInput
, but just remove the theme=bs_theme()
, then it is still fast (650ms):
ui <- fluidPage(
do.call("tagList", lapply(1:200, function(x) {
sliderInput(paste0("id", x), "Another input", 1, 100, 50)
}))
)
app <- shinyApp(ui, server = function(input, output, session) {})
profvis(runApp(app))
So the problem appears to be an interaction between bslib and having many html dependency objects.
This issue has been automatically locked. If you believe you have found a related problem, please open a new issue (with a reproducible example or feature request) and link to this issue.
Hi, when building a large app with many inputs, I noticed a performance issue.
Profiling the app with
shows that
bslib::bs_dependency()
is called many times and causes the slowdown. Total time: 6580ms on my computer.The time goes down to 1320ms if
selectize = FALSE
or if bslib is not used.Related question: https://stackoverflow.com/q/67726350 (I didn't ask that question but I took its reprex)
sessionInfo()