rstudio / shiny

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

Remove outdated initial page load pulse from `useBusyIndicators()` #4057

Closed cpsievert closed 4 months ago

cpsievert commented 4 months ago

Closes #4056

This PR removes the now outdated "initial page load pulse" from useBusyIndicators(). This logic was added well before we had proper progress reporting on the initial render of outputs, and was in mostly inspired by the lack of progress reporting on initial render, so it's no longer serving as much utility.

By removing this logic, it is technically possible for the server to be busy without any indication. Below is one such example with slow running session initialization code and no outputs. It seems fair to say, however, that Shiny should be reporting a busy status when the server function is executing (i.e., it shouldn't be the responsibility of the busy indicator logic to cover these scenarios).

library(shiny)

ui <- fluidPage(
  useBusyIndicators(),
  actionButton("btn", "Press"),
)

server <- function(input, output, session) {
  Sys.sleep(5)

  observeEvent(input$btn, {
    showNotification("Thanks for pressing!", duration = 5)
  })

}

shinyApp(ui, server)

The more unfortunate thing about removing this logic is what can possibly happen when someone chooses useBusyIndicators(spinners = FALSE, pulse = TRUE). In that case, if there is slow running startup code, you won't get any busy indication (for similar reasons to above), even when there are outputs on the page:

library(shiny)

ui <- fluidPage(
  useBusyIndicators(spinners = FALSE),
  actionButton("btn", "Press"),
  plotOutput("p")
)

server <- function(input, output, session) {

  Sys.sleep(3) # Won't get busy indication here

  output$p <- renderPlot({
    input$btn
    Sys.sleep(3) # This will get busy indication, since the server reports busy status
    plot(1:10)
  })

}

shinyApp(ui, server)