-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
base: master
Are you sure you want to change the base?
Conversation
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ;-)
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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
.
Hey @businessengine could you elaborate on the deadlock you're seeing? The current code as-written breaks the semantics of the editing transaction queue. |
No description provided.