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

Attempt to fix deadlock issues on iOS 13 #1710

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

willtr101
Copy link

No description provided.

@CLAassistant
Copy link

CLAassistant commented Oct 22, 2019

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ BusinessEngine
❌ businessengine


BusinessEngine seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@@ -660,6 +661,8 @@ - (void)updateWithChangeSet:(_ASHierarchyChangeSet *)changeSet
}];
}];
--_editingTransactionGroupCount;
// Leave the group
dispatch_group_leave(_editingTransactionGroup);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this works – leaving the group after dispatching_async defeats the purpose of the group.

Copy link
Author

@willtr101 willtr101 Oct 23, 2019

Choose a reason for hiding this comment

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

@Adlai-Holler Just double-checked, dispatch_group_async is just a convenient function, and it works the same way as dispatch_group_enter + dispatch_async + dispatch_group_leave ref: https://apple.github.io/swift-corelibs-libdispatch/tutorial/. So this change won't make any different comparing to the original. However, the change from dispatch_group_wait to dispatch_group_notify helped us solving the deadlock issues. Our QA is still in testing and we will investigate more to see why this only does happen on iOS 13, not on the previous iOS versions.

Copy link
Member

Choose a reason for hiding this comment

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

It's not the same – dispatch_group_async is equivalent to:

group_enter()
dispatch_async(^{
  // work
  group_leave();
});

Whereas the code in this PR is different:

group_enter()
dispatch_async(^{
  // work
});
group_leave();

The group is exited before the work is finished.

Copy link
Author

Choose a reason for hiding this comment

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

@Adlai-Holler can you please double-check? the group_leave is inside the dispatch_async, not outside ;-)

Copy link
Member

Choose a reason for hiding this comment

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

Oh you're right. So the following two things can't both be true:

  • dispatch_group_async is a shorthand for this exact code.
  • Removing dispatch_group_async is necessary to fix deadlocks.

I think the first one is true. So perhaps it's switching from wait to notify that is fixing your deadlocks (seems likely.)

Copy link
Author

@willtr101 willtr101 Oct 26, 2019

Choose a reason for hiding this comment

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

Yes first one is true and switching from wait to notify fixed our deadlocks. We are confident to release our app with that change as we noticed no crashes/app being frozen issues since that fix. We have to comment an assert due to the notify seems working differently with the wait.

@Adlai-Holler
Copy link
Member

Hey @businessengine could you elaborate on the deadlock you're seeing? The current code as-written breaks the semantics of the editing transaction queue.

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.

3 participants