I'm working on a quite complicated dashboard written in R using Shiny and ggplot2.
At the moment it was written everything worked fine, but after some time (data is updated daily) it started to segfault while rendering specific pages.
I can reproduce the problem by opening specific tab with 12 ggplot graphs.
Console output at the moment of failure looks like this:
dashboard_1 | address 0x194b1, cause 'memory not mapped'
dashboard_1 |
dashboard_1 | Traceback:
dashboard_1 | 1: mapply(FUN = f, ..., SIMPLIFY = FALSE)
dashboard_1 | 2: Map(build_grob, plot$layer, data)
dashboard_1 | 3: ggplot_gtable(data)
dashboard_1 | 4: print.ggplot(result$value)
dashboard_1 | 5: print(result$value)
dashboard_1 | 6: eval(expr, envir, enclos)
dashboard_1 | 7: eval(expr, pf)
dashboard_1 | 8: withVisible(eval(expr, pf))
dashboard_1 | 9: evalVis(expr)
dashboard_1 | 10: capture.output(print(result$value))
...
dashboard_1 | 65: tryCatchOne(expr, names, parentenv, handlers[[1L]])
dashboard_1 | 66: tryCatchList(expr, classes, parentenv, handlers)
dashboard_1 | 67: 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() } }})("62978544", FALSE, "{\"method\":\"update\",\"data\":{\"daterange:shiny.date\":[\"2014-04-26\",\"2015-04-26\"],\"group_by\":\"weeks\"}}"), <environment>), error = .rcpp_error_recorder)
dashboard_1 | 68: withCallingHandlers(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() } }})("62978544", FALSE, "{\"method\":\"update\",\"data\":{\"daterange:shiny.date\":[\"2014-04-26\",\"2015-04-26\"],\"group_by\":\"weeks\"}}"), <environment>), error = .rcpp_error_recorder), warning = .rcpp_warning_recorder)
dashboard_1 | aborting ...
dashboard_1 | Segmentation fault
rmreports_dashboard_1 exited with code 139
I would like to trace the root cause and introduce changes to prevent segfault from happening. What is the best way to approach this problem?
I was searching your problem was able to find this thread. https://github.com/hadley/dplyr/issues/322
Which says to try to update 'dplyr' with 'devtools'.
"devtools::install_github("hadley/dplyr", build_vignettes = FALSE)"
Related
A section of my R Shiny script is giving me a headache. In short, the script receives two data tables: data_tran and contam_datafile. data_tran is queried with contam_datafile for any matching IDs under the "Feature.ID" column. A user is then given the option to either keep the matching IDs, remove
the matching IDs (by turning to zeros), or to do nothing.
data_tran_contam_filt_react = reactive({
if(input$contam_filter == "Remove"){
data_tran = data_tran_react()
contam_datafile = contam_datafile()
rownames(data_tran) = data_tran$Feature.ID
# data_tran = data_tran[ ! data_tran$Feature.ID %in% contam_datafile$Feature.ID,]
data_tran[contam_datafile$Feature.ID,!names(data_tran) %in% c("Consensus.Lineage","Feature.ID","ReprSequence","rowID")] = 0
rownames(data_tran) = 1:nrow(data_tran)
}
if(input$contam_filter == "Analyze"){
data_tran = data_tran_react()
contam_datafile = contam_datafile()
data_tran = data_tran[data_tran$Feature.ID %in% contam_datafile$Feature.ID,]
}
if(input$contam_filter == "No action"){
data_tran = data_tran_react()
}
})
This works when I run the R Shiny app locally within a combined ui/server script. I've tested it with several datasets and it's all good. However, when I transfer it to an Ubuntu LTS-based server, and select the option to "Remove", the app fails and provides the "Error in Summary.factor: ‘max’ not meaningful for factors" within the log files. All other aspects of the R Shiny script works locally and remotely except for the "Remove" function. I'll include the full error log below.
I don't get it. Any help would be appreciated.
Thanks
Warning in Ops.factor(i, 0L) : ‘>=’ not meaningful for factors
Warning: Error in Summary.factor: ‘max’ not meaningful for factors
86: stop
85: Summary.factor
84: [<-.data.frame
82: <reactive:data_tran_contam_filt_react> [DELETED]
66: data_tran_contam_filt_react
65: <reactive:data_long_react> [DELETED]
49: data_long_react
45: observe [DELETED]
44: <observer>
1: runApp
Warning: Error in Summary.factor: ‘max’ not meaningful for factors
107: <Anonymous>
106: stop
105: data_long_react
104: exprFunc [DELETED]
103: widgetFunc
102: ::
htmlwidgets
shinyRenderWidget
101: func
88: renderFunc
87: renderFunc
83: renderFunc
82: output$proc_main_alt
1: runApp
Warning: Error in Summary.factor: ‘max’ not meaningful for factors
107: <Anonymous>
106: stop
105: data_tran_contam_filt_react
104: exprFunc [DELETED]
103: widgetFunc
102: ::
htmlwidgets
shinyRenderWidget
101: func
88: renderFunc
87: renderFunc
83: renderFunc
82: output$proc_new_data
1: runApp
Execution halted
Ignore the "DELETED". It's just a server address and contains some identifying information.
Thank you to Ric Villalba for the suggestion.
This turned out to be a simple R version issue, and likely caused by the change in stringsAsFactors between R 3.x and 4.x. It sent me down a whole 8-hour path of trying to update R and encountering package issues, but I have it all sorted out now.
Cheers
Seeing inconsistent results with dataTableOutput (https://github.com/rstudio/DT). When I start shiny from an R console, the first time I run the app the height argument in dataTableOutput() causes the app to crash. If I then CTRL-C to stop shiny, then shiny::runApp(), then the app thenceforth works as expected. Not passing the height is okay locally. The box is filled in and sizes its height automatically. However, when loading the app on shinyapps.io, the box is always empty and has a small height (let's say 60px). No matter what I do on shinyapps.io, if the the height is, e.g., height=300, then the app will always crash. No CTRL-C will work on shinyapps.io. Sometimes the app will refuse to start locally when "height=300" is present, but if I comment out dataTableOutput completely, re-run shiny::runApp(), then bring dataTableOutput back without restarting shiny, then the app loads okay.
The error:
Warning: Error in dataTableOutput: unused argument (height = "200")
100: h
99: .handleSimpleError
98: dots_list
97: div
96: dots_list
95: div
94: dots_list
93: div
92: box
91: dots_list
90: div
89: fluidRow
88: dots_list
87: div
86: column
85: dots_list
84: div
83: fluidRow
82: dots_list
81: div
80: tabItem
79: lapply
78: tabItems
77: dots_list
76: tags$section
75: dots_list
74: div
73: dashboardBody
72: tagAssert
71: dashboardPage
70: ..stacktraceon..
69: eval
68: eval
67: sourceUTF8
66: func
65: uiHandlerSource
64: handler
63: handler
62: handler
61: handlers$invoke
60: withCallingHandlers
59: domain$wrapSync
58: promises::with_promise_domain
57: captureStackTraces
56: withCallingHandlers
55: withLogErrors
54: withCallingHandlers
53: force
52: withVisible
51: withCallingHandlers
50: domain$wrapSync
49: promises::with_promise_domain
48: captureStackTraces
47: doTryCatch
46: tryCatchOne
45: tryCatchList
44: tryCatch
43: do
42: hybrid_chain
41: force
40: withVisible
39: withCallingHandlers
38: domain$wrapSync
37: promises::with_promise_domain
36: captureStackTraces
35: doTryCatch
34: tryCatchOne
33: tryCatchList
32: tryCatch
31: do
30: hybrid_chain
29: handler
28: func
27: compute
26: doTryCatch
25: tryCatchOne
24: tryCatchList
23: tryCatch
22: rookCall
21: <Anonymous>
20: evalq
19: evalq
18: doTryCatch
17: tryCatchOne
16: tryCatchList
15: doTryCatch
14: tryCatchOne
13: tryCatchList
12: tryCatch
11: execCallbacks
10: run_now
9: service
8: serviceApp
7: ..stacktracefloor..
6: withCallingHandlers
5: domain$wrapSync
4: promises::with_promise_domain
3: captureStackTraces
2: ..stacktraceoff..
1: shiny::runApp
The code (two example boxes although one is enough to show the issue):
dashboardPage(
dashboardHeader(title = 'Energy comparison'),
dashboardSidebar(
sidebarMenu(
...
menuItem('Stacked', tabName = 'table', icon = NULL)
)
),
dashboardBody(
tabItems(
...
tabItem(
tabName = 'table',
fluidRow(
column(6,
fluidRow(
box(title = 'Annual energy by source',
solidHeader = TRUE, status = 'primary', width = 12,
dataTableOutput('tab1') # Always works locally.
# Doesn't crash shinyapps.io
# but always show a tiny box
# with no data.
)
)
),
column(6,
fluidRow(
box(title = 'Annual energy by source %',
solidHeader = TRUE, status = 'primary', width = 12,
dataTableOutput('tab2', height="auto")
# height = "auto" or "300"
# Causes error sporadically locally.
# Can get it working locally by removing "height=..."
# then reloading the page while shiny is running.
# But this always crashes on shinyapps.io.
)
)
)
)
)
)
)
)
TAG: dataTableOutput
There are two functions of dataTableOutput, one which is present in shiny package which does not have height argument and another in DT package. I don't know if you are loading the DT package at all but it is better to mention explicitly that you want to use dataTableOutput from DT package.
DT::dataTableOutput('tab2', height="auto")
I got error msg when converting tex to pdf using texi2pdf function in Rstudio.
tools::texi2pdf('test.tex')
and the error msg I got:
Error in system(paste(shQuote(texi2dvi), if (quiet) "--quiet" else "", :
(converted from warning) running command '"C:\CTEX\MiKTeX\miktex\bin\texi2dvi.exe" --quiet --pdf "test.tex" --max-iterations=20 -I "C:/Program Files/R/R-3.5.1/share/texmf/tex/latex" -I "C:/Program Files/R/R-3.5.1/share/texmf/bibtex/bst"' had status 1
1: tools::texi2pdf("test.tex")
2: texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, texi2dvi = texi2dvi, texinputs = texinputs, index = index)
3: system(paste(shQuote(texi2dvi), if (quiet) "--quiet" else "", if (pdf) "--pdf" else "", shQuote(file), extra), intern = TRUE, ignore.stderr = TRUE)
4: .signalSimpleWarning("running command '\"C:\\CTEX\\MiKTeX\\miktex\\bin\\texi2dvi.exe\" --quiet --pdf \"test.tex\" --max-iterations=20 -I \"C:/Program Files/R/R-3.5.1/share/texmf/tex/latex\" -I \"C:/Program Files/R/R
5: withRestarts({
.Internal(.signalCondition(simpleWarning(msg, call), msg, call))
.Internal(.dfltWarn(msg, call))
}, muffleWarning = function() NULL)
6: withOneRestart(expr, restarts[[1]])
7: doWithOneRestart(return(expr), restart)
I am running windows10, R version 3.5.1 , RStudio 1.1.463 and CTeX_2.9.2.164.
Anyone could help me with this problem? Thanks.
I have to build a Shiny-Board, there I need to get more then 10k rows from the Google Analytics Reporting API. For this I use my own Google API-Project
Doing this in RStudio works perfectly and I can get as much rows I want. If I do this in shiny I don´t get a problem getting less then 10k rows if I want to get more I get the following Error:
2017-08-17 14:12:55> Fetched: landingPagePath city date sourceMedium sessions newUsers bounceRate pageviewsPerSession avgSessionDuration transactions transactionRevenue. [10000] total results out of a possible [190119], Start-Index: 1
2017-08-17 14:12:55> Batching data into [20] calls.
Request #: 1 : 10001 : 20001 : 30001 : 40001 : 50001 : 60001 : 70001 : 80001 : 90001
2017-08-17 14:12:57> Request to profileId: ()
Warning: Error in f: Invalid dimension or metric:
Stack trace (innermost first):
114: f
113: FUN
112: lapply
111: googleAuthR::gar_batch
110: FUN
109: lapply
108: googleAuthR::gar_batch_walk
107: batchData
106: loop_ids
105: f
104: with_shiny
103: eventReactiveHandler [#405]
83: gadata
82: renderDataTable [#511]
81: func
80: origRenderFunc
79: output$Con_Table
4: <Anonymous>
3: do.call
2: print.shiny.appobj
1: <Promise>
I can call the same query in a differnt Timeframe (to don´t hit the 10k Limit) and it works with the dimensions and metrics.
Here is the query I use:
Auth
options("googleAuthR.webapp.client_id" = app_config$gaClientId)
options("googleAuthR.webapp.client_secret" = app_config$gaClientSecret)
options("googleAuthR.scopes.selected" =c("https://www.googleapis.com/auth/analytics.readonly"))
## Get auth code from return URL
token <- callModule(googleAuth, "login")
ga_accounts <- reactive({
req(token())
with_shiny(ga_account_list, shiny_access_token = token())
})
selected_id <- callModule(authDropdown, "auth_menu", ga.table = ga_accounts)
Query Data
ga<-with_shiny(google_analytics,
id = gaid,
start=(as.character(input$datestart)), end=(as.character(input$dateend)),
metrics = metric,
dimensions = dime,max=99999999,
shiny_access_token = token())
Some more information:
> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
> packageVersion("googleAnalyticsR")
[1] ‘0.4.1’
Does anybody has a idea what I´m missing?
Thanks to Mark Edmondson the problem is solved. Instead of using the V3 Version of the API just use the V4 Version. The call looks like this then:
ga<-with_shiny(google_analytics_4,
id = gaid,
date_range = c(as.character(input$datestart), as.character(input$dateend)),
metrics = metric,
dimensions = dime,anti_sample = TRUE,
shiny_access_token = token())
I've just installed Slimv to maximize lisp hacking, and I can't get anything useful out of the debugger.
If I type in the REPL
(+ 1 a)
I get the following error, which is fine
EVAL: variable A has no value
[Condition of type SYSTEM::SIMPLE-UNBOUND-VARIABLE]
...and it's accompanying insane backtrace
Backtrace:
0: [520] frame binding variables (~ = dynamically): | ~ SWANK::*SLDB-STEPPING-P* <--> NIL
No locals
1: [517] frame binding variables (~ = dynamically): | ~ SWANK::*SLDB-LEVEL* <--> 0
2: [514] frame binding variables (~ = dynamically): | ~ *PACKAGE* <--> #<PACKAGE COMMON-LISP-USER>
3: <1/507> #<COMPILED-FUNCTION SWANK::DEBUG-IN-EMACS>[506] frame binding variables (~ = dynamically): | ~ SWANK::*SLIME-INTERRUPTS-ENABLED* <--> T
4: <1/501> #<COMPILED-FUNCTION SWANK:INVOKE-SLIME-DEBUGGER>- #<COMPILED-FUNCTION SWANK::SWANK-DEBUGGER-HOOK-2-1>
5: <1/499> #<COMPILED-FUNCTION SWANK::SWANK-DEBUGGER-HOOK-2-1>- #<COMPILED-FUNCTION SWANK::SWANK-DEBUGGER-HOOK-2-1>
6: [498] frame binding variables (~ = dynamically): | ~ *DEBUGGER-HOOK* <--> NIL
7: <1/494> #<COMPILED-FUNCTION #:|877 882 (DEFINTERFACE CALL-WITH-DEBUGGER-HOOK (HOOK FUN) ...)-84-3-1|>- #<COMPILED-FUNCTION #:|877 882 (DEFINTERFACE CALL-WITH-DEBUGGER-HOOK (HOOK FUN) ...)-84-3-1|>
8: <1/489> #<COMPILED-FUNCTION SWANK-BACKEND:CALL-WITH-DEBUGGER-HOOK>- #<COMPILED-FUNCTION SWANK::SWANK-DEBUGGER-HOOK-2>
9: <1/486> #<COMPILED-FUNCTION SWANK::SWANK-DEBUGGER-HOOK-2>- #<COMPILED-FUNCTION SWANK::SWANK-DEBUGGER-HOOK-2>
10: [485] handler frame for conditions SWANK::INVOKE-DEFAULT-DEBUGGER
11: [479] compiled tagbody frame for #(NIL)
12: <1/473> #<COMPILED-FUNCTION SWANK:SWANK-DEBUGGER-HOOK>[471] frame binding variables (~ = dynamically): | ~ *DEBUGGER-HOOK* <--> #<COMPILED-FUNCTION SWANK:SWANK-DEBUGGER-HOOK>
13: <1/468> #<SYSTEM-FUNCTION INVOKE-DEBUGGER> 1[467] frame binding variables (~ = dynamically): | ~ SYSTEM::*PRIN-STREAM* <--> #<UNBOUND>
14: [464] frame binding variables (~ = dynamically): | ~ *PRINT-READABLY* <--> NIL
15: [461] frame binding variables (~ = dynamically): | ~ *PRINT-ESCAPE* <--> T
16: <1/458> #<SYSTEM-FUNCTION ERROR>[457] frame binding variables (~ = dynamically): | ~ SYSTEM::*ACTIVE-RESTARTS* <--> (#S(RESTART :NAME SWANK::RETRY :TEST #<COMPILED-FUNCTION SYSTEM::DEFAULT-RESTART..
17: [454] frame binding variables (~ = dynamically): | ~ SYSTEM::*CONDITION-RESTARTS* <--> NIL
18: [450] compiled block frame for SYSTEM::CHECK-VALUE
19: <1/445> #<COMPILED-FUNCTION SYSTEM::CHECK-VALUE>- NIL ~
So, what the heck is going on, and how can I fix it?
Well, this is working with the debugger then go to normal mode (press ESC)
and:
If you place the cursor on a numbered line in the Backtrace: section
and press Enter (in Normal mode) then the frame locals are displayed:
If you press Enter on a numbered line in the Restarts: section then
the corresponding restart is executed. The most frequently used
restarts have their own keyboard shortcuts: ,a selects the Abort, ,q
selects the Quit and ,n selects the contiNue restart. Let's choose
restart 1: [*ABORT] Return to SLIME's top level by pressing ,a:
you can learn more on it with the slimv tutorial