Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updateAceEditor causes out of memory error on chrome #83

Open
stewerner opened this issue Apr 19, 2023 · 1 comment
Open

updateAceEditor causes out of memory error on chrome #83

stewerner opened this issue Apr 19, 2023 · 1 comment

Comments

@stewerner
Copy link

stewerner commented Apr 19, 2023

I'm currently trying to use aceEditor() to display a log file (which is continuously updated). For this I set readOnly = TRUE.

However, despite the fact that (as intended) I can't undo (CTRL + Z) the changes caused by updateAceEditor the undo stack is updated for each modification of the displayed text, which finally leads to chrome's out of memory error:

image

Here is an example to reproduce this behaviour (exaggerated updating rate):

library(shiny)
library(shinyAce)

ui <- fluidPage(
  aceEditor(
    outputId = "myeditor",
    height = "82vh",
    value = "",
    mode = "text",
    readOnly = TRUE
  )
)

server <- function(input, output, session) {
  log <- reactiveVal()
  observe({
    invalidateLater(300)
    log(c(isolate(log()), paste(Sys.time(), "- This is going to pile-up in the ace.js undo stack, despite using readOnly = TRUE")))
  })
  observeEvent(log(), {
    updateAceEditor(session, "myeditor", value = paste0(log(), collapse = "\n"))
  })
}

shinyApp(ui, server)

I think it would be useful to disable the undo stack when readOnly = TRUE or updateAceEditor is used. Another option would be to provide a function to reset the undo stack.

Edit: introducing the editor option mergeUndoDeltas: true | false | 'always'; could be another approach.

@vnijs
Copy link
Collaborator

vnijs commented Apr 20, 2023

That makes sense. I'd be happy to review a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants