Identity TFLite Model Creation Crash Fix#12083
Conversation
|
Diffuse output: APKDEX |
| ) | ||
| } catch (e: IllegalStateException) { | ||
| } catch (e: Exception) { | ||
| Log.e(TAG, "Analyzer creation failed", e) |
There was a problem hiding this comment.
What happens after the crash now? Do we show an error message?
There was a problem hiding this comment.
Currently the behavior is the same was it was previously – if it fails at the validation level, it simply tries to redownload the model, but if it succeeds there and fails at the creation stage (the rare case like we have for this crash) then identity verification fails and dismisses the sheet, and the exception is passed to the client app in the failure status. The client app can then choose to show the error to the user if they want, or give them another opportunity to retry.
The only difference from before is that we catch more types of exceptions now so that they no longer crash.
There was a problem hiding this comment.
Can we use genericError instead to make sure we can see the error in our logs?
There was a problem hiding this comment.
sure thing, done – I also included the exception message in the genericError message, but let me know if that message should remain static / if I should remove that as part of the message
cjmisenas-stripe
left a comment
There was a problem hiding this comment.
Do we also need to handle this for document capture?
The existing try-catches in validation and analyzer creation handle both selfie and document scan cases, so we should be covered! |
Summary
This fixes a crash that could happen when attempting to open a tflite model file that doesn't exist or has been removed during Identity verification. This was seen in production on a large client app. We're not quite sure how it happens, but it is theoretically possible that a model could be cleared from the cache in between validation and loading. Builds on #9812
Motivation
Here's a backtrace:
The crashing TFLite
Interpreteris created uponFaceDetectorAnalyzercreation, which is made fromIdentityScanFlow.startFlowwhenScanTypeisSELFIE. Since we don't own or control what exceptions TensorFlow Lite (now LiteRT) throws, I changed the existing try-catch statements surrounding theInterpreterandFaceDetectorAnalyzerinitialization to catch all exceptions and call the appropriate error handler. I considered catchingIllegalArgumentExceptionin addition to the existingIllegalStateException, but thought the catch-all made sense here given that the exceptions are coming from an outside dependency, so that we fail gracefully for library users instead of crashing, even for issues we can't anticipate. We now log those exceptions as well.Testing
Manually completed verification via the identity example app, selecting selfie to make sure I went through that flow and received a success, verifying everything still worked as expected.