Skip to content

IDE goes blank and hangs in a long-running function writing to console #12130

Closed

Description

@jonvanausdeln

System details

RStudio Edition : Desktop
RStudio Version :  2022.12.0-daily+258
OS Version      : Windows 11 & MacOS 12.4
R Version       : 4.2.1

Steps to reproduce the problem

Discovered when testing #12059 see #12059 (comment). A long running function that is writing to the console will make the ide window go blank and has to be force quite.

  1. Execute R script
forever <- function() {
  while (TRUE) {
    message("This is the message that never ends.  It goes on and on my friends.")
  }
}

forever()
  1. Let it run for a few minutes

Describe the problem in detail

The IDE window will go blank and hang. Process needs to be killed to proceed.
On windows this took less than 1 minute, on MacOS it was around 3 minutes. This also might be machine resource dependent.

Describe the behavior you expected

Code to continue executing and IDE to remain responsive

  • I have read the guide for submitting good bug reports.
  • I have installed the latest version of RStudio, and confirmed that the issue still persists.
  • If I am reporting an RStudio crash, I have included a diagnostics report.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

Activity

  1. added
    new
    and removed
    new
    on Oct 11, 2022
  2. timtmok commented on Oct 28, 2022

    @timtmok
    Contributor

    The issue appears to be how the content is displayed in the ACE editor.

    With Qt, it creates new HTML elements for each message output. The maximum message output that is created in the HTML is 1000 nodes (ie. 1000 lines). So it will scale with large output.

    Electron doesn't behave the same for some reason. It appends the message output to the existing node and uses a line break. This bloats the memory and eventually overwhelms the renderer.

    This should be fixable by getting the output to render as a new node. Then it's probably ACE editor that handles the scrollback and limiting the nodes to prevent the memory bloat.

  3. timtmok commented on Oct 31, 2022

    @timtmok
    Contributor

    Looks like Electron does cap the nodes to 1000. It actually processes the events much faster than Qt and VirtualConsole.java aggregates the output to prevent updating the DOM too quickly. This was done to address: #5518

    The current implementation is a stop-gap until we can address the tech debt of how to better handle fast console output. Kevin suggested virtualization of the console output in the fix for the above mentioned issue.

    So I think this might happen with Qt but is very difficult since it processes the R callbacks much slower.

  4. timtmok commented on Nov 1, 2022

    @timtmok
    Contributor

    I'll open another issue to track the tech debt. The fix was a tweak to the bandaid that was done a couple of years ago.

  5. self-assigned this
    on Nov 1, 2022
  6. jonvanausdeln commented on Nov 2, 2022

    @jonvanausdeln
    Author

    Tested on 2022.12.0-preview+307

    It was marginally better on Windows 11, but hung after about 2 minutes. MacOS 12.6 hung after about 4 minutes.

    Given there was another issue opened to better handle this, I would be okay closing for this Elsbeth release. I would like another opinion before I close.

  7. jonvanausdeln commented on Nov 2, 2022

    @jonvanausdeln
    Author

    Didn't mean to close after last comment. .wrong button..

  8. timtmok commented on Nov 2, 2022

    @timtmok
    Contributor

    I could lower the limit even more but it still comes down to the render thread getting overwhelmed. Refactoring the console output to use virtualization is too risky at this point and there wouldn't be time to get it implemented by Friday.

    Virtualization would allow the console output to update and not be burdened with a massive amount of messages while allowing scrollback to view the history.

  9. jonvanausdeln commented on Nov 2, 2022

    @jonvanausdeln
    Author

    I agree.. I'm going to close this and wait for the virtualization work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugelectrontech debt

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions