Skip to content

Data viewer doesn't auto refresh on source data changing #7066

Closed

Description

@adamconroy

In the R console:

1. d <- c(1,0)
2. View(d)
3. d <- c(2,0)

Notice that the data doesn't update and you have to View(d) again to see it. This must have been broken in the last performance PR on the DataViewer. Instinct says this should be fairly trivial to fix and some watcher just got lost in the mix.

Activity

  1. added this to the v1.3 milestone on Jun 8, 2020
  2. self-assigned this
    on Jun 8, 2020
  3. jmcphers commented on Jun 8, 2020

    @jmcphers
    Member
  4. adamconroy commented on Jun 18, 2020

    @adamconroy
    ContributorAuthor

    I actually can't reproduce this anymore. I wonder what happened. Could I get a quick sanity check @dfalty or @ronblum ?

  5. dfalty commented on Jun 22, 2020

    @dfalty

    Hey @adamconroy, I can reproduce this on my desktop (Mac 10.15.2) on 1.3.1039 but it looks fixed on 1.4.497 for me. Maybe something in 1.4 fixed this?

  6. adamconroy commented on Jun 22, 2020

    @adamconroy
    ContributorAuthor

    Thanks Darby. I'll play around with different versions and distros. I have a feeling it might be a heisenbug (goes away when I look at it in a dev environment) because the debug/logging infrastructure shunts away the error condition.

  7. kevinushey commented on Jun 26, 2020

    @kevinushey
    Collaborator

    Here's the JS callstack when the exception occurs:

    Screen Shot 2020-06-26 at 12 03 58 PM

    It's worth noting that this exception in older versions of RStudio as well (tested back to v1.1). It seems like (as @adamconroy said) there are multiple copies of this DataEditingTarget class receiving data update events here, but only one is actually "live".

    We can get a stack trace for each instantiation:

    Screen Shot 2020-06-26 at 12 38 16 PM

    Screen Shot 2020-06-26 at 12 38 31 PM

    Note that in the first case, we're getting an instantiation as part of getDefaultNamePrefix(); in the second case, we're getting it as part of just getEditingTarget(). That points to code here:

    final String defaultNamePrefix = editingTargetSource_.getDefaultNamePrefix(doc);
    final EditingTarget target = editingTargetSource_.getEditingTarget(
    doc, fileContext_, () -> getNextDefaultName(defaultNamePrefix));

    In theory, these should be receiving GWT-injected objects here:

    https://github.com/rstudio/rstudio/blob/master/src/gwt/src/org/rstudio/studio/client/workbench/views/source/editors/EditingTargetSource.java#L58-L74

    But it seems like those calls to get() are actually producing separate editing targets. Because of that, we end up with multiple editing targets attached to the same document, but with one of those targets being left half-initialized (but still listening for and incorrectly-handling events).

  8. kevinushey commented on Jun 26, 2020

    @kevinushey
    Collaborator

    I wonder if this comes down to isActive_ not being set in onActivate()? See e.g.

    @Override
    public void onActivate()
    {
    super.onActivate();
    if (view_ != null)
    {
    if (queuedRefresh_ != QueuedRefreshType.NoRefresh)
    {
    // the data change while the window wasn't active, so refresh it,
    // and recompute the size when finished
    doQueuedRefresh(true);
    }
    else
    {
    view_.onActivate();
    }
    }
    }
    @Override
    public void onDeactivate()
    {
    super.onDeactivate();
    view_.onDeactivate();
    isActive_ = false;
    }

    We set the flag in the constructor, but it seems like that flag should be set / unset in onActivate() / onDeactivate().

  9. adamconroy commented on Jun 26, 2020

    @adamconroy
    ContributorAuthor

    will give it a go! most of this file hasn't been touched in 5-6 years but I wouldn't be surprised if a change somewhere else broke this.

  10. adamconroy commented on Jun 26, 2020

    @adamconroy
    ContributorAuthor

    Look at that, it works...making a PR now. Great find! We still get the UmbrellaException sadly but at least the DataViewer updates.

  11. R-Hannibal commented on Jun 29, 2020

    @R-Hannibal

    Verified Fixed on: RStudio Version - 1.3.1054, R Version - 4.0.2, Windows 10 - Desktop

    Compared functionality between 1.3.1045 and 1.3.1054 builds, pre-fix View(d) has to be run a 2nd time to update the data, with the fix the data is updated immediately after running d <- c(2,0).

  12. self-assigned this
    on Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions