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

ASCollectionLayout to return a zero content size if its state is unavailable #509

Merged
merged 3 commits into from
Aug 17, 2017

Conversation

nguyenhuy
Copy link
Member

Reported by @wsdwsd0829 here.

Reproducible in "examples/ASCollectionView" by enabling ASYNC_COLLECTION_LAYOUT and popping the view controller after just 2 seconds (this line
). The crash occurs when a containing view controller is popped out right after its collection view finished a batch update, but before an update animation settles. As soon as the view controller is deallocated, its collection view's layout is invalidated. Then when the update animation stops, it asks for the layout's content size and triggers the assertion. Fix by returning a zero size instead.

Copy link
Member

@Adlai-Holler Adlai-Holler left a comment

Choose a reason for hiding this comment

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

Down with this

@@ -140,8 +140,7 @@ - (void)invalidateLayout
- (CGSize)collectionViewContentSize
{
ASDisplayNodeAssertMainThread();
ASDisplayNodeAssertNotNil(_layout, @"Collection layout state should not be nil at this point");
return _layout.contentSize;
return _layout ? _layout.contentSize : CGSizeZero;
Copy link
Member

Choose a reason for hiding this comment

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

So that we don't regress on this in the future, could you add a link to this PR explaining the workaround?

@nguyenhuy
Copy link
Member Author

Thanks, @Adlai-Holler!

@nguyenhuy nguyenhuy merged commit 46e9494 into TextureGroup:master Aug 17, 2017
@nguyenhuy nguyenhuy deleted the HNHandleUnavaiLayoutState branch August 17, 2017 13:43
bernieperez pushed a commit to AtomTickets/Texture that referenced this pull request Apr 25, 2018
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.

2 participants