trestletech / shinyRGL

Shiny wrappers for RGL (WebGL)
MIT License
52 stars 22 forks source link

Strange behavior after update rgl package to 0.95.1247 #10

Open chermit opened 9 years ago

chermit commented 9 years ago

What doesn't work: No rendering of the plot but the message "You must enable Javascript to view this page properly." instead on Firefox. The Javascript is enabled and the rgl package works smoothly (writeWebGL(),browseURL()). The console gives the message "Error: Could not find method of starting WebGL scene." that seem to be generated from glbinding.js, more precisely from:

...
setTimeout(function() { 
  // check to see whether we're using the old or new RGL function type.
  oldFun = window[data.prefix + "webGLStart"];
  newObj = window[data.prefix + "WebGL"];
  if(typeof oldFun === 'function'){
    oldFun();     
  } else if(typeof newObj === 'object'){
    newObj.start();
    newObj.onZoom(function(zoom){
      Shiny.onInputChange('.clientdata_gl_output_' + el.id + '_zoom', zoom);
    });
    newObj.onFOV(function(fov){
      Shiny.onInputChange('.clientdata_gl_output_' + el.id + '_fov', fov);
    });
    newObj.onPan(function(pan){
      Shiny.onInputChange('.clientdata_gl_output_' + el.id + '_pan', pan.getAsArray());
    });

  } else{
    throw new Error("Could not find method of starting WebGL scene.");
  }

}, 0);
...

System info: x86_64, linux-gnu R version 3.2.0 (2015-04-16) RStudio 0.98.1103 rgl package 0.95.1247 shinyRGL 1.1.0

How to reproduce: Run any of the example in the shinyRGL package

Thank you, Marco

gdkrmr commented 9 years ago

Found the same error under windows

jamesa8 commented 9 years ago

I have found this error on Chrome using Windows 7. I have the latest chrome, R, shiny, and shinyrgl packages. Previous versions of my code worked perfectly.

williFiebranz commented 9 years ago

It also happens on Max OS X within Safari...

martinschmelzer commented 9 years ago

I encoutnered this problem months ago and still nothing changed. I guess the package is not maintained anymore?

sargdavid commented 9 years ago

I have the same issue in Windows 7 with both Chrome and Firefox (I'm not even going to talk about IE, it's completely useless...). Please help!

Btw, it works just fine on my other Windows 7 machine which makes the issue even more mysterious :).

trestletech commented 9 years ago

This isn't really an acceptable solution, but try running this: install_github("rgl", "trestletech", "js-class") and see if the errors persist.

The root of the issue is that the rgl package has substantially refactored its JS code and this package would effectively need to be rewritten to encompass those changes. Hopefully using the older version by following the command above will help get things running, though you're certainly using an older version of the rgl package which may or may not be acceptable for your circumstances.

Sorry I don't have more time to maintain it now. I will commit to try to find time to review PRs if anyone wants to take on that work. I'm very open to adding a collaborator to the project.

martinschmelzer commented 9 years ago

Hi there,

thanks for the reply. I stumbled over this work around only a few hours before your post. It worked for me indeed!

Best, Martin

chermit commented 9 years ago

Hi, thank you for the workaround you provided. It works for me!

Best, Marco

sargdavid commented 9 years ago

Thank you Jeff, it worked! Just one more comment: I had to delete rgl package manually form my library folder, otherwise I was getting something like "permission denied to overwrite .../rgl.dll with .../rgl.dll".

Thanks!

martinschmelzer commented 9 years ago

If you start R/RStudio as an administrator you wont have the error message... ;)

williFiebranz commented 9 years ago

On mac this does not seem to work with the latest Xcode version. At least I get a ton of Xcode-related errors until the error limit gets exceeded and the installation aborts...

R version 3.2.0 (2015-04-16) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X 10.10.4 (Yosemite)

locale: [1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached): [1] httr_0.6.1 magrittr_1.5 tools_3.2.0 RCurl_1.95-4.6 stringi_0.4-1 stringr_1.0.0 bitops_1.0-6
[8] devtools_1.9.0

sargdavid commented 9 years ago

aha...Thanks for the tip!

OK, so now it works locally but I'm still having trouble running it on shinyapp.io. I completely removed the app from shinyapp.io and then deployed it again using the updated code. I get the following error message:

Error: rgl.open failed

I was under impression that shinyapp.io will use the packages that I'm using while deploying the apps but maybe that's not the case... Does anyone have an idea how to fix that?

Thank you.

jariwalask commented 9 years ago

The rgl.snapshot is failing when using the patched (install_github("rgl", "trestletech", "js-class")) rgl version. Here is a reproducible example, taken from shinyRGL github:

server.R

library(shiny)
library(shinyRGL)

#' Define UI for application that plots random 3d points
#' @author Jeff Allen \email{jeff@@trestletech.com}
shinyUI(pageWithSidebar(

    # Application title
    headerPanel("Shiny WebGL!"),
    # Sidebar with a slider input for number of points
    sidebarPanel(
        sliderInput("pts",
        "Number of points:",
        min = 10,
        max = 1000,
        value = 250),
        HTML("<hr />"),
        helpText(HTML("Created using <a href = \"http://github.com/trestletech/shinyRGL\">shinyRGL</a>."))
    ),

    # Show the generated 3d scatterplot
    mainPanel(
        webGLOutput("sctPlot")
    )
))

ui.R

# Must be executed BEFORE rgl is loaded on headless devices.
options(rgl.useNULL=TRUE)

library(shiny)
library(shinyRGL)
library(rgl)

xPts <- runif(1000, 0, 1)
yPts <- runif(1000, 0, 1)
zPts <- runif(1000, 0, 1)

#' Define server logic required to generate and 3d scatterplot
#' @author Jeff Allen \email{jeff@@trestletech.com}
shinyServer(function(input, output) {

# Expression that generates a rgl scene with a number of points corresponding
# to the value currently set in the slider.
    output$sctPlot <- renderWebGL({
        points3d(xPts[1:input$pts],
            yPts[1:input$pts],
            zPts[1:input$pts])
        axes3d()
        rgl.snapshot('./test.png', fmt = 'png')
   })
})

out

Warning in rgl.snapshot("./test.png", fmt = "png") : snapshot failed
# sessionInfo()
R version 3.2.1 (2015-06-18)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.4 (Santiago)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] shinyRGL_0.1.1 shiny_0.12.2   rgl_0.93.963 

loaded via a namespace (and not attached):
[1] R6_2.1.1        htmltools_0.2.6 Rcpp_0.12.0     digest_0.6.8   
[5] xtable_1.7-4    httpuv_1.3.3    mime_0.3

The rgl.snapshot works with rgl >= 0.95.1247. However, due to the known issue of the latest rgl not working with shiny, the output is what's reported initially in this ticket, and the snapshots are just blank / black images.

Any help is much appreciated. Thanks.

DanitD commented 8 years ago

Any solution for the "No rendering of the plot but the message: You must enable Javascript to view this page properly." for shinyRGL plots in Mac? I went through the comments and it looks like the solution doesn't work in Mac OS X.

Thanks in advance,

chermit commented 8 years ago

trestletech said "Sorry I don't have more time to maintain it now" so the package seem no more manteined right now. Try using package "rglwidget" instead. Marco

DanitD commented 8 years ago

I used "rglwidget", but thats still an issue!

chermit commented 8 years ago

Try to post your problem in R-Forge rgl forum. Marco

Il 26/01/2016 14:20, DanitD ha scritto:

I used "rglwidget", but thats still an issue!

— Reply to this email directly or view it on GitHub https://github.com/trestletech/shinyRGL/issues/10#issuecomment-175007857.

wave-electron commented 8 years ago

I've been having the same issue with ShinyRGL on a MAC OS X. i.e no plot and the message "You must enable Javascript to view this page properly."

I tried out the RGL patch and it didn't work just a lot of errors on the install which gets aborted.

In the end, i gave up and tried out the RGLwidget package and it works using the same plot example The code is up on github for anyone looking to get it working. Shiny App - RGLwidget Example