Skip to content

Fix #7347 - Catch errors loading tflite models in Identity SDK#9812

Merged
kentwilliams-stripe merged 14 commits intomasterfrom
catch-errors-loading-tflite-models
Dec 20, 2024
Merged

Fix #7347 - Catch errors loading tflite models in Identity SDK#9812
kentwilliams-stripe merged 14 commits intomasterfrom
catch-errors-loading-tflite-models

Conversation

@kentwilliams-stripe
Copy link
Contributor

@kentwilliams-stripe kentwilliams-stripe commented Dec 20, 2024

Summary

Identity SDK

  • Validates that cached models are valid, exits flow with IdentityVerificationSheet.VerificationFlowResult.Failed if not
  • Handle error If an invalid model is still somehow still loaded, preventing an app crash

Motivation

#7347

Testing

  • Added tests
  • Modified tests
  • Manually verified

Changelog

  • [Fixed] Fix app crash when TFLite model fails to load

@kentwilliams-stripe kentwilliams-stripe changed the title Fix #7347 - Catch errors loading tflite models Fix #7347 - Catch errors loading tflite models in Identity SDK Dec 20, 2024
@github-actions
Copy link
Contributor

github-actions bot commented Dec 20, 2024

Diffuse output:

OLD: identity-example-release-base.apk (signature: V1, V2)
NEW: identity-example-release-pr.apk (signature: V1, V2)

          │            compressed            │           uncompressed           
          ├───────────┬───────────┬──────────┼───────────┬───────────┬──────────
 APK      │ old       │ new       │ diff     │ old       │ new       │ diff     
──────────┼───────────┼───────────┼──────────┼───────────┼───────────┼──────────
      dex │     2 MiB │     2 MiB │ +1.5 KiB │   4.1 MiB │   4.1 MiB │ +1.5 KiB 
     arsc │     1 MiB │     1 MiB │      0 B │     1 MiB │     1 MiB │      0 B 
 manifest │   2.3 KiB │   2.3 KiB │      0 B │     8 KiB │     8 KiB │      0 B 
      res │ 301.8 KiB │ 301.8 KiB │      0 B │ 455.5 KiB │ 455.5 KiB │      0 B 
   native │   6.2 MiB │   6.2 MiB │      0 B │  15.8 MiB │  15.8 MiB │      0 B 
    asset │   7.1 KiB │   7.1 KiB │    -18 B │   6.9 KiB │   6.9 KiB │    -18 B 
    other │  90.2 KiB │  90.3 KiB │    +12 B │ 170.3 KiB │ 170.3 KiB │      0 B 
──────────┼───────────┼───────────┼──────────┼───────────┼───────────┼──────────
    total │   9.6 MiB │   9.6 MiB │ +1.5 KiB │  21.5 MiB │  21.5 MiB │ +1.5 KiB 

 DEX     │ old   │ new   │ diff            
─────────┼───────┼───────┼─────────────────
   files │     1 │     1 │   0             
 strings │ 19966 │ 19970 │  +4 (+9 -5)     
   types │  6188 │  6191 │  +3 (+6 -3)     
 classes │  4979 │  4982 │  +3 (+3 -0)     
 methods │ 29759 │ 29769 │ +10 (+194 -184) 
  fields │ 17526 │ 17540 │ +14 (+284 -270) 

 ARSC    │ old  │ new  │ diff 
─────────┼──────┼──────┼──────
 configs │  164 │  164 │  0   
 entries │ 3622 │ 3622 │  0
APK
     compressed      │    uncompressed     │                                           
──────────┬──────────┼──────────┬──────────┤                                           
 size     │ diff     │ size     │ diff     │ path                                      
──────────┼──────────┼──────────┼──────────┼───────────────────────────────────────────
    2 MiB │ +1.5 KiB │  4.1 MiB │ +1.5 KiB │ ∆ classes.dex                             
  6.3 KiB │    -20 B │  6.1 KiB │    -20 B │ ∆ assets/dexopt/baseline.prof             
 28.5 KiB │     +7 B │ 62.9 KiB │      0 B │ ∆ META-INF/CERT.SF                        
 25.3 KiB │     +6 B │ 62.8 KiB │      0 B │ ∆ META-INF/MANIFEST.MF                    
    859 B │     +2 B │    727 B │     +2 B │ ∆ assets/dexopt/baseline.profm            
  1.2 KiB │     -2 B │  1.2 KiB │      0 B │ ∆ META-INF/CERT.RSA                       
    272 B │     +1 B │    120 B │      0 B │ ∆ META-INF/version-control-info.textproto 
──────────┼──────────┼──────────┼──────────┼───────────────────────────────────────────
    2 MiB │ +1.5 KiB │  4.2 MiB │ +1.5 KiB │ (total)
DEX
STRINGS:

   old   │ new   │ diff       
  ───────┼───────┼────────────
   19966 │ 19970 │ +4 (+9 -5) 
  
  + Invalid TFLite model, likely a corrupted download
  + LB3/m;
  + LH3/n;
  + LK3/g1;
  + VLLLB
  + [LH3/n;
  + [LK3/Y0;
  + [LK3/y0;
  + ~~R8{"backend":"dex","compilation-mode":"release","has-checksums":false,"min-api":21,"pg-map-id":"fe84a2d","r8-mode":"full","version":"8.7.14"}
  
  - VLLB
  - [LH3/i;
  - [LK3/X0;
  - [LK3/x0;
  - ~~R8{"backend":"dex","compilation-mode":"release","has-checksums":false,"min-api":21,"pg-map-id":"cb0eba6","r8-mode":"full","version":"8.7.14"}
  

TYPES:

   old  │ new  │ diff       
  ──────┼──────┼────────────
   6188 │ 6191 │ +3 (+6 -3) 
  
  + LB3/m;
  + LH3/n;
  + LK3/g1;
  + [LH3/n;
  + [LK3/Y0;
  + [LK3/y0;
  
  - [LH3/i;
  - [LK3/X0;
  - [LK3/x0;
  

METHODS:

   old   │ new   │ diff            
  ───────┼───────┼─────────────────
   29759 │ 29769 │ +10 (+194 -184) 
  
  + A3.g <init>(Context, l, g, x)
  + B3.g <init>(t0, IllegalStateException, d)
  + B3.g h(Object, Object) → Object
  + B3.g l(d, Object) → d
  + B3.h <init>(i, d)
  + B3.h o(Object) → Object
  + B3.i <init>(e, s)
  + B3.i <init>(o, g)
  + B3.i a(int, d) → Object
  + B3.i j(Object, d) → Object
  + B3.j <init>(Object, int, Object)
  + B3.j b(g, d) → Object
  + B3.k <init>(l, j, y, b, a, t0, Rect, d)
  + B3.k h(Object, Object) → Object
  + B3.k l(d, Object) → d
  + B3.k o(Object) → Object
  + B3.l <init>()
  + B3.l <init>(O, Context, int)
  + B3.l a() → j
  + B3.l b(a)
  + B3.l c()
  + B3.m <init>(Context, V)
  + B3.m a(d) → l
  + B4.M <init>(i, d)
  + B4.s <init>(i, d)
  + C4.a <init>(i)
  + D.e C0(l0) → y0
  + D.e O(Set, E) → j
  + E3.b <init>(l, l, IdentityActivity)
  + E3.b <init>(l, l, IdentityActivity, byte)
  + H3.a <init>(b, c)
  + H3.a o(Object) → Object
  + H3.b <init>(g, a)
  + H3.b a(String, c) → Object
  + H3.b b(File) → boolean
  + H3.c <init>(g, c)
  + H3.d <init>(g, c)
  + H3.e <init>(g, c)
  + H3.f <init>(g, c)
  + H3.f o(Object) → Object
  + H3.g <init>(k, a, Context)
  + H3.g a(String, c) → Object
  + H3.g b(g, a, c) → Object
  + H3.g c(i, O, c, c) → Object
  + H3.g d(String, String, f, c, E) → Object
  + H3.g e(String, String, J) → Object
  + H3.g f(d, c) → Object
  + H3.g g(String, String, boolean, O) → Object
  + H3.g h(String, String, File, j, c, i) → Object
  + H3.g i(String, String, boolean, W) → Object
  + H3.h <init>(String)
  + H3.i <init>(i, f, String)
  + H3.i a() → Map
  + H3.i b() → x
  + H3.i c() → Map
  + H3.i e() → String
  + H3.i f(OutputStream)
  + H3.i g() → String
  + H3.i h() → String
  + H3.i i(PrintWriter, String)
  + H3.j <init>(m, Object, String, Throwable)
  + H3.k <init>(j, j, j, j, j, j)
  + H3.k a(k, j, j, j, j, j, j, int) → k
  + H3.l <init>()
  + H3.l <init>(j, j)
  + H3.l a(l, j, j, int) → l
  + H3.l b() → IllegalStateException
  + H3.l c() → boolean
  + H3.l d() → boolean
  + H3.l describeContents() → int
  + H3.l equals(Object) → boolean
  + H3.l hashCode() → int
  + H3.l toString() → String
  + H3.l writeToParcel(Parcel, int)
  + H3.m valueOf(String) → m
  + H3.m values() → m[]
  + H3.n <clinit>()
  + H3.n <init>(h, List, m)
  + H3.n describeContents() → int
  + H3.n equals(Object) → boolean
  + H3.n hashCode() → int
  + H3.n toString() → String
  + H3.n writeToParcel(Parcel, int)
  + I3.e b(n, n, n, n, n, n, boolean, float, float, int) → f
  + K3.A0 <init>(c, j, d)
  + K3.A0 h(Object, Object) → Object
  + K3.A0 l(d, Object) → d
  + K3.A0 o(Object) → Object
  + K3.B0 <init>()
  + K3.B0 a(e) → C
  + K3.C0 <init>(c, V, V, d)
  + K3.C0 h(Object, Object) → Object
  + K3.C0 l(d, Object) → d
  + K3.C0 o(Object) → Object
  + K3.D0 <init>(d0, int)
  + K3.E0 <init>(X, C, Context, int)
  + K3.E0 a() → Object
  + K3.F0 <init>(X, C, d)
  + K3.F0 h(Object, Object) → Object
  + K3.F0 l(d, Object) → d
  + K3.G0 <init>(c, X, C, d)
  + K3.G0 i(Object) → Object
  + K3.H0 <init>(C, O, X, Context, c, d)
  + K3.I0 <init>(k0, n, X, C, Context, d0, c, d)
  + K3.J0 <init>(c, L0, d)
  + K3.J0 h(Object, Object) → Object
  + K3.J0 l(d, Object) → d
  + K3.J0 o(Object) → Object
  + K3.K0 <clinit>()
  + K3.K0 g() → String
  + K3.K0 h(String) → J0
  + K3.L0 <init>(X, String, j, int, int)
  + K3.M0 <init>(X, j, String, d)
  + K3.M0 l(d, Object) → d
  + K3.M0 o(Object) → Object
  + K3.N0 <init>(float, m, int)
  + K3.N0 h(Object, Object) → Object
  + K3.O0 <init>(c, boolean)
  + K3.O0 <init>(boolean, Enum, int)
  + K3.O0 i(Object) → Object
  + K3.P0 <init>(m, String, boolean, boolean, C, c
...✂

@kentwilliams-stripe kentwilliams-stripe marked this pull request as ready for review December 20, 2024 21:23
@kentwilliams-stripe kentwilliams-stripe requested review from a team as code owners December 20, 2024 21:23
mockFpsTracker,
mockIdentityAnalyticsRequestFactory,
mock(),
mock(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to see tests for this, rather than just mocks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to chat about this if you think it's worthwhile! The line you commented on is a finishWithResult function, were you suggesting that I write tests for errorHandler?

@kentwilliams-stripe kentwilliams-stripe merged commit dd48576 into master Dec 20, 2024
@kentwilliams-stripe kentwilliams-stripe deleted the catch-errors-loading-tflite-models branch December 20, 2024 22:36
kentwilliams-stripe added a commit that referenced this pull request Dec 21, 2024
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.

2 participants