Apps work with Shiny 0.8.0 but buggy or broken in 0.8.0.99

233 views
Skip to first unread message

Matthew Leonawicz

unread,
Jan 8, 2014, 8:25:39 PM1/8/14
to shiny-...@googlegroups.com
Hi,

I understand version 0.8.0.99 is developmental, but I am curious if I should expect a large number of my previously made apps to no longer function properly when run with this version of Shiny? Several of my apps hosted on Spark for a long time now, and tested and continuing to function perfectly on that server with version 0.8.0, are revealing many bugs and broken functionality when I launch them locally using version 0.8.0.99 (which I've been experimenting with for some of its new features).

It this to be expected? It is a bit troubling, the thought that once the server is upgraded to perhaps version 0.9.0, several apps our clients rely on many no longer work properly. I am searching the best I can for the source of all the bugs, but they seem different from app to app, and difficult for me to pinpoint the sources of the errors. In one case, an app simply did not seem to allow me to name an output reactive for a slider using text that was similar (but not the same) to other variable names. I was able to "fix" the problem in that instance, though I did not understand what was wrong. In other cases I have not found the problems. But in general, it seems to be a pattern of errors showing up in the console (for the sidebar, or for the mainPanel area) that suggest maybe some components on either the user or server side are no longer able to "see" certain objects.

Does anyone have any suggestions on how I can best troubleshoot these problems in a generic way?

Thanks,
Matt

Joe Cheng

unread,
Jan 9, 2014, 2:19:09 PM1/9/14
to Matthew Leonawicz, shiny-...@googlegroups.com
Hey Matthew, our goal is to keep the master branch at a pretty high level of quality and we certainly haven't seen the problems you're describing on 0.8.0.99. Could you provide a concrete example of what you're talking about, even if it doesn't consistently reproduce, or reproduce at all?


--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Matthew Leonawicz

unread,
Jan 9, 2014, 2:23:22 PM1/9/14
to shiny-...@googlegroups.com, Matthew Leonawicz
Hi Joe,

Yes, I will look for what appears to be the simplest bug in the simplest app today, and attempt to reproduce it. My debugging skills with Shiny are not very strong compared to when I'm just working in a typical R session. But I will see what I can come up with.

Thanks,
Matt

Winston Chang

unread,
Jan 9, 2014, 2:47:07 PM1/9/14
to Matthew Leonawicz, shiny-discuss
When you're debugging, also try to use the latest version of shiny from github. The 0.8.0.99 version number indicates that it's the development version, but it doesn't specify exactly which commit is installed, and you'll want use the latest to make sure it's not a bug that's already fixed.

-Wintson

Vincent Nijs

unread,
Jan 9, 2014, 3:41:42 PM1/9/14
to shiny-...@googlegroups.com, Matthew Leonawicz
Perhaps this is related to this issue https://github.com/rstudio/shiny/issues/329 ?

I had a few problems pop up after upgrading to use navbarPage where I was expecting a NULL but got an NA. I now mostly use the following function to check if a variable has been initialized. Seems to have resolved the problems for me.

has.value <- function(x) ifelse(is.null(x) || is.na(x),FALSE,TRUE)

Matthew Leonawicz

unread,
Jan 9, 2014, 3:42:47 PM1/9/14
to shiny-...@googlegroups.com, Matthew Leonawicz
Hi,

That is a good idea, thanks. I was able to find the source of one bug so far by following a breadcrumb trail of print() statements in an app (this tactic probably speaks to my limited debugging Shiny apps).

I just reinstalled 0.8.0.99 and confirmed the issue still exists. I don't know if it counts as a bug or an intended change in behavior. I have reproduced a simple example.

Here is the ui.R

shinyUI(pageWithSidebar(
  headerPanel("Title"),
  sidebarPanel(
    uiOutput("selectionMenu")
  ),
  mainPanel(
    uiOutput("printSelected")
  )
))

And here is the server.R

library(shiny)
mydata <- factor(c("A","B","C"))

shinyServer(function(input, output) {
  output$selectionMenu <- renderUI({ selectInput("selectionMenu", "Choose:", mydata, selected=mydata[1]) })
  output$selected <- reactive({ input$selectionMenu })
  output$printSelected <- renderUI({ verbatimTextOutput("selected") })
})

Up to version 0.8.0, I did not have to do explicit conversion of a factor variable to class character because this happens automatically. Actually, with 0.8.0.99, the value stored in input$selectionMenu still has class character, but it now returns the index of the original factor level instead of the desired value. In this example input$selectionMenu is the character variable "1"," 2", or "3" in 0.8.0.99 whereas it was "A" or "B" or "C" in 0.8.0. It reminds me doing a as.numeric() on a factor without doing as.character() first.

Matt

Matthew Leonawicz

unread,
Jan 9, 2014, 4:34:25 PM1/9/14
to shiny-...@googlegroups.com
I have found one more change, with a simple reproducible example.

I suspect it is not best practice to include a period in a reactive name, at least if one will be using some javascript perhaps? The following works in 0.8.0 but not in 0.8.0.99. It does work again once I remove the period in "dist.type".

ui.R

shinyUI(pageWithSidebar(
  headerPanel("Title"),
  sidebarPanel(
    radioButtons("dist.type","Distribution type:",list("Discrete","Continuous"),selected="Discrete")
  ),
  mainPanel(
    uiOutput("printSelected")
  )
))

server.R

library(shiny)
shinyServer(function(input, output) {
  output$selected <- reactive({ input$dist.type })
  output$printSelected <- renderUI({ verbatimTextOutput("selected") })
})

At least so far once I find the source, these issues do not appear to be complex problems. It's just the complexity of some of the apps that makes them a bit harder to track down.
Matt

Matthew Leonawicz

unread,
Jan 9, 2014, 5:28:00 PM1/9/14
to shiny-...@googlegroups.com
I have found one more problem that affects sliders in multiple apps when using shiny 0.8.0.99. I do not understand this one though. If I have multiple sliderInput reactives in the sidebar, some display and function properly, while others display as a non-functional (and I think, NULL-valued) textbox that shows the slider's intended default value.

The interesting thing is it seems to be the presence of one slider, that can affect the functionality of another slider (no dependency is intended). Reproducible example below. Note that the first line in sidebarPanel, 'uiOutput("n.trees")', is commented out initially.

ui.R

shinyUI(pageWithSidebar(
  headerPanel("Title"),
  sidebarPanel(
#uiOutput("n.trees"),
uiOutput("interaction.depth"),
uiOutput("shrinkage"),
uiOutput("train.fraction"), 
uiOutput("bag.fraction"),
uiOutput("cv.folds"),
uiOutput("minobsinnode")
  ),
  mainPanel(
uiOutput("printSelected")
  )
))


server.R

library(shiny)
shinyServer(function(input, output) {
output$n.trees <- renderUI({
sliderInput("n.trees","Number of trees:",100,10000,100,step=100)
})

output$bag.fraction <- renderUI({
sliderInput("bag.fraction","Bag fraction:",0.1,1,0.5,step=0.05)
})

output$train.fraction <- renderUI({
sliderInput("train.fraction","Training fraction:",0.1,1,0.5,step=0.05)
})

output$minobsinnode <- renderUI({
sliderInput("minobsinnode","Min. obs. in terminal nodes:",1,10,5,step=1)
})

output$cv.folds <- renderUI({
sliderInput("cv.folds","Cross-validation folds:",1,10,1,step=1)
})

output$shrinkage <- renderUI({
selectInput("shrinkage","Shrinkage rate:",choices=c(0.001,0.005,0.01,0.05,0.1),selected=0.05)
})

output$interaction.depth <- renderUI({
selectInput("interaction.depth","Interaction depth:",choices=1:3,selected=1)
})

output$selected <- reactive({ input$bag.fraction })
output$printSelected <- renderUI({ verbatimTextOutput("selected") })
})

As long as the reactive expression, n.trees, is not included in the sidebar, all the other sliders display and function properly. If you inlcude uiOutput("n.trees") in the ui.R script under Shiny 0.8.0.99, it will display and function properly. However, now most (but not all) of the other sliders will break. The issue seems more nuanced than simply not using periods in reactive names. In fact, I can remove all instances of periods in names in both ui.R and sever.R and it appears this has nothing to do with this particular issue.

I also tried leaving a different output commented out in ui.R in case the issue somehow depended on the number of sliders, but it seems the inclusion of the first slider is the only problematic inclusion. Including it but removing another other one does not remove the problem as removing uiOutput("n.trees") does.

Matt

Vincent Nijs

unread,
Jan 9, 2014, 11:37:47 PM1/9/14
to shiny-...@googlegroups.com
Not sure if this is related but I have a binding to jquery sortable (http://jqueryui.com/sortable/) that works fine in .80 but no longer works in .8.0.99


shiny::runGitHub("sortable","mostly-harmless")

Joe Cheng

unread,
Jan 10, 2014, 5:07:48 AM1/10/14
to Vincent Nijs, Matthew Leonawicz, shiny-...@googlegroups.com
Thank you Matthew and Vincent! These are indeed real issues and we are so grateful to you for helping identify them.
  1. The NULL vs. NA issue will be resolved one way or another shortly. My very strong preference is to return the behavior to 0.8.0.
  2. The factors being rendered as numbers is a new bug--we never tested factors as attribute values to my knowledge, and this commit inadvertently changed the behavior. I have filed issue #359 and pull request #360 to return the behavior to 0.8.0, along with a unit test.
  3. Dots can be used as the names of variables, but NOT as the names of input or output IDs. Issue #358 was filed by Winston asking to warn if IDs containing dots are detected. By the way, it's also a bad idea to have an input and output share the same ID (which your n.trees example has, in that each input has the same name as the uiOutput that encloses it). I'm not sure how realistic it is for us to be able to warn in dynamic cases like this though.
  4. The slider and sortable issues are both related to this commit which was an ambitious attempt to fix a pretty fundamental longstanding bug. The regression it introduces is pretty serious though, I'll work on it tomorrow.
I must apologize for the relatively large number of regressions, we're trying to fix a lot of longstanding issues in 0.9.0 and obviously that kind of ambition increases regression risk. Perhaps we'll do a longer-than-usual beta period for this release. :)

Thanks again!


--

Matthew Leonawicz

unread,
Jan 10, 2014, 1:25:47 PM1/10/14
to shiny-...@googlegroups.com, Vincent Nijs, Matthew Leonawicz
Thanks Joe!

I always appreciate how fast you all are to address issues that come up. The timely support is so valuable with such a rapidly developing package. It remains a joy to use.

I will adjust my coding style from here forward (and backward, as soon as I can get around to it) to reflect all the coding best practices you suggested.

Once I comb through more of my apps, I will post here again if I find any additional bugs, after freshly re-updating my shiny 0.8.0.99 as Winston suggested in case anything else is fixed in the meantime.

Thanks so much,
Matt

Matthew Leonawicz

unread,
Jan 10, 2014, 7:35:04 PM1/10/14
to shiny-...@googlegroups.com, Vincent Nijs, Matthew Leonawicz
I've found another apparent change in behavior in the browser when using Shiny 0.8.0.99. I have been adding help popovers using your helpPopup() function:


A change I am seeing under 0.8.0.99 is that html in the content string is displayed as text. For example, if I enclose text like:

'<p style="text-align:justify">This is paragraph one.</p><p style="text-align:justify">this is paragraph two.</p>',

this entire string verbatim is what shows up in the popover in the browser, rather than the desired rendering.

Matt

Joe Cheng [RStudio]

unread,
Jan 13, 2014, 7:43:23 PM1/13/14
to shiny-...@googlegroups.com, Matthew Leonawicz
Can you try wrapping it in an HTML() call, like this?

HTML('<p style="text-align:justify">This is paragraph one.</p><p style="text-align:justify">this is paragraph two.</p>')

If that fixes it, I'm a bit surprised it didn't do that in previous versions of Shiny, the current behavior is definitely more correct. We should always interpret content strings as plain text, not HTML, unless you explicitly tell us otherwise using HTML().

Matthew Leonawicz

unread,
Jan 13, 2014, 7:55:36 PM1/13/14
to shiny-...@googlegroups.com, Matthew Leonawicz
It appears to have no effect. I had also tried adding the line:

content <- HTML(content)

as the first line inside the curly braces of the helpPopup() function itself, but that had not had any effect either.

I agree the new behavior is more appropriate at least. But strange that HTML seems to have no effect here.

Matt

Vincent Nijs

unread,
Jan 21, 2014, 1:27:22 AM1/21/14
to shiny-...@googlegroups.com, Matthew Leonawicz
I noticed in the latest development version of Shiny the NA / NULL behavior reverted back to the behavior in .80. Doesn't seem to have affected the drag-and-drop binding (https://github.com/mostly-harmless/sortable)

Matthew: Any effects on how the sliders operate?

Patrick Toche

unread,
Jan 21, 2014, 7:04:27 AM1/21/14
to shiny-...@googlegroups.com, Matthew Leonawicz
is that similar to what was reported a while back by Stéphane, caused by this?

(if off topic ignore my message)

  # validate label
  labelText <- as.character(label)
  if (!is.character(labelText))
    stop("label not specified")


Matthew Leonawicz

unread,
Jan 22, 2014, 5:35:06 PM1/22/14
to shiny-...@googlegroups.com, Matthew Leonawicz
Hi Vincent,

Just trying the ui.R and server.R with several sliders again that I posted earlier in this thread, they appear to function and display properly now.

Matt

Vincent Nijs

unread,
Jan 23, 2014, 3:08:16 PM1/23/14
to shiny-...@googlegroups.com, Matthew Leonawicz
Good to hear Matt. Joe and Winston just fixed my problem with the sortable binding as well.
Reply all
Reply to author
Forward
0 new messages