p2 / OAuth2

OAuth2 framework for macOS and iOS, written in Swift.
Other
1.14k stars 275 forks source link

App crashes if a token refresh occurs while in the background #403

Open connorwagner opened 1 year ago

connorwagner commented 1 year ago

We have received several reports of crashes in our app while the app is in the background. I was able to get a crash log (attached to this issue), and found that there was activity on the OAuth2Authorizer.safariViewControllerDidCancel method. That lead me to believe that a token refresh was happening in the background and attempting to prompt the user to reauthenticate, even though the app was backgrounded/the phone was locked.

I found this related issue and tried making the oauth2 variable in question a strong reference (PR to my fork with that change), which mitigated the issue in my testing.

If you're open to that solution I'd be happy to open a PR here - but I haven't gotten into the project's design enough to fully understand the impact of that change. I just tried it as a quick-and-dirty way to validate the source of the issue.

Let me know if I can provide any further information/logs/etc!