shiny.js refresh function crashes Shiny on RStudio Workbench

I've found that shiny.js::refresh() crashes the Shiny window if RStudio Workbench is used but not using a "regular" version of RStudio.

An example of how to use refresh() can be found at (refresh: Refresh the page in shinyjs: Easily Improve the User Experience of Your Shiny Apps in Seconds). On my version of RStudio Workbench, clicking the "Refresh" button causes the Shiny window to close, although R remains running in the background.

Is this due to a peculiarity of my RStudio Workbench configuration or is it a general issue. Are there perhaps workarounds available?

Hi John!

I tried running the shinyjs::refresh() example on both RStudio Desktop and Workbench:

 library(shiny)
 library(shinyjs)

  ui <- fluidPage(
    useShinyjs(),
    textInput("text", "Text", "text"),
    actionButton("refresh", "Refresh")
  )

  server <- function(input, output, session) {
    observeEvent(input$refresh, {
      refresh()
    })
  }

 shinyApp(ui, server)

and it works fine on both.

Maybe we need more information to underpin the exact issue.

To this end, could you expand a bit on the details of:

  1. Your setup (R version, {shiny} and {shinyjs} versions, workbench version
  2. What you specifically mean by "Shiny window" (is it a browser tab, the viewer pane, a window viewer?)

Thanks!


This post was published by an Appsilon) team member. Our company can help you get the most out of RShiny and Posit/RStudio products.

Check our open positions here.

Appsilon: Building impactful RShiny Dashboards and providing R coding services.
Appsilon_GIFsmall_whitebg

Hi Agus,

Thanks for your efforts! I just gave the refresh example code another try on RSW and saw the same behaviour as before, i.e. the popup window closed but R remains active until I click the "Stop" button. In this session, I'm running R 4.2.1 but I've had the same issue running R 4.1.0.

I'll discuss this next week with our RSW admin, it looks like this is specific to our site. Thanks for providing that insight!

Hi John!

Glad to be of some help :sweat_smile:

In the meantime, could you see what happens if you change where the app launches, by running (in the R console):

options(shiny.launch.browser = .rs.invokeShinyWindowExternal)

and then using the run button in the GUI or just shiny::runApp()?
This should launch the app in a new browser tab.

You may also try with

options(shiny.launch.browser = .rs.invokeShinyPaneViewer)

which would launch the app in the viewer pane inside RStudio.

This way, we could understand whether the issue has to do with the launching interface.

Cheers!


This post was published by an Appsilon team member. Our company can help you get the most out of RShiny and Posit/RStudio products.

Check our open positions here.

Appsilon: Building impactful RShiny Dashboards and providing R coding services.
Appsilon_GIFsmall_whitebg

Hi Agus,

I tried running the sample code using

options(shiny.launch.browser = .rs.invokeShinyWindowExternal)

The app opened in a new Browser tab. If I clicked on the "refresh" button, the browser tab greyed out, then reappeared, but the text was not reset to "Test". This also happens if I run the app in the usual manner, then click on the "Open in browser" button.

If I run

options(shiny.launch.browser = .rs.invokeShinyPaneViewer)

instead, the app runs in the view pane as expected. If I click the "refresh" button, the view pane becomes empty but R keeps running until I click the "stop" button.

This problem is due to Firefox. If I try it using Chrome, the refresh button works properly. Our RSW admin tried this out on RStudio Connect and got the same results: refresh work on Chrome but not on Firefox. Surprising, RShiny Workgroups/Connect work otherwise fine on Firefox.

I'm using Firefox "102.6.0esr (64-bits)" by the way, and Chrome "Version 108.0.5359.125 (Official Build) (64-bit)". Both are managed by our IT department.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.