-
Notifications
You must be signed in to change notification settings - Fork 120
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
Bug 1819161 - Attempt to fix issue when leaving DispatchGroup #2392
Conversation
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## main #2392 +/- ##
=======================================
Coverage 32.50% 32.50%
=======================================
Files 1 1
Lines 40 40
=======================================
Hits 13 13
Misses 27 27 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Since @badboy is not around I redirected this to @rosahbruno for a first look. @travis79 I'd recommend seeking an additional review from an iOS expert outside of our team. |
I don’t think this is a timing issue as DispatchGroup will hang forever if you let it. The error we are seeing is There are potential issues with the upload function that is called. If for some reason the buildRequest function returns nil then the function will exit without triggering the callback. Similarly if the write to file in the upload function fails it will not call the completion. These aren’t causing the crash but would cause the process to hang forever as the dispatch group will never complete. To get around this issue you can instead call the same defer block you had previously but put it at the top of the function, at the same scope as the enter and then don’t call leave anywhere else, this will guarantee the number of enter calls matches the number of leave calls. Something like this:
|
The reason the upload functions completion fires twice is potentially related to the same iOS crash we had last year, the quick fix was to remove finishTasksAndInvalidate for the url session, but that crash had the same presentation as this issue where something funny was going on with the url session task on foregrounding the app. The fix I suggest above will likely still resolve this crash but I recommend creating a follow up task to investigate what the underlying issue is with how url session is managed because it's likely this will continue to cause random issues going forward. |
Thanks @OrlaM! I agree 100% that this seems very much like the previous crash related to the URL Session usage and I'd really like to resolve that for good. I'll adjust this to add the single |
Sorry, the advice I gave was bad on further consideration. Moving the defer to the top of the function will ensure there is a leave for every enter but it will not have the effect you want it to since the leave will fire before the completion of the upload. I assume this isn't what you are after and will potentially cause other knock on issues. I'm not sure there is a good fix for this 🤔
|
46535fc
to
e74e49b
Compare
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.
LGTM 🤞
8cfeacb
to
a521527
Compare
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.
Needs CHANGELOG and maybe we can drop testingMode
?
I'm no iOS wizard and I barely understand Swift, but I'm feeling some unearned confidence that the approach is sound from having a proper iOS dev already look over this.
And generally speaking, less code means fewer bugs, right?
635148f
to
916920a
Compare
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.
Seems good and changes make sense - just a few nit-picky things
My suspicion is that this is due to the recursive nature of `process` and `defer` being especially executed at the end of the scope and some interaction between the two.
My suspicion is that this is due to the recursive nature of
process
anddefer
being especially executed at the end of the scope and some interaction between the two.