skranz / RTutor

Creating interactive R Problem Sets. Automatic hints and solution checks. (Shiny or RStudio)
https://skranz.github.io/RTutor/
200 stars 57 forks source link

show.ps leads to grey-screen Shiny App #14

Closed kmishra9 closed 6 years ago

kmishra9 commented 6 years ago

Hey there,

I seem to be having issues specifically with demo material on vignettes and linked from the GitHub mainpage.

Specifically, when I go to the RStudio Cloud demo here and log in, I have a temporary copy of your project.

Then, if I run the code chunk in the README.md, I'm first prompted to install RTutor: Error in library(RTutor) : there is no package called ‘RTutor’ Okay, so I install with the following: install.packages("RTutor",repos = c("https://skranz-repo.github.io/drat/",getOption("repos"))) Now, I run the code chunk:

library(RTutor)
show.ps("Intro", user.name="TestUser")

A new window spawns but the Shiny App is greyed out, though I've discovered I can actually still click around within the app, though all of the code chunks seem to have vanished. image image

-- I'm also having the exact same issue on my own RStudio Server instance, where I've created a file called Example_sol.Rmd that is identical to the one in the Guide for Developing Interactive R Problemsets Vignette. With this, I'm able to run create.ps just fine but running show.ps with the example problemset spawns a greyed out screen and no code chunks for me to fill out.

skranz commented 6 years ago

Thanks a lot for the problem description.

  1. The problem that RTutor was not installed in the rstudio-cloud, seems to be due to the fact that a copy of my rstudio cloud project at https://rstudio.cloud/project/39040 always seems to set by default the newest R version 3.5. Yet, when I created the project R 3.4.4 was the newest version and all my packages are installed for that version. (I asked RStudio about this behavior here: https://community.rstudio.com/t/copy-of-rstudio-cloud-starts-with-different-r-version-packages-not-installed/10335) I now also installed RTutor for R version 3.5 and it should hopefully work.

  2. I also could replicate that the shiny version greys out under R version 3.5 in rstudio-cloud, unfortunately without any error message in the R console. Interestingly, it works when you change the R studio version to 3.4.4 in the cloud. It also works on my Windows desktop that runs R 3.5. So something strange is going on here, but for the lack of an error message, I don't know yet, what the underlying problem is.

kmishra9 commented 6 years ago

Thanks for reporting that -- they're still in alpha so these kinds of bugs are likely to be expected.

That said, I attempted to create the problemset from our other issue, and used 3.4.4 on RStudio Cloud in an attempt to see what the Shiny app looked like -- no dice, unfortunately. Perhaps you'll be able to see something I'm missing?

skranz commented 6 years ago

True, I can replicate that the error also arises in R 3.4.4. However, for me it currently looks like a Heisenbug. Sometimes show.ps works without greying out anything (even in R 3.5). Moreover, I made a copy of your project https://rstudio.cloud/project/45019 and added a simple default shiny app from File->New File-> ShinyWebApp (in the folder SimpleApp). Also this app now sometimes greys out (even though less frequently, and more often when I have tried show.ps before).

When greying out, the javascript console of my Chrome Browser shows an error message like:

shinyapp.js:83 WebSocket connection to 'wss://skranz.rstudio.cloud/11f0ed75a84e47a0b87ab0abd399fa92/p/3620/websocket/' failed: Error during WebSocket handshake: Unexpected response code: 500

Maybe there is some timeout or other connection problem going on with shiny here. I also now run into this problem with my simple "Intro" problem set, while it worked fine in earlier days. I think, I will ask about it on the RStudio-cloud mailing list.

skranz commented 6 years ago

Here is the discussion so far on the rstudio mailing list:

https://community.rstudio.com/t/shiny-app-greys-out-in-rstudio-cloud-error-during-websocket-handshake

Updating to the new development version of httpuv solved the problem after a restart of my computer and the R session in the cloud. (I used R 3.5 for that). Can you try out, whether this also solves the issue for you?

kmishra9 commented 6 years ago

Ok, so upgrading to the dev version on my RStudio-Server instance doesn't resolve the problem, for whatever reason. This is in two both Safari and Chrome, though I'll restart at some point in the near future and hope that resolves it.

However, when I go to a new RStudio Cloud project, install the necessary components, including the dev version of httpuv, I am able to successfully spawn a non-grey screen Shiny app (hooray, at least we got that done).

skranz commented 6 years ago

If a restart does not help for RStudio Server, you may want to add directly to the discussion here: https://community.rstudio.com/t/shiny-app-greys-out-in-rstudio-cloud-error-during-websocket-handshake or in one of the corresponding Github issues.

That being said, you should be aware of security isssues if you give students access to your own RStudio server: even in the shiny version of RTutor, users can run arbitrary R code including system commands via system, e.g. deleting files to which they have access. The issue would also arise, if you host a problem via your own shiny server.

In principle, you probably could make stuff secure, e.g. by programming some login app that starts a new docker container with approbriately restricted rights for every user. But that is not straightforward and I have never done it. For that reason, I never host my problem sets on my server.

So far I know of three simply ways to avoid this risk:

  1. Distribute the problem sets as ZIP files and let each student solve them on their own computer. (Drawback: Each student needs to install R and all packages)
  2. Host your problem set on shinyapps.io as described in the corresponding RTutor vignette. Drawback: The free shinyapp.io version can be accessed for a limited number of hours per month. So you probably have to pay.
  3. Host it on shiny.cloud. Drawback: Probably you have to pay after the alpha phase. But maybe there will remain free or cheap options for teaching.

Currently, I think shiny.cloud is the simplest way to let students solve problem sets. (You can additionally give the option for students to solve it at home (1.), if they feel fit enough to handle the installation themselves)

kmishra9 commented 6 years ago

Yup, I'm familiar with the security risks -- we're just developing the problem sets on our server right now, which is the main dev environment I'm using. It's very likely we'll be using the RStudio Cloud + RTutor combo, given the nice elements of RStudio Cloud for education.

I'll report in on the RStudio thread if RStudio-Server still ends up not working. Thanks for helping with this issue!