Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Horizontal Layout - layout attributes for supplementary items changed without invalidating the layout. #49

Closed
christoff-1992 opened this issue Dec 14, 2018 · 6 comments
Labels
bug Something isn't working

Comments

@christoff-1992
Copy link
Collaborator

If headers and footers are been used the horizontal layout will crash when been set.

2018-12-14 11:33:41.254874+0000 Example-iOS[2682:570726] *** Assertion failure in -[UICollectionViewData validateLayoutInRect:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3698.93.8/UICollectionViewData.m:459
2018-12-14 11:33:41.256220+0000 Example-iOS[2682:570726] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'layout attributes for supplementary item at index path (<NSIndexPath: 0x281b59b00> {length = 2, path = 0 - 0}) changed from <UICollectionViewLayoutAttributes: 0x104700dd0> index path: (<NSIndexPath: 0x281b582e0> {length = 2, path = 0 - 0}); element kind: (UICollectionElementKindSectionHeader); frame = (0 0; 375 61);  to <UICollectionViewLayoutAttributes: 0x104704650> index path: (<NSIndexPath: 0x281b59b00> {length = 2, path = 0 - 0}); element kind: (UICollectionElementKindSectionHeader); frame = (0 0; 1835 61);  without invalidating the layout'
*** First throw call stack:
(0x1c05fbea0 0x1bf7cda40 0x1c0511c1c 0x1c0fff140 0x1ecfbb2ac 0x1ecfba814 0x1ecfbce30 0x1ecf8f594 0x1ecf8eaa8 0x1ecf8e668 0x102f03db0 0x102ee9c80 0x1edb528b4 0x1edb52ed0 0x102f03b68 0x102f0d0f4 0x102f0d044 0x102f0d154 0x1ed6ba768 0x1ece8a6ec 0x1ece8a61c 0x1ed6ba768 0x1ed1486d0 0x1ed1489f0 0x1ed1479f0 0x1ed6f418c 0x1ed6f53f0 0x1ed6d46ec 0x1ed7a057c 0x1ed7a2f74 0x1ed79ba64 0x1c058c1cc 0x1c058c14c 0x1c058ba30 0x1c05868fc 0x1c05861cc 0x1c27fd584 0x1ed6b9054 0x102ed8288 0x1c0046bb4)
libc++abi.dylib: terminating with uncaught exception of type NSException
@zenangst zenangst added the bug Something isn't working label Dec 14, 2018
@zenangst
Copy link
Owner

I got this crash today. I'm gonna take a stab at solving it :)

@zenangst
Copy link
Owner

I think I might be one to something now, will make a PR if I land on something!

@zenangst zenangst assigned zenangst and unassigned zenangst Dec 18, 2018
@zenangst
Copy link
Owner

It seems like prepare can be invoked multiple times which makes this kind of thing invalid:

https://github.com/zenangst/Blueprints/blob/master/Sources/Shared/Core/HorizontalBlueprintLayout.swift#L128

From Googling the issue, it looks like a common issue with using headers in collection views since Apple introduced features like prefetching.

I didn't manage to solve it properly so I'll un-assign this issue from me for the time being.

@zenangst zenangst pinned this issue Dec 26, 2018
@zenangst
Copy link
Owner

Bah, this needs fixing but haven't had any time to fix this properly yet... Life keeps getting in the way.

@zenangst
Copy link
Owner

Fixing this might as well go hand in hand with #35, at least I think so... they are kinda related in a way.

@christoff-1992
Copy link
Collaborator Author

@zenangst - I should have time this week to take a look at this and #35 :)

zenangst pushed a commit that referenced this issue Jan 2, 2019
* Ensure that the header attributes are only added per section

Currently adds per items per section which causes conflicting values

* Updating tests to take into account the header and footer size and position

* Fix tests on macOS

* Revert "Fix tests on macOS"

This reverts commit d3e79ed.

* Improve setting the width of headeras and footers

* Fix warning to trigger travis-ci.com build
@zenangst zenangst unpinned this issue Jan 10, 2019
zenangst added a commit that referenced this issue Jan 14, 2019
* Inital layout changes to support stickyHeaders in the vertical layout.

TODO:

1. Investigate and resolve any performance hits
2. Move common code for reuseability
3. Update example header and footer views
4. Update / add tests
5. Implement logic for footers

* Remove commented out code now that #49 has been fixed and closed.

* [WIP] - Calculate the footer logic in prepare

* [WIP] - Testing different approaches

* Fixed calculations for the postion of the footer when sticky footers are been used

* fix calculations for footer attributes

* Update cell background colour for when sticky headers/footers are been used

* Remove comments

* Storyboard update

Automatic customModule update

* Patch sticky headers branch (#59)

* Fix crash by not calling layoutIfNeeded

Avoids crash:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'

* Load injection bundle for faster debugging

* Improve shouldInvalidateLayout function in vertical layout

* Add shouldInvalidateLayout to HorizontalBlueprintLayout

* Add link to InjectionIII
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants