rstudio / reactlog

Shiny Reactivity Visualizer
http://rstudio.github.io/reactlog
Other
121 stars 9 forks source link

Changes to reactive values not displaying accurately #36

Closed jcheng5 closed 5 years ago

jcheng5 commented 5 years ago

Set options(shiny.reactlog=TRUE), then run this app:

library(shiny)

ui <- fluidPage(
  uiOutput("ui")
)

server <- function(input, output, session) {
  output$ui <- renderUI({
    numericInput("x", "x", 5)
  })

  observe({
    print(input$x)
  })
}

shinyApp(ui, server)

If you don't touch any inputs, you'll see that the input$x value is 5. Now launch the reactlog. It'll say that input$x is NULL.

I don't repro this problem without using the renderUI; it's almost like the initial value being NULL causes the next value to be lost.

For what it's worth, the 063-superzip example app is where I saw this first; input$map_bounds stays NULL longer than it should.

mattflor commented 4 years ago

Has this issue really been fixed? I added a numericInput in the ui function to @jcheng5's app to compare the behavior with the numericInput created via renderUI in the server function. What I observe is that without having touched any inputs the reactlog looks fine. input$x is initialized with NULL but then picks up the value of 5. However, when I DO touch the x input and step it to up to 6, and then launch reactlog again, the info displayed in the dependency graph and the info in the status bar do not match at step 13. The status bar says "Step: 13 input$x has a new value: int 6" while the graph says "input$x - 'int 5'". The graph info is the correct one. That discrepancy does not occur with input$y.

library(shiny)
library(reactlog)

options(shiny.reactlog = TRUE)

ui <- fluidPage(
    uiOutput("ui"),
    numericInput("y", "y", 10)
)

server <- function(input, output, session) {
    output$ui <- renderUI({
        numericInput("x", "x", 5)
    })

    observe(label = "observe x", {
        print(paste("x:", input$x))
    })

    observe(label = "observe y", {
        print(paste("y:", input$y))
    })

}

shinyApp(ui, server)
schloerke commented 4 years ago

I believe this is a bug with the status bar within reactlog.


Thank you for the reproducible steps! If you hit the l key while the reactlog is open, it'll display the raw log value. The raw log value states the value to be int 5, while the status bar states it to be int 6.

Screen Shot 2020-01-23 at 10 38 33 AM

The value int 6 should not appear until after the second idle stage ~ Step 20.

Screen Shot 2020-01-23 at 10 44 03 AM