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

Crash on trying to collectPaymentMethod with low battery #124

Closed
robertsammons opened this issue Nov 24, 2021 · 6 comments · Fixed by #134
Closed

Crash on trying to collectPaymentMethod with low battery #124

robertsammons opened this issue Nov 24, 2021 · 6 comments · Fixed by #134

Comments

@robertsammons
Copy link

Summary

We are encountering a crash on several of our readers when trying to call the collectPaymentMethod with a low battery. We get a crash trace back that mentions "reportLowBatteryWarning"

Code to reproduce

Code is in production, can provide privately if need be

iOS version

iOS 15.1

Installation method

Stripe Package Manager

SDK version

Based on logs we believe this started with 2.3.0 but are on the latest 2.4.0

Other information

Attached crash trace from Xcode.

Screen Shot 2021-11-24 at 9 37 18 am

I'm not sure if this is a required method to support but it isn't mentioned as a required method?

@robertsammons
Copy link
Author

Screen Shot 2021-11-24 at 10 04 08 am

@bric-stripe
Copy link
Collaborator

@robertsammons sorry for the trouble here - we've identified the crash on the SDK side and will get a fix in the next release1. Until then, this should be able to be worked around on the application side by ensuring the SCPBluetoothReaderDelegate passed to the connectBluetoothReader is not released while connected to the reader. Terminal holds a weak reference to that delegate so if the application code loses all references to it it will be released.

Note the SDK side crash is not because the delegate doesn't have the optional readerDidReportLowBatteryWarning: implemented, but is instead from a missing nil check on that delegate. So if the application can ensure it retains that delegate2 that should work around the crash here until this is fixed on the SDK side.

Footnotes

  1. due to end of year code freeze the next release isn't planned until ~3rd week of Jan when we resume our monthly release schedule)

  2. which is also recommended to ensure the app is getting all the BluetoothReader events and all)

@robertsammons
Copy link
Author

@bric-stripe Thanks for the reply, unfortunately the work around is likely a lot of work from my side, just the way I've built it means I have a connect readers screen that has the delegate reference then obviously disappears as it closes. I'll definitely consider changing this in the future as the additional methods like low battery would be useful to know.

One question I have is we're not sure if this was introduced in V2.3.0 or if it has always been there, just thinking of reverting back to an older version if the bug was introduced with this version. It may have just matched up to their being more readers from our side in use around the same time frame but worth an ask.

@bric-stripe
Copy link
Collaborator

One question I have is we're not sure if this was introduced in V2.3.0 or if it has always been there

I checked our git blame and the problem has been there since the first 2.0.0 release 😞

unfortunately the work around is likely a lot of work from my side

There may be some not terribly elegant, but not overly complicated, options/band aids here for a short term solution. In our Example code we have a DelegateAnnouncer that we use that provides a long lived singleton that you may be able to make use of or something similar:

if you don't need the added multiple listener support that can probably be simplified a good bit.

@robertsammons
Copy link
Author

Perfect, thanks for that. You're right I think that'll do the job for now without too much work.

@robertsammons
Copy link
Author

Thanks for solving this one!

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 a pull request may close this issue.

2 participants