Skip to content

Add ASExperimentalSkipClearData #trivial#1136

Merged
maicki merged 2 commits into
masterfrom
MSAddASCollectionViewSkipClearDataExperiment
Sep 20, 2018
Merged

Add ASExperimentalSkipClearData #trivial#1136
maicki merged 2 commits into
masterfrom
MSAddASCollectionViewSkipClearDataExperiment

Conversation

@maicki

@maicki maicki commented Sep 19, 2018

Copy link
Copy Markdown
Contributor

We are seeing crashes to an internal inconsistency deep within UICollectionView. We were able to track down the range of commits where we start seeing this crash. To verify the hunch of the root cause of this crash we will introduce a new experiment that will skip calling clear data if dataSource / delegate is cleared within ASCollectionView.

@maicki maicki requested a review from nguyenhuy September 19, 2018 22:09
Comment thread Source/ASCollectionView.mm Outdated
{
ASDisplayNodeAssertMainThread();

if (ASActivateExperimentalFeature(ASExperimentalSkipClearData)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Checking for nils is less expensive than checking for experiment, so let's do it first, e.g:

  if (_asyncDataSource == nil && _asyncDelegate == nil && ASActivateExperimentalFeature(ASExperimentalSkipClearData)) {
    [_dataController clearData];
  }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point

@maicki maicki force-pushed the MSAddASCollectionViewSkipClearDataExperiment branch from 5edc05b to 38449ec Compare September 19, 2018 22:34
@ghost

ghost commented Sep 19, 2018

Copy link
Copy Markdown

🚫 CI failed with log

@ghost

ghost commented Sep 19, 2018

Copy link
Copy Markdown
1 Warning
⚠️ Any source code changes should have an entry in CHANGELOG.md or have #trivial in their title.

Generated by 🚫 Danger

@nguyenhuy

nguyenhuy commented Sep 19, 2018

Copy link
Copy Markdown
Member

screen shot 2018-09-19 at 4 11 15 pm

For the record, we believe the cause of this crash is a race condition in which the clear data operation is run immediately on main thread, after blocking main on ASDataController's editing queue, but without waiting for any pending batch updates that was scheduled from the editing queue to the main queue. Actually, that shouldn't be the case because waitUntilAllUpdatesAreProcessed blocks main on the editing queue and then run all scheduled blocks of the main queue.

@nguyenhuy nguyenhuy changed the title Add ASExperimentalSkipClearData Add ASExperimentalSkipClearData #trivial Sep 19, 2018
@maicki maicki merged commit 4708522 into master Sep 20, 2018
nguyenhuy pushed a commit to nguyenhuy/Texture that referenced this pull request Sep 20, 2018
* Add ASExperimentalSkipClearData

* Move the experiment check within the if clause
nguyenhuy added a commit to nguyenhuy/Texture that referenced this pull request Oct 2, 2018
This is a follow up on TextureGroup#1136. Our experiment results show that clearing data frequently is the cause of our TextureGroup#1 crash. @maicki and I believe that this is because if the collection view is being used, silently clearing its data without notifying the backing UICollectionView can put it out-of-sync and causes mayhem next time the collection view processes a batch update. If you look at the stack trace closely, you'll notice that the crash doesn't occur on the same run loop that clearData is called. This made it extremely tricky to investigate and identify the root cause.

Another interesting question would be whether or not we want to clear the data during deallocation at all, since the data will be cleared out soon anyway.
mikezucc pushed a commit to mikezucc/Texture that referenced this pull request Oct 2, 2018
* Add ASExperimentalSkipClearData

* Move the experiment check within the if clause
nguyenhuy added a commit that referenced this pull request Oct 3, 2018
This is a follow up on #1136. Our experiment results show that clearing data frequently is the cause of our #1 crash. @maicki and I believe that this is because if the collection view is being used, silently clearing its data without notifying the backing UICollectionView can put it out-of-sync and causes mayhem next time the collection view processes a batch update. If you look at the stack trace closely, you'll notice that the crash doesn't occur on the same run loop that clearData is called. This made it extremely tricky to investigate and identify the root cause.

Another interesting question would be whether or not we want to clear the data during deallocation at all, since the data will be cleared out soon anyway.
@maicki maicki deleted the MSAddASCollectionViewSkipClearDataExperiment branch October 17, 2018 16:45
mikezucc pushed a commit to mikezucc/Texture that referenced this pull request Nov 7, 2018
…1154)

This is a follow up on TextureGroup#1136. Our experiment results show that clearing data frequently is the cause of our #1 crash. @maicki and I believe that this is because if the collection view is being used, silently clearing its data without notifying the backing UICollectionView can put it out-of-sync and causes mayhem next time the collection view processes a batch update. If you look at the stack trace closely, you'll notice that the crash doesn't occur on the same run loop that clearData is called. This made it extremely tricky to investigate and identify the root cause.

Another interesting question would be whether or not we want to clear the data during deallocation at all, since the data will be cleared out soon anyway.
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