Skip to content
This repository was archived by the owner on Mar 27, 2023. It is now read-only.

Conversation

@Jinnie
Copy link
Contributor

@Jinnie Jinnie commented Oct 6, 2020

issue #5085

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • If applicable, have a visual design approval

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • clarity.design website / infrastructure changes
  • Other... Please describe:

What is the current behavior?

When Ivy is turned off, the displayedRows list accumulates old ghost items, which mess the proper child views visualization. Thus, after been filtered out, rows are not shown back when the filter is removed.

Issue Number: #5085

What is the new behavior?

Works fine both with and without Ivy

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Please note, that because of the complicated setup we can't make a test for the no-Ivy scenario. We can't have a test run with and without Ivy unless we run a new task with new test setup.

bbogdanov
bbogdanov previously approved these changes Oct 6, 2020
sis0k0
sis0k0 previously approved these changes Oct 6, 2020
Copy link
Contributor

@gnomeontherun gnomeontherun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've had a regression from fixes here before. I want to be 100% certain before we merge that this is correct. How have we tested this?

@Jinnie
Copy link
Contributor Author

Jinnie commented Oct 6, 2020

As I said, automated tests are not possible, so:

  1. Checked with enabled Ivy that it does not break any current tests. I didn't test with Ivy off, as many of our other tests are failing with Ivy off.
  2. Manually tested the following scenarios (both Ivy on and off):
    • no interference with the trackby functionalities - it keeps the proper items selected.
    • made sure the recently fixed issue of keeping detail pane open on refresh is okay.
  3. Made sure we're not skipping the view destruction, which was previously leading to memory leaks.
  4. Debugged the previously offending data list, which was accumulating dead records, thus leading to possible memory leaks.

Any other testing ideas or manually performed testing by the reviewers are welcome. I won't merge this for a couple of day more to allow for more reviews.

@Jinnie
Copy link
Contributor Author

Jinnie commented Oct 7, 2020

After today's tests I made a more precise selection of what should be removed - only the views marked as "destroyed". Without it - it was possible to get "pseudo-randomly" rearranged rows after update.

@gnomeontherun
Copy link
Contributor

Thanks, I wanted to be as certain as we can. It helps to put more of this detail into the issue PR description as well in the future.

@Jinnie
Copy link
Contributor Author

Jinnie commented Oct 7, 2020

Thanks form me too - it was good to have one more round - we found an issue. I'm postponing the unblocking with 1 more day.

Shijir
Shijir previously approved these changes Oct 7, 2020
// Necessary with Ivy off. See https://github.com/vmware/clarity/issues/4692
for (let i = this._displayedRows.length - 1; i >= 0; i--) {
if (this._displayedRows.get(i).destroyed) {
this._displayedRows.detach(i);
Copy link
Contributor

@Shijir Shijir Oct 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was due to an Angular bug—something along the lines of this: angular/angular#38648.

When ViewRef destroys itself independently without going through ViewContainerRef as we do in our WrappedRow's OnDestroy cycle, the ViewContainerRef still holds the reference to the ViewRef. And that results in out-of-sync views and ViewContainerRef. So we have to have this extra removal from the ViewContainerRef itself. Though I think, instead of ViewContainerRef.detach() which detaches the DOM view of undestroyed ViewRef, ViewContainerRef.remove() might be more appropriate here as we are trying to completely remove the views that are "impartially" destroyed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I started with the ViewContainerRef.remove() at first, but it was having some side effects. Then I saw that in other part of this same TS file we're using detach() and it worked better. But I'm not sure if I was doing the .destroyed check back then, so I'll give it a try, out of curiosity at least.
Thanks for the detailed review, Shijir!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, though it probably gets reclaimed after being detached, using remove gives us finer level of control and better protection against memory leaks. Updated all 3 PRs to use remove()

issue vmware-archive#5085
Signed-off-by: Ivan Donchev <idonchev@vmware.com>
@hippee-lee hippee-lee changed the base branch from master to next October 9, 2020 22:33
@hippee-lee hippee-lee dismissed stale reviews from Shijir, sis0k0, and bbogdanov October 9, 2020 22:33

The base branch was changed.

@hippee-lee
Copy link
Contributor

@Jinnie - fyi I updated the base branch to reflect the new default for the repo.

Copy link
Contributor

@Shijir Shijir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will approve it again. I am only a bit apprehensive we couldn't test it automatically. But I am sure @Jinnie tested well with both Ivy and Ivy off.

Copy link
Contributor

@bbogdanov bbogdanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about creating an issue or a discussion to revisit this code at some point in order to covert it with tests?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants