pixels icon indicating copy to clipboard operation
pixels copied to clipboard

shiny server instance crashes after capture button click.

Open joshuawlambert opened this issue 7 years ago • 4 comments

First, thanks for this package!

I am trying to use get pixels from a shiny app that I am building on my shiny server.

Server.R

library(shiny)
library(pixels)
server <- function(input, output) {
  
  show_pixels(
    round(runif(400, 0, 1)),
    grid = c(40, 10),
    size = c(800, 200),
    params = list(fill = list(color = "#FF3388"))
  )
  
  output$pixels <- shiny_render_pixels(
    show_pixels()
  )
  
  digit <- reactiveVal(floor(runif(1, 1, 10)))
  output$prompt <- renderText(paste0("Please draw number ", digit(), ":"))
  
  observeEvent(input$captureDigit, {
    digit_path <- file.path("digits", digit())
    if (!dir.exists(digit_path)) dir.create(digit_path, recursive = TRUE)
    saveRDS(input$pixels, paste0(digit_path, "/", as.numeric(Sys.time()), ".rds"))
    
    digit(floor(runif(1, 1, 9)))
    output$pixels <- shiny_render_pixels(
      show_pixels()
    )
  })
}

UI.R


library(shiny)
library(pixels)
fluidPage(
  tags$head(
    tags$style(HTML("
                    #pixels {
                    height: 270px !important;
                    margin-top: 10px;
                    }
                    "))
  ),
  titlePanel("Digit Capture Application"),
  textOutput("prompt"),
  shiny_pixels_output("pixels"),
  actionButton("captureDigit", "Capture")
)

Issue

On my shiny server, when I click the capture button it will save the image in the appropriate folder, but then it crashes and gives this warning in chrome console: "failed: One or more reserved bits are on: reserved1 = 0, reserved2 = 1, reserved3 = 1". Any ideas?

joshuawlambert avatar Apr 13 '18 18:04 joshuawlambert

Let me give it a shot...

javierluraschi avatar Apr 13 '18 18:04 javierluraschi

I was able to run it just fine from RStudio... I'm on OS X, can you share your sessionInfo()? Does this trigger for you within RStudio or as a proper shiny app?

screen shot 2018-04-13 at 11 29 55 am screen shot 2018-04-13 at 11 29 37 am screen shot 2018-04-13 at 11 29 43 am

javierluraschi avatar Apr 13 '18 18:04 javierluraschi

Rsudio version worked just fine. It only happened when I served it on our shiny server.

joshuawlambert avatar Apr 15 '18 17:04 joshuawlambert

sessionInfo() R version 3.4.3 (2017-11-30) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 14.04.5 LTS

Matrix products: default BLAS: /usr/lib/libblas/libblas.so.3.0 LAPACK: /usr/lib/lapack/liblapack.so.3.0

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

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

other attached packages: [1] shiny_1.0.5 pixels_0.1.0

loaded via a namespace (and not attached): [1] htmlwidgets_1.0 compiler_3.4.3 R6_2.2.2 htmltools_0.3.6 tools_3.4.3 yaml_2.1.18
[7] Rcpp_0.12.16 digest_0.6.15 xtable_1.8-2 httpuv_1.3.6.2 miniUI_0.1.1 mime_0.5

joshuawlambert avatar Apr 15 '18 20:04 joshuawlambert