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

Make swizzled URLSession init method signature match the origin init method to avoid unexpected crash #31

Merged
merged 1 commit into from
Aug 20, 2021

Conversation

ivanlisovyi
Copy link

@ivanlisovyi ivanlisovyi commented Aug 20, 2021

Hi @kean, first of all, thank you for creating such a cool library!

After the integration using the swizzling approach, we've noticed that our app started to crash occasionally. Apparently, the crash reason was related to the fact that pust_init URLSession method signature didn't really match the original init method. The swizzled method had delegate defined as non-optional whereas the original method has it defined as optional. Since we're swizzling the init method for every instance of URLSession created after a call of URLSession.enableAutomaticRegistration() it may lead to a crash when nil passed as a delegate value.

This PR shall also fix #29

@kean
Copy link
Owner

kean commented Aug 20, 2021

Thanks, @ivanlisovyi! I appreciate you taking your taking and fixing it.

@kean kean merged commit 7b5f48e into kean:master Aug 20, 2021
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.

Crash during NSURLSession.init
2 participants