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

Nondeterministic layout bug #60

Open
pocketpixels opened this issue Apr 27, 2022 · 5 comments
Open

Nondeterministic layout bug #60

pocketpixels opened this issue Apr 27, 2022 · 5 comments

Comments

@pocketpixels
Copy link

Hi,
I am using the WaterfallGrid to layout thumbnails of different aspect ratios. The data (including the JPEG data for the thumbnail images) comes from a local database (using GRDB). But it is read synchronously on the main thread, and the order (and content) of the displayed items does not change.
However the layout does. Sometimes it displays correctly, sometimes it does not (thumbnails overlap). See attached video where I switch back and forth between tabs of the app (not an actual TabView, the tab content is recreated from scratch each time).

The following error/warning shows up in the Xcode console when the thumbnails end up overlapping, but not when the layout works correctly:

Bound preference ElementPreferenceKey tried to update multiple times per frame.

Any idea what is causing this, and how I could fix it?

Btw, as you can see in the video, the layout always animates on initial display. Is that by design? And can that be disabled, ideally without disabling animations during changes?

layout_bug.mov
@pocketpixels
Copy link
Author

I just realized that this is likely a duplicate of #52.

@pocketpixels
Copy link
Author

Maybe it is caused by a cycle in the view updates as discussed in this SO answer?

@AlexanderOtavka
Copy link

Looking at the code myself, I have noticed there is a race in the layout computation, since it uses DispatchQueue to delay updating the position and sizing: https://github.com/paololeonardi/WaterfallGrid/blob/master/Sources/WaterfallGrid/WaterfallGrid.swift#L32. That probably has something to do with the non-determinism we are seeing here.

@tarangpatel
Copy link

Any solution for this? Is this project still maintained?

@pocketpixels
Copy link
Author

I ended up implementing my own Waterfall layout from scratch back then. At least for the functionality I needed it wasn't difficult at all.

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

No branches or pull requests

3 participants