You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IDE goes blank and hangs in a long-running function writing to console #12130
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.
Execute R script
forever <- function() {
while (TRUE) {
message("This is the message that never ends. It goes on and on my friends.")
}
}
forever()
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
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.
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.
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.
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.
Activity
timtmok commentedon Oct 28, 2022
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.
timtmok commentedon Oct 31, 2022
Looks like Electron does cap the nodes to 1000. It actually processes the events much faster than Qt and
VirtualConsole.javaaggregates the output to prevent updating the DOM too quickly. This was done to address: #5518The 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.
timtmok commentedon Nov 1, 2022
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.
jonvanausdeln commentedon Nov 2, 2022
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.
jonvanausdeln commentedon Nov 2, 2022
Didn't mean to close after last comment. .wrong button..
timtmok commentedon Nov 2, 2022
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.
jonvanausdeln commentedon Nov 2, 2022
I agree.. I'm going to close this and wait for the virtualization work.