-
Notifications
You must be signed in to change notification settings - Fork 1.9k
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with dynamic UI in 1.7.5 (runs fine in 1.7.4) #3899
Comments
Thanks for the report, Vincent. To quickly answer your question up front, no there isn't a way to opt out of the asynchronous UI rendering, other than staying with shiny < 1.7.5. I've done some investigation, but haven't been able to find the root cause. Radiant is quite a complicated app! The rest of my notes are for others on the Shiny team who might have more insight. I haven't been able to create a reprex that isolates the behavior; within radiant, this example includes nested dynamic UI ( From the websocket logs I can tell that the client receives a single message with the UI intended for This message creates What's unusual is that, if I add a breakpoint in There are only a few places where
What I can see happening is that the Conceptually, this feels similar to #1399, but I also haven't been able to use that pattern to reproduce this issue. @wch @jcheng5 @cpsievert Do you have any ideas or advice? |
I've been poking at this, and I've found something odd:
I believe the problem is that the previous UI is being removed before
I think that by experimenting with various combinations of these things, it should be possible to create a simple reproducible example, which will make it easier to get to the bottom of things. |
FYI Linear regression is probably the most complex ui. Single mean in radiant.basics has the same issue and is less complex. |
@wch I don't (yet) have a radiant-less reprex, but I was able to simplify radiant's UI logic quite a bit, and get a simple log of the problematic unbind/bind ordering (and, as @gadenbuie mentioned, |
I've been trying to make a minimal example but I haven't gotten very far. @vnijs if you are able to strip down Radiant to the bare minimum to reproduce this problem, that would be very helpful! |
@wch I may be on to something. Will post back asap when I have had a chance to do more testing. Thanks for looking into this! |
@vnijs Thanks for that the information about It's hard to say for sure if commenting it out will be a reliable fix until we really understand the issue. I think our next step is to try to create a truly minimal reproducible example, so that we can isolate the cause of the problem. |
I have a minimal reproducible example: library(shiny)
library(bslib)
ui <- navbarPage(
title = "Reprex",
tabPanel(
"Tab 1",
selectInput("data", NULL, choices = c("a", "b")),
),
tabPanel(
"Tab 2",
uiOutput("outer_ui")
)
)
server <- function(input, output, session) {
output$inner_inner_ui <- renderUI({
"This is inner_inner_ui. YOU SHOULD BE ABLE TO SEE THIS!"
})
output$inner_ui <- renderUI({
input$data
div(
uiOutput("inner_inner_ui"),
icon("play"),
sliderInput("s", "Slider:", min = 0, 10, 5)
)
})
output$outer_ui <- renderUI({
input$data
uiOutput("inner_ui")
})
}
shinyApp(ui, server) To reproduce:
Almost any significant change to the app will make the error not happen. For example, the following will cause the error to go away:
|
I modified
|
Great insights, @wch. I followed the rabbit trail a little to see how the interleaving is happening, and got here: shiny/srcts/src/shiny/shinyapp.ts Line 515 in a6fc6bf
Seems like that |
@jcheng5 Thanks, it looks like that line is the culprit. I tried adding an The main entry points are (internally) There are some issues with making everything on the stack
|
I was surprised that this isn't something that Typescript catches, but it turns out there are linting rules for this. Should we add no-floating-promises to our eslint config? |
Nice, I didn't know about the
After enabling it, it flags a number of other places where we created promises without handling them. |
I started a discussion at the link below and @gshotwell suggested I post an issue:
https://discord.com/channels/1109483223987277844/1154545900211937340
The issue seems to be caused by a change in how dynamic UI elements are processed in 1.7.5.1 compared to 1.7.4. The issue occurs in every component where there are column names from a dataset are used to populate a dropdown after switching from one dataset to another (e.g., diamonds to titanic)
Steps to reproduce:
install.packages("radiant")
radiant::radiant()
To see what happens in 1.7.4.1 and all prior versions of shiny that I have used see below.
remotes::install_version("shiny", "1.7.4.1")
As you can see in the first video, an error comes up in the JS console. There is only one
ui_reg_rvar
, a dynamic input that depends on the available data set, but somehow when a dataset is changed the JS code sees both the old one and refuses to create the new/updated one. Since most other inputs in Model > Linear regression dependui_reg_rvar
being available, those don't render either.This is not just an issue with one component in Radiat. In every component that depends on a selected data to provide values for a dropdown, the same
duplicate binding for ID ...
error occurs.Is there way to turn off the new dynamic processing approach in shiny 1.7.5? That would be quickest way forward with students starting classes next week.
Thanks,
Vincent
The text was updated successfully, but these errors were encountered: