getbouncer / cardscan-ios

A library for scanning credit and debit cards
MIT License
203 stars 67 forks source link

ActiveStateComputation: make it easy to run ML in active state #199

Closed kingst closed 4 years ago

kingst commented 4 years ago

Our only crashing bug on iOS was due to backgrounding logic and ML. This logic has continued to haunt us and has been the subject of a number of related bugs that we caught before production.

This PR introduces a new class ActiveStateComputation that behaves similarly to a serial DispatchQueue but runs the computation iff the app is in the active state.

We can use this to protect our main loop ML, warmUp routines, and to enable running completion loop ML with hardware acceleration safely (currently we run completion loop ML on the CPU for safety).

jaimejiyepark commented 4 years ago

makes sense to me. has all those triggers that we thought of not work against this? #lgtm