Deactivate "busy status" in R Shiny application

493 Views Asked by At

How can I prevent the RStudio Shiny application server from sending "busy/idle" status updates?

When observing my websocket traffic in my app, I noticed that the server is constantly sending updates about its current status ("busy"/"idle").

Server Status: Busy/Idle

The event shiny:busy is triggered when something is happening on the server (e.g. an observer is running), and the event shiny:idle indicates when the server is idle. The event object does not carry any special properties related to Shiny.

Using Shiny version 1.1.0 on the server side, Chrome 66 on the client side.

Background of my question

I have the feeling that this feature might slow down my application, because the client seems to be blocking itself for several seconds after sending information to the server. It is hard to reproduce, but what happens is (according to the websocket traffic log):

  1. Client: User clicks on an action button.
  2. Client: The action information is sent to the server with no delay.
  3. Client: All JavaScript executions freeze/pause for several seconds. No user interaction is possible during that period.
  4. Meanwhile server: While the client is waiting, R is executing some procedures on the server side.
  5. Server: Sends back custom information to the client.
  6. Client: Shows information in the log as "received", but keeps freezing.
  7. Server: Sends another status update {"busy":"idle"} to the client. This happens several seconds after steps 5/6 show up in the traffic log.
  8. Client: Finally, client comes back to life and continuous with JavaScript execution and UI interaction.

Sample code

This app shows the problematic server communication in a very simple way. I would like to reduce the communication coming from the server.

library(shiny)

ui <- fluidPage(

   titlePanel("Test"),

   sidebarLayout(
      sidebarPanel(
         actionButton(inputId = "testButton",
                      label = "Click me")
      ),

      mainPanel(
         textOutput(outputId = "testText")
      )
   )
)

server <- function(input, output) {

  observeEvent(input$testButton,{
    output$testText <- renderText({
      Sys.time()
    })
  }) 


}

shinyApp(ui = ui, server = server)

Websocket traffic log:

enter image description here

Please note: The above example is simplified, the described effect of a long waiting period cannot be seen there. Nevertheless, the unwanted status updates are well observable. The problem arises as application code grows, and turning off the Shiny status messages could potentially help me in these special situations.

0

There are 0 best solutions below