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
Thread Safety, closure captures, debug-only FatalErrors, self-self aliasing, misc tweaks #192
Conversation
Hmmm, looks like I introduced a scrolling direction bug. One sec |
Got it! I used auto-complete which didn't include parameters with default arguments in the main thread cast so direction was defaulting to .forward. |
@RamblinWreck77 oh nice! Have you found it's managed to mitigate the internal |
SwiftLint found issuesWarnings
Generated by 🚫 Danger |
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.
Looks good to me 👍 I'll sort the linter errors 😄
@msaps That bug was/is particularly rare in our project, but so far it hasn't happened again in prod with these changes so knock on wood! |
Decided to take a crack at fixing #153 and ended up poking around a bit more than I planned. Key points for this PR:
Move all FatalErrors to #DEBUG only, as it should not be done in release/prod code. Hard crashing like this will, AFAIK, break people's crash reporting/make crashes seem random.
let self=self aliasing is a compiler bug and will be removed in future swift versions, might as well fix now and use a guard inside weak self closures for cleaning up optional chaining.
Main thread safety: More enforcement of main thread usage for functions that manipulate UIKit classes. Conversion involved adding asserts, making current functions private and adding a public function that thread casts the private function to main.
Closure Captures: Generally closures should capture their inputs (especially if they're classes/reference types) to prevent memory/BAD_ACCESS errors when/if things get changed out from under you. ViewControllers are, in my experience, particularly nasty about this so closure captures help a ton.
Thanks again for an awesome library! It looks like all tests are passing and I'll run this fork in through our QA/production and report back over the next week if any unexpected issues occur