Repository navigation
Feature/virtual scroller - #7568
Conversation
| this._MAX_VISIBLE_BUCKETS = 10; | ||
|
|
||
| // we use this style to keep the elements in the DOM for screen readers | ||
| this._HIDDEN_STYLE = "org-rstudio-core-client-theme-res-ThemeStyles-visuallyHidden"; |
There was a problem hiding this comment.
Have you tested this in a production build? GWT obfuscates class names, so you will either need to pass the class name into the setup method at runtime or tell GWT to use a non-obfuscated name.
| return; | ||
|
|
||
| // *** _CONSTANTS *** | ||
| this._DEBUG = true; |
There was a problem hiding this comment.
Should this be disabled by default?
| this._DEBUG = true; | ||
| this._SCROLL_DEBOUNCE_MS = 500; | ||
| this._BUCKET_MAX_SIZE = 50; | ||
| this._MAX_VISIBLE_BUCKETS = 10; |
There was a problem hiding this comment.
These parameters are probably somewhat machine dependent (i.e. with more hardware you can have more buckets w/o noticeable performance degradation), so it'd be nice if they could be set via an advanced (no UI) option; your call.
There was a problem hiding this comment.
I partially also picked this due to it just feeling better, in my opinion, to have a smaller scrollbar and having more fine motor control over what you see in the window. Once the window becomes saturated it's quite difficult to quickly get to the line that you want, it's why I clear in my terminal pretty often.
I'll file an enhancement to make this customizable though.
There was a problem hiding this comment.
There's also interaction with our server-side (I think) console-output limiting logic to consider. For example, try this sequence:
> for (i in 1:2000) cat(c(i, "\n"))
1000
1001
...
2000Notice that you only see the output from 1000 - 2000 (but still see the original prompt with no indication stuff is missing in between; prior to this change the prompt would have been lost, too).
> for (i in 2001:4000) cat(c(i, "\n"))
3000
3001
...
4000Now you can scroll back and indeed are seeing > 1000 lines, but these gaps are unexpected, I think.
| this.jumpToLatestButton.onclick = function() { | ||
| self._jumpToBottom(); | ||
| self._setJumpToLatestVisible(false); | ||
| document.getElementById("rstudio_console_output").focus(); |
There was a problem hiding this comment.
This would need to be removed to make the virtual scroller usable in other panes. Maybe it should be supplied as a callback?
| // only load the virtual scroller if enabled in prefs | ||
| if (prefs_.limitConsoleVisible() && | ||
| parent_ != null && | ||
| !VirtualConsole.virtualScrollerInitialized_ && |
There was a problem hiding this comment.
Nit: VirtualConsole. prefix is unnecessary (here and elsewhere)
There was a problem hiding this comment.
I really like prefixing it to make it explicit that we're referencing something static but if it's not how we do it in our style guide that's fine.
|
|
||
| private static final ExternalJavaScriptLoader virtualScrollerLoader_ = | ||
| new ExternalJavaScriptLoader(VirtualScrollerResources.INSTANCE.virtualscrollerjs().getSafeUri().asString()); | ||
| private static VirtualScrollerNative virtualScrollerNative_; |
There was a problem hiding this comment.
Maybe I'm misreading this, but wouldn't we need one instance of VirtualScrollerNative per VirtualConsole?
There was a problem hiding this comment.
Addressed in the commit I just pushed. Unfortunately just making it an instance variable wasn't an option as the way that VirtualConsole works is frankly kind of broken. A new instance is created pretty much any time you hit enter and there's a lot of cases where it's created with a null parent. I tried to decouple it from Gin but I wasn't able to make a clean break there so I wholly detached VirtualScroller from the VirtualConsole, which I prefer anyway.
gtritchie
left a comment
There was a problem hiding this comment.
Some initial comments; I still need to do accessibility testing but want to get this feedback written down in the meantime.
| if (prefs_.limitVisibleConsole().getValue() != initialLimitVisibleConsole_) | ||
| { | ||
| initialLimitVisibleConsole_ = prefs_.limitVisibleConsole().getValue(); | ||
| if (Desktop.isDesktop()) |
There was a problem hiding this comment.
You can replace this if/else with a single call to restartRequirement.setRestartRequired() (added fairly recently).
| range.appendRight(text, 0); | ||
| } | ||
| else | ||
| } else |
There was a problem hiding this comment.
nit, we usually put else on a separate line
| @Override | ||
| public boolean limitConsoleVisible() | ||
| { | ||
| return limitConsoleVisible_; |
There was a problem hiding this comment.
As discussed elsewhere, be great to have some unit-tests for the virtual scrolling mechanism here and/or in the ConsoleOutputWriteTests.
| this._DEBUG = true; | ||
| this._SCROLL_DEBOUNCE_MS = 500; | ||
| this._BUCKET_MAX_SIZE = 50; | ||
| this._MAX_VISIBLE_BUCKETS = 10; |
There was a problem hiding this comment.
There's also interaction with our server-side (I think) console-output limiting logic to consider. For example, try this sequence:
> for (i in 1:2000) cat(c(i, "\n"))
1000
1001
...
2000Notice that you only see the output from 1000 - 2000 (but still see the original prompt with no indication stuff is missing in between; prior to this change the prompt would have been lost, too).
> for (i in 2001:4000) cat(c(i, "\n"))
3000
3001
...
4000Now you can scroll back and indeed are seeing > 1000 lines, but these gaps are unexpected, I think.
|
Mentioned this in Slack, including here for completeness: Seeing a bug; after running (for example: for (i in 1:500) message(i), then reloading the browser page, the console output isn’t reloaded (console is blank). Same with Desktop (e.g. right-click on blank area of toolbar and “reload”). Works when I turn off the option you added. |
|
The accessibility command |
| @@ -0,0 +1,106 @@ | |||
| package org.rstudio.core.client.virtualscroller; | |||
There was a problem hiding this comment.
nit: missing comment header
| { | ||
| // If we get an error initializing the virtualScroller, log | ||
| // and no-op the error to continue non-virtualized | ||
| Debug.log(e.getMessage()); |
There was a problem hiding this comment.
Should we clear the loading_ flag here? (doesn't look like it effects correctness but would be consistent?)
|
This isn't done yet but I've been working on it as I can between support tickets. I just pushed the nitpick fixes and did a merge to have them in and updated. As of now:
|
|
So, been a stressful week debugging this stuff. Items 2 and 3 above weren't too bad, about a day each to figure out the right solutions for. Item 1 however... So the issue is that the data has no fewer than 5 (and maybe a 6th) different states that need to stay in sync: backend caching, frontend StringBuilder, frontend output Element, frontend bucket, frontend line_ variable. In addition to this, the backend seems to be doing some hidden trimming/data omission that I haven't yet found (beyond it's normal maxOutputLines trimming) such that not all of the data even ever makes it to the "ConsoleProcess::onStdout" function. There may be a layer deeper in the R that I haven't delved into yet that's doing this omission but that will take more time. The good news is now there is no data that would ever be shown in the old way that is ever lost while VirtualScroller is active. The remaining symptom is that single output chunks over 1000 lines seem to have some missing data but it's data you can't currently ever access anyway as these missing chunks are only before the final 1000 lines. I propose filing a bug for this issue as it may actually indicate something more insidious going on in a deeper lever of the ConsoleProcess and moving on from here. @gtritchie @kevinushey this should be ready to be looked at again. Thank you for your patience. |
|
@adamconroy: are you able to confirm that the example I described in #7568 (comment) is fixed? If not, I think that needs to be handled before this PR is merged. (I wasn't sure if it is indeed resolved or not based on your comment) |
|
Talked with Kevin and Jonathan and we are going to merge and file this as an issue to fix ASAP. |


Intent
Improve performance of the Console pane when a large amount of data has accumulated in that window.
Fixes #6042
Approach
Only show a moving window of message elements much like Slack and other similar programs. When scrolling up/down a set of elements (stored in "buckets") is added to the view while another bucket on the opposite end is hidden.
QA Notes
There is a lot of subtle DOM manipulation added to the console functionality here. It's fairly self-contained but it is very possible that there are cases where GWT code is trying to directly manipulate the DOM that I missed.
I think just putting as much varied content as possible into the console is the best place to start for testing. I'll be available to work closely with ya'll for testing here because it is such a quirky feature.