-
Notifications
You must be signed in to change notification settings - Fork 719
[css-grid-3][masonry] variable track sizes + dense packing has poor performance #9326
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
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Back to the original issue... Agreed that having N different track sizes means dense packing would require O(N) layout passes on items added after a gap, and this would be a problem. We suggest adopting a heuristic that brings this closer to O(2) for most cases:
It's possible, but unlikely, that an item's actual shortest height would be at a middling width; and this allows us to avoid a lot of that extra work in the much more common cases where the item definitely won't fit. |
Ok, discussing with @stwrt, new proposal for dense-packing in masonry:
This avoids doing more than one layout, and it works as expected for explicitly-placed masonry in mixed-size tracks as well as for auto-placed masonry in consistently-sized tracks, and does a reasonable job of dense-packing large collections of auto-placed masonry in mixed-size tracks as well. |
In step 2 does it have to be exactly the same used size, or could it be “an earlier gap in a track with a used size at least as large as this track”? |
Would have to be the same size to actually work; a larger track size usually would make the item shorter (and thus more likely to fit), but not always - say, an aspect-ratio image that fills the track. And even if it did fit, it would still be a second layout, potentially ~doubling the layout cost from turning on dense packing. This algo sounds reasonable to me? In the common case of equal-sized tracks, it'll work naturally to fill holes everywhere; in mixed tracks, it'll at least do some work, without increasing costs beyond that of tracking gaps (which is trivial). |
@ethanjv Your diagrams are amazing. |
The CSS Working Group just discussed
The full IRC log of that discussion |
For @ethanjv's (1): yes, your displayed position options are exactly right. For (2), we'd pick the higher area in the first picture. |
From @bfgeek in #9041 (comment)
The text was updated successfully, but these errors were encountered: