Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List virtualization fixes #10285

Merged
merged 5 commits into from
Feb 19, 2023
Merged

List virtualization fixes #10285

merged 5 commits into from
Feb 19, 2023

Conversation

grokys
Copy link
Member

@grokys grokys commented Feb 9, 2023

What does the pull request do?

Fixes some issues with the new virtualization system introduced in #9677:

  • When items are removed and the list is scrolled, ensure that we cause the extent to change by adjusting the size returned from VirtualizingStackPanel.MeasureOverride. This was broken previously due to two problems:
    • We weren't setting _startUUnstable when items were removed before the realized range
    • We were clamping the stand and end indexes too late when calculating the viewport, meaning that firstIndexU was calculated with a non-clamped index, which caused the items to be realized in the wrong position
  • There was a problem in ScrollContentPresenter whereby if the viewport or extent were changed the offset wasn't being coerced, leading to an offset beyond the extent of the scroll

- Before we were clamping indexes too early, meaning that `firstIndexU` was calculated with a non-clamped index
- `_startUUnstable` needs to be set when the remove happens before the realized elements
If viewport or extent were changed, this could affect the current offset so make sure we coerce the offset during arrange.
@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0029806-beta. (feed url: https://pkgs.dev.azure.com/AvaloniaUI/AvaloniaUI/_packaging/avalonia-all/nuget/v3/index.json) [PRBUILDID]

@grokys grokys marked this pull request as ready for review February 15, 2023 17:42
@grokys grokys changed the title WIP: List virtualization fixes List virtualization fixes Feb 15, 2023
@adirh3
Copy link
Contributor

adirh3 commented Feb 18, 2023

@grokys maybe it's a bit off topic for this PR, but my app crashes on index out of range due toto this method giving a negative index using ItemsControl - https://github.com/AvaloniaUI/Avalonia/blob/7da9bb9d434ecb70e5ef2fc7af768067c43709f1/src/Avalonia.Controls/VirtualizingStackPanel.cs#LL491C28-L491C28

@grokys
Copy link
Member Author

grokys commented Feb 19, 2023

@adirh3 i don't suppose you have a minimal repro do you? Hard to know what's going wrong from just your description.

@adirh3
Copy link
Contributor

adirh3 commented Feb 19, 2023

@adirh3 i don't suppose you have a minimal repro do you? Hard to know what's going wrong from just your description.

As usual I can't repro anything outside of my app :/
The issue is that GenerateElements calls GetOrCreateElement with a negative index which cause an OutOfRangeException.
I will try to make a repro but TBH I doubt it will happen in empty app 😅

Copy link
Member

@maxkatz6 maxkatz6 left a comment

Choose a reason for hiding this comment

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

Let's merge it, and see if somebody will find a repro for the master branch.

@maxkatz6 maxkatz6 merged commit 3e3dbb1 into master Feb 19, 2023
@maxkatz6 maxkatz6 deleted the fixes/virtualization-fixes branch February 19, 2023 22:28
@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0030261-beta. (feed url: https://pkgs.dev.azure.com/AvaloniaUI/AvaloniaUI/_packaging/avalonia-all/nuget/v3/index.json) [PRBUILDID]

@grokys
Copy link
Member Author

grokys commented Feb 20, 2023

In the absence of a repro, a stacktrace might help.

@timunie
Copy link
Contributor

timunie commented Feb 20, 2023

@grokys is this maybe related? #10399 (comment)

If so, the issue seems not to be solved yet.

@adirh3
Copy link
Contributor

adirh3 commented Feb 20, 2023

Will give stack trace later today.
FYI I reproduced this issue using the nightly build of thus PR, so it definitely did not solve it.

@adirh3
Copy link
Contributor

adirh3 commented Feb 25, 2023

@grokys @maxkatz6 Sorry took longer than expected -
image
More debug info -
image

Not sure if it makes sense, but I will try to add || index < 0 to the if return condition and see if that helps without generating new bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants