Maximum call stack size exceeded only on chrome

1,392 views
Skip to first unread message

Ozgen Eren

unread,
Sep 24, 2018, 8:14:20 AM9/24/18
to Chromium-discuss

12:34 PM (2 hours ago)
I have an analysis Rshiny application that first checks if there were any previously done analysis and if there is, it reads it and shows it as a table. Otherwise user can run analysis himself and see the results in the same table. Everything works perfectly fine except I have a specific problem with chrome. 

Only when chrome is used (works in IE, safari, firefox), and there is a saved existing analysis result, Rshiny reads the file, I confirmed that it prepares the datatable correctly (~3000 rows) but does not show it (although I return the correct datatable to renderDataTable). However when I run the analysis, it is able to create the table and show it as it was supposed to using the same part of the code. So the problem is only apparent when the datatable is read from a file for the first time (although read is successfully completed and datatable was successfully prepared). And when I check the console I see "Maximum call stack size exceeded" error for that case. 

Could stack size be relevant with the datatable I am initially trying to show somehow? And would increasing the stacksize be a solution? If yes, how do I achieve that from R?


Exact error I am getting:

htmlwidgets.js:732 Uncaught RangeError: Maximum call stack size exceeded
    at Object.window.HTMLWidgets.evaluateStringMember (htmlwidgets.js:732)
    at exports.OutputBinding.shinyBinding.renderValue (htmlwidgets.js:496)
    at exports.OutputBinding.onValueChange (output_binding.js:16)
    at exports.OutputBinding.delegator.(:6158/anonymous function) [as onValueChange] (http://127.0.0.1:6158/htmlwidgets-1.2/htmlwidgets.js:112:23)
    at OutputBindingAdapter.onValueChange (output_binding_adapter.js:21)
    at ShinyApp.receiveOutput (shinyapp.js:354)
    at ShinyApp.<anonymous> (shinyapp.js:566)
    at ShinyApp._sendMessagesToHandlers (shinyapp.js:551)
    at ShinyApp.dispatchMessage (shinyapp.js:537)
    at WebSocket.c.onmessage (shinyapp.js:112)

PhistucK

unread,
Sep 24, 2018, 8:20:51 AM9/24/18
to ozge...@gmail.com, Chromium-discuss
It sounds a bit like crbug.com/752081 (already fixed and released).
It basically talks about an infinite (or big enough) recursion within the JavaScript parser.
Thousands of those (or similar) -
a = ''
+ '' 
+ ''
+ ''
+ ''
+ '' 
Caused it.
I guess you are constructing the existing data using somehow and the parser recurs until it dies.

How is it the output constructed in your case?

PhistucK


--
--
Chromium Discussion mailing list: chromium...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss

---
You received this message because you are subscribed to the Google Groups "Chromium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discu...@chromium.org.

Ozgen Eren

unread,
Sep 24, 2018, 8:33:24 AM9/24/18
to Chromium-discuss, ozge...@gmail.com
I have further debugged it to find out the formatting of the rows (specifically coloring them by condition) causes this when number of rows is in the order of thousands. Output is generated like follows:

% this part is okay
      result <- scanResultsOrdered %>% 
        datatable(
          selection = 'single',
          extensions = c('FixedColumns', 'Buttons'),
          rownames=FALSE,
          options=list(
            #dom = 't',
            dom = 'Bfrtip',
            scrollX=TRUE,
            buttons = c(I('colvis'),'copy', 'print'),
            fixedColumns = TRUE,
            columnDefs = list(list(visible=FALSE, targets=match(columns2hide, colnames(scanResultsOrdered))-1L ))
          ))

% this part fails in chrome
      result <- result %>% formatStyle(
          'Root',
          target = "row",
          backgroundColor = styleEqual(unlist(scanResultsOrdered[[1]]) , values=c(rep("red", nRed),rep("yellow", nYel),rep("white", nWhi)))
        )


And below is a reproducable example (running it on chrome should lead to same problem when number of rows are too large and row formatting is used):

require(shiny)
library(dplyr)

ui <- fluidPage(
  titlePanel(title=h4("example", align="center")),
  mainPanel(
    DT::dataTableOutput('test')
  )
)

##server
server <- function(input, output){
  x<-tibble(a=c(1,2,3), color=c("red","yellow","white"))
  x<-tibble(a=1:(4*10^3), color=c(rep("red", 2*10^3), rep("yellow", 1*10^3), rep("white", 1*10^3) ))
  saveRDS(x,"./x.rds")
  
  output$test<-renderDataTable({
    data <- readRDS("./x.rds")
    result <- datatable(data,
              selection = 'single',
              rownames=FALSE,
              options=list(scrollX=TRUE)
              ) 
    
    result <- result %>% 
      formatStyle(
        'color',
        target = "row",
        backgroundColor = styleEqual(unlist(data[["color"]]) , values=c(rep("red", 2*10^3),rep("yellow", 1*10^3),rep("white", 1*10^3)))
      )
    return(result)
  })
}

shinyApp(ui = ui, server = server)

PhistucK

unread,
Sep 24, 2018, 8:34:31 AM9/24/18
to ozge...@gmail.com, Chromium-discuss
Sorry, I am not very strong in non-JavaScript browser languages. :P

PhistucK

Ozgen Eren

unread,
Sep 24, 2018, 8:38:33 AM9/24/18
to Chromium-discuss, ozge...@gmail.com
Haha, no problem! 

I actually think that increasing "Max Call Stack Size" will solve the problem but I dont know how. For example here: http://2ality.com/2014/04/call-stack-size.html they show Chrome has less than other browsers so I think it makes sense that it only doesn't work on Chrome when number of rows increase.

PhistucK

unread,
Sep 24, 2018, 9:17:05 AM9/24/18
to ozge...@gmail.com, Chromium-discuss
It is not configurable, but assuming your code ends up creating a concatenation or similar of many parts, it is reasonable to think it is a V8 bug.
Can you show the resulting JavaScript for a smaller data-set?

PhistucK

Reply all
Reply to author
Forward
0 new messages