Plot problem

605 views
Skip to first unread message

Alberto Mirisola

unread,
Sep 2, 2013, 7:08:39 AM9/2/13
to shiny-...@googlegroups.com
In the shiny upgrade from 0.5.0 to 0.7.0, I found a problem with the plots' visualization.

This is the piece of code in the server.R

output$plots1 <- renderPlot( {
    
    dati <- get(input$dataset)
    
    if(input$tool=='regression'){
   
      aa<-PrepMatr(database = get(input$dataset), nameTime = input$var2, nameDV= input$var1,
                   namePhase= input$var3,Aphase= input$var4,Bphase= input$var5)
      
      if(is.na(input$mindv) == TRUE){minimo="-inf"}else{minimo=input$mindv}
      if(is.na(input$maxdv) == TRUE){massimo="+inf"}else{massimo=input$maxdv}
      
      if(input$type == "allisonM"){
        
        allison<-Allison(aa,slopes=FALSE, miny= minimo,maxy= massimo)
        
      }else{
        allison<-Allison(aa,slopes=TRUE, miny= minimo,maxy= massimo)
      }
      
      dat=allison$database
      coe=allison$coefficients
    
      if(is.null(input$var2)) {
        print(ggplot(dat, aes_string(x=input$var1)) + geom_histogram())
      } else { 
       print(ggplot(dat, aes_string(x='TIME', y='DV',color='PHASE',group = 'PHASE')) + geom_point() +  geom_path() + geom_point(aes_string(x = 'TIME',y = 'diffe',colour = 'PHASE',group = 'PHASE'),data=dat,shape = 15)+ geom_path(aes_string(x = 'TIME',y = 'diffe',colour = 'PHASE',group = 'PHASE'),data=dat,linetype = 6) + geom_path(aes_string(x = 'TIME',y = 'pred'),data=dat,linetype = 3,colour = '#0000cc') + scale_y_continuous(name = 'DEPENDENT VARIABLE') +  scale_x_continuous(name = 'TIME'))
       #(plot(cars))
      } }
  }, width=800, height=400)



.. and this is the piece of code in the UI.R

 conditionalPanel(condition = "input.tool == 'regression'",
                       tabsetPanel(
                         tabPanel(names(Languam[10]), 
                                  #tableOutput("summary0"),
                                  htmlOutput("summary1")
                                  ), 
                         tabPanel(names(Languam[11]), plotOutput("plots1", width="100%", height = '400px')),
                         tabPanel(names(Languam[12]), plotOutput("plots1b", height = 400)),
                         tabPanel(names(Languam[13]), plotOutput("plots1a", height = 400)),
                         tabPanel(names(Languam[14]), plotOutput("plots2", height = 400), 
                                  helpText(names(Languam[15]))),
                         tabPanel(names(Languam[16]), htmlOutput("extra1"),
                                  helpText(names(Languam[17]))) 
                       )                         
      ),


the plot is visualized if (a) I run it locally (with runApp and with shiny 0.7.0 ) or (b) online (glimmer.rstudio) with the older version of shiny (0.5.0). With the new version of shiny, the plot is not visualized online and no errors are reported.

Anyone can help me?
Thanks in advance
Alberto

Alberto Mirisola

unread,
Sep 3, 2013, 6:35:47 AM9/3/13
to shiny-...@googlegroups.com

This is the log in the app folder:

#
# There is insufficient memory for the Java Runtime Environment to continue.
# pthread_getattr_np
# Possible reasons:
#   The system is out of physical RAM or swap space
#   In 32 bit mode, the process size limit was hit
# Possible solutions:
#   Reduce memory load on the system
#   Increase physical memory or swap space
#   Check if swap backing store is full
#   Use 64 bit Java on a 64 bit OS
#   Decrease Java heap size (-Xmx/-Xms)
#   Decrease number of Java threads
#   Decrease Java thread stack sizes (-Xss)
#   Set larger code cache with -XX:ReservedCodeCacheSize=
# This output file may be truncated or incomplete.
#
#  Out of Memory Error (os_linux_x86.cpp:715), pid=13975, tid=140117758912256
#
# JRE version: 6.0_27-b27
# Java VM: OpenJDK 64-Bit Server VM (20.0-b12 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea6 1.12.6
# Distribution: Ubuntu 12.04 LTS, package 6b27-1.12.6-1ubuntu0.12.04.2

---------------  T H R E A D  ---------------

Current thread (0x00007f6f68001000):  JavaThread "SIGINT handler" daemon [_thread_new, id=14023, stack(0x0000000000000000,0x0000000000000000)]

Stack: [0x0000000000000000,0x0000000000000000],  sp=0x00007f6fb53f16e0,  free space=136833748933k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x782b65]

 

why it happens after the shiny's upgrade?
 
Alberto

Alberto Mirisola

unread,
Sep 3, 2013, 10:23:30 AM9/3/13
to shiny-...@googlegroups.com

An additional information I noted: in the glimmer's application folder, the plots are saved in the file Rplots.pdf. However, they are not visualized with plotOutput

Alberto Mirisola

unread,
Sep 8, 2013, 12:31:37 PM9/8/13
to shiny-...@googlegroups.com
Can anyone help me? :(

Winston Chang

unread,
Sep 8, 2013, 11:57:49 PM9/8/13
to shiny-...@googlegroups.com
Hm, can you send the output of sessionInfo() on both the server and your local machine? I took a look at the log files for your app in ~/ShinyApps/log, and at the end it says:
 *** caught segfault ***
address 0x12ec57f8, cause 'memory not mapped'

This suggests to me that a package with compiled code is behaving badly.

Can you try removing pieces of code until the problem goes away? For example, simplify the ggplot2() call to something like:
 ggplot2(mtcars, aes(x=wt, y=mpg)) + geom_point()

Then, if the problem still happens, remove a piece of code above, and repeat until the problem disappears. This should help to diagnose the problem. 

Best,
-Winston




--
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.

Alberto Mirisola

unread,
Sep 9, 2013, 4:17:50 AM9/9/13
to shiny-...@googlegroups.com
Winston,
First of all, Thank you!
I followed your suggestion.
Regarding the plot's code , I tried simply with plot(cars) and the problem persist.
Regarding the session info, 
this the output in the server (via renderPrint and verbatimTextOutput)

R version 2.15.3 (2013-03-01)
Platform: x86_64-pc-linux-gnu (64-bit)

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=C                 LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
 [1] splines   grid      tools     stats     graphics  grDevices utils    
 [8] datasets  methods   base     

other attached packages:
 [1] xtable_1.7-0     Hmisc_3.10-1     survival_2.36-14 xlsx_0.5.0      
 [5] xlsxjars_0.4.0   rJava_0.9-3      ggplot2_0.9.3.1  foreign_0.8-52  
 [9] car_2.0-16       nnet_7.3-5       MASS_7.3-23      shiny_0.7.0     

loaded via a namespace (and not attached):
 [1] bitops_1.0-4.1     caTools_1.13       cluster_1.14.3     colorspace_1.2-0  
 [5] dichromat_1.2-4    digest_0.5.2       gtable_0.1.1       httpuv_1.1.0      
 [9] labeling_0.1       lattice_0.20-13    munsell_0.4        plyr_1.7.1        
[13] proto_0.3-9.2      RColorBrewer_1.0-5 Rcpp_0.10.2        reshape2_1.2.1    
[17] RJSONIO_1.0-1      scales_0.2.3       stringr_0.6.1     

This is the output in the local machine:

R version 2.15.2 (2012-10-26)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

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

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

other attached packages:
 [1] markdown_0.5.4      xtable_1.7-1        Hmisc_3.10-1        survival_2.37-4     xlsx_0.5.0          xlsxjars_0.4.0      rJava_0.9-4         ggplot2_0.9.3.1     foreign_0.8-53     
[10] car_2.0-16          nnet_7.3-6          MASS_7.3-23         shiny_0.7.0         knitcitations_0.4-4 bibtex_0.3-5        knitr_1.1           reports_0.1.2      

loaded via a namespace (and not attached):
 [1] bitops_1.0-4.2     caTools_1.14       cluster_1.14.4     colorspace_1.2-1   dichromat_2.0-0    digest_0.6.3       evaluate_0.4.3     formatR_0.7        gtable_0.1.2       httpuv_1.1.0      
[11] httr_0.2           labeling_0.1       lattice_0.20-15    munsell_0.4        plyr_1.8           proto_0.3-10       RColorBrewer_1.0-5 Rcpp_0.10.3        RCurl_1.95-4.1     reshape2_1.2.2    
[21] RJSONIO_1.0-3      scales_0.2.3       stringr_0.6.2      XML_3.96-1.1  



An additional information. I noted in the log these warnings:

.....
Warning in function (filename = "Rplot%03d.png", width = 480, height = 480,  :
  unable to load shared object '/usr/lib/R/library/grDevices/libs//cairo.so':
  libjpeg.so.8: failed to map segment from shared object: Cannot allocate memory
Warning in function (filename = "Rplot%03d.png", width = 480, height = 480,  :
  failed to load cairo DLL
.....

 *** caught segfault ***
address 0xc, cause 'memory not mapped'

Traceback:
 1: strsplit(msg, "\n")
 2: value[[3L]](cond)
 3: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 4: tryCatchList(expr, classes, parentenv, handlers)
 5: tryCatch(expr, error = function(e) {    call <- conditionCall(e)    if (!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)        dcall <- deparse(call)[1L]        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        msg <- conditionMessage(e)        sm <- strsplit(msg, "\n")[[1L]]        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")        if (is.na(w))             w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],                 type = "b")        if (w > LONG)             prefix <- paste0(prefix, "\n  ")    }    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if (!silent && identical(getOption("show.error.messages"),         TRUE)) {        cat(msg, file = stderr())        .Internal(printDeferredWarnings())    }    invisible(structure(msg, class = "try-error", condition = e))})
 6: try(func(), silent = FALSE)
 7: func()
 8: env$runWith(.self, func)
 9: ctx$run(.func)
10: run()
11: func()
12: withCallingHandlers({    func()}, warning = function(e) {}, error = function(e) {})
13: FUN(X[[1L]], ...)
14: lapply(.flushCallbacks, function(func) {    withCallingHandlers({        func()    }, warning = function(e) {    }, error = function(e) {    })})
15: ctx$executeFlushCallbacks()
16: .getReactiveEnvironment()$flush()
17: flushReact()
18: handler(binary, message)
19: doTryCatch(return(expr), name, parentenv, handler)
20: tryCatchOne(expr, names, parentenv, handlers[[1L]])
21: tryCatchList(expr, classes, parentenv, handlers)
22: tryCatch(expr, error = function(e) {    call <- conditionCall(e)    if (!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)        dcall <- deparse(call)[1L]        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        msg <- conditionMessage(e)        sm <- strsplit(msg, "\n")[[1L]]        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")        if (is.na(w))             w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],                 type = "b")        if (w > LONG)             prefix <- paste0(prefix, "\n  ")    }    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if (!silent && identical(getOption("show.error.messages"),         TRUE)) {        cat(msg, file = stderr())        .Internal(printDeferredWarnings())    }    invisible(structure(msg, class = "try-error", condition = e))})
23: try(handler(binary, message))
24: function (handle, binary, message) {    for (handler in .wsconns[[as.character(handle)]]$.messageCallbacks) {        result <- try(handler(binary, message))        if (inherits(result, "try-error")) {            .wsconns[[as.character(handle)]]$close()            return()        }    }}("95065952", FALSE, "{\"method\":\"update\",\"data\":{\".clientdata_output_summary1_hidden\":true,\".clientdata_output_plots1_hidden\":false}}")
25: eval(substitute(expr), envir, enclos)
26: evalq(function (handle, binary, message) {    for (handler in .wsconns[[as.character(handle)]]$.messageCallbacks) {        result <- try(handler(binary, message))        if (inherits(result, "try-error")) {            .wsconns[[as.character(handle)]]$close()            return()        }    }}("95065952", FALSE, "{\"method\":\"update\",\"data\":{\".clientdata_output_summary1_hidden\":true,\".clientdata_output_plots1_hidden\":false}}"),     <environment>)
27: doTryCatch(return(expr), name, parentenv, handler)
28: tryCatchOne(expr, names, parentenv, handlers[[1L]])
29: tryCatchList(expr, classes, parentenv, handlers)
30: tryCatch(evalq(function (handle, binary, message) {    for (handler in .wsconns[[as.character(handle)]]$.messageCallbacks) {        result <- try(handler(binary, message))        if (inherits(result, "try-error")) {            .wsconns[[as.character(handle)]]$close()            return()        }    }}("95065952", FALSE, "{\"method\":\"update\",\"data\":{\".clientdata_output_summary1_hidden\":true,\".clientdata_output_plots1_hidden\":false}}"),     <environment>), error = .rcpp_error_recorder)
31: .Call("httpuv_run", PACKAGE = "httpuv", timeoutMillis)
32: run(timeoutMs)
33: service(timeout)
34: serviceApp()
35: tryCatchList(expr, classes, parentenv, handlers)
36: tryCatch(while (!.globals$stopped) {    serviceApp()    Sys.sleep(0.001)}, finally = {    timerCallbacks$clear()})
37: runApp(Sys.getenv("SHINY_APP"), port = port, launch.browser = FALSE,     workerId = Sys.getenv("WORKER_ID"))
aborting ...
Segmentation fault (core dumped)

Winston Chang

unread,
Sep 9, 2013, 4:20:30 PM9/9/13
to shiny-...@googlegroups.com
Alberto, is it possible so send the source code, along with step-by-step instructions on how to reproduce the problem? You can send it directly, off-list, if you don't want to make it public.

Thanks,
Winston


Winston Chang

unread,
Sep 14, 2013, 9:41:41 PM9/14/13
to shiny-...@googlegroups.com
Hi Alberto -

I've played around with the code you sent me, and the problem seems to be with the xlsx library -- if you comment out the library(xlsx), it seems to work. I think the problem is somehow related to rJava, and will investigate some more.

-Winston

Alberto Mirisola

unread,
Sep 15, 2013, 2:34:45 AM9/15/13
to shiny-...@googlegroups.com
Hi Winston,
Thank you!
Now it works!

- Alberto

Maximilian Amberg

unread,
Jul 15, 2021, 9:37:08 AM7/15/21
to Shiny - Web Framework for R

Hi,

I have built a Shiny app (using the golem framework) and have (so far) deployed it via the shinyapps.io-server making use of GitHub Actions. In this webtool, users can select inputs (also in the form of a checkbox) upon which the data is subsetted and graphs & datatables are produced. While the app is working locally, error messages show up from time to time when visiting the webpage on the shinyapps.io-server: "Disconnected from the server: Reload".
For reference, here is the logged messages that I focus on:
2021-07-13T12:24:26.495243+00:00 shinyapps[4159264]: *** caught segfault *** 2021-07-13T12:24:26.495244+00:00 shinyapps[4159264]: address 0x5573328516d8, cause 'memory not mapped'
Followed by a traceback starting with:
2021-07-13T12:24:26.497790+00:00 shinyapps[4159264]: 1: policy %in% input$recycling_option_choice_checkbox
and ending in:
2021-07-13T12:24:56.324135+00:00 shinyapps[4159264]: 91: local({ if (identical(.Platform$OS.type, "unix")) { whoami <- system("whoami", intern = TRUE) if (identical(whoami, "root")) { stop("Attempted to run application as whoami=", whoami, "; USER=", Sys.getenv("USER")) } } ... 2021-07-13T12:24:56.324136+00:00 shinyapps[4159264]: An irrecoverable exception occurred. R is aborting now ...

Whenever users belong to the same instance, they get kicked out as soon as others experience a disconnection from the server. However, this does not rule out that users experience disconnections when being the single user of an instance. Please find the full log-file attached.

My first starting points:
Specifically: Referring to policy %in% input$recycling_option_choice_checkbox in particular

  1. My code looks as follows:
    df_subset_long <- df_final_long %>% dplyr::filter( policy_type == input$carbon_price_choice, policy %in% input$recycling_option_choice_checkbox, monetary_group_type == input$monetary_group_type_choice, soceco_group_type == "Keine", outcome_type == input$outcome_type_choice, statistics_type == input$statistics_type_choice )
    This type of subsetting has always worked out but at some point started to fail from time to time (strangly enough, not every time it is initiated by an actionButton).

General starting points:

  1. Links like https://groups.google.com/g/shiny-discuss/c/aPaAPQpVkdM/m/ZAxtB2MStd4J and https://stackoverflow.com/questions/67511409/problem-with-directory-when-deploying-app-on-shinyapps indicate that there may be problems with certain packages/dependencies. However, this is in general quite difficult to check since changes that have been made locally would have to be deployed and checked on the shinyapps.io server (again and again). E.g. I do not use the xlsx-package mentioned in the first link (creating a problem related to the rJava packages there).
  2. As the app is working locally, I have also found a number of avenues to investigate on
    https://support.rstudio.com/hc/en-us/articles/229848967-Why-does-my-app-work-locally-but-not-on-shinyapps-io-
    However, I have so far not found a solution to the problem described above.

I would be grateful if you (@Winston) could give me some advice!
Best,
Maxl

logs.txt
Reply all
Reply to author
Forward
0 new messages