Skip to content

Conversation

@lord41ph4
Copy link
Contributor

@lord41ph4 lord41ph4 commented Apr 16, 2021

Fixes #1361

The non-responsiveness came from continuous listener adding while creating the cell that is not visible and be garbage collected immediately. Moving the getCell(..) call further down to be performed after the visibility check is avoiding unnessesary creation of elements.

…the continuous listener add/remove and garbage collection
@github-actions
Copy link

Hi lord41ph4,

Welcome to ControlsFX and thank you for taking time to contribute to this project.

We do not recognise you as a contributor. Can you please sign ControlsFX Individual Contributor Agreement: https://cla.controlsfx.org ?

@github-actions github-actions bot added the CLA label Apr 16, 2021
@abhinayagarwal
Copy link
Member

Hi @lord41ph4 ,

Can you add a Test to verify this change?

@abhinayagarwal abhinayagarwal changed the title #1361: check cell visibility before creation to get rid of the contin… TableView2: Check cell visibility before add/remove listener Apr 17, 2021
@lord41ph4
Copy link
Contributor Author

lord41ph4 commented Apr 18, 2021

@abhinayagarwal
Will do as soon I have time. :)

@github-actions github-actions bot added CLA-VERIFIED and removed CLA labels Apr 18, 2021
@Maxoudela
Copy link
Collaborator

Could you point out where the notable changes are? It seems that the diff is quite large because of a change in indenting.

Also, is this issue reproduced in the SpreadsheetView?

@lord41ph4
Copy link
Contributor Author

Hi @Maxoudela,
I did not change that much actually, it just looks much because I could get rid of the one if statement in the loop that was pointless, because the check was always true because of the continue couple of lines above, and thats why the formatting made the change that big. It is easier when you look the 2 commits (26e78f2 & 8339de5) separately, as the others just added unit tests for different cases. And as I personally like Hamcrest in my unit tests I added the dependency as well. The SpreadsheetView I did not try, and also did not look into its code. I don't know if that is enough explanation, if needed do not hesitate to ask for more. :D

produceUpdateLoad();

Duration timeTaken = measure(this::changeSelection);
assertThat(timeTaken, is(lessThan(MAX_DURATION_FOR_SELECTION_CHANGES)));
Copy link
Member

Choose a reason for hiding this comment

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

What is the logic behind the time taken by changeSelection always being less than 20s?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I gave a maximum of 1 second for each selection change (defined in line 70).

}

@Test
public void shouldHaveNoArtifacts_When_ScrollingVertically() {
Copy link
Member

Choose a reason for hiding this comment

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

This test passes even when the fix is not applied. Not sure if its supposed to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is supposed to be that way. I played around with the code and I thought this test could at least guarantee that the scrolling is not broken. I think it does not harm to have such tests, as they make the life easier when modifying the code

}

@Test
public void shouldNotFreeze_When_ScrollingVerticallyUnderLoad() {
Copy link
Member

Choose a reason for hiding this comment

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

This test passes even when the fix is not applied. Not sure if its supposed to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is also supposed to be that way. I first thought I could make the GUI freeze with this test, because I could see that the cells have not been reused before (8339de5). But I guess to make it freeze I need to use heavier cells, like with buttons or something like that. But as it didn't really freeze and the test was anyway written I just left it there.

}
}

if (isVisible) {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this check removed?

Copy link
Contributor Author

@lord41ph4 lord41ph4 May 29, 2021

Choose a reason for hiding this comment

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

Because of line 213 (continue statement) the isVisible variable was always true at this point.

@Maxoudela
Copy link
Collaborator

I'll modify the SpreadsheetView later on to remove the isVisible condition since it's indeed always true after the check with the continue is done.

The problem should not appear in the SpreadsheetView since the getCell call is done after the isVisible check in GridRowSkin

@abhinayagarwal abhinayagarwal merged commit cca9409 into controlsfx:jfx-13 Aug 21, 2021
@lord41ph4 lord41ph4 deleted the #1361_update_performance branch March 30, 2022 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not responsive gui when having many updates in a TableView2 and changing the selected row

3 participants