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

Resources$NotFoundException thrown when the application is killed by OS #158

Closed
rpanadero opened this issue Apr 8, 2019 · 6 comments
Closed
Labels
Milestone

Comments

@rpanadero
Copy link
Contributor

Bug report

Description

Hi, I'm facing an issue with this plugin that occurs when the OS kills the application because of memory, for example if the mobile user has many application opened on background at a time. If the Fingerprint authentication fragment is present when the OS kills your application, the application crashes when the user tries to resume it. The crash stacktrace is attached below.

As you will see in the logs, investigating the issue I added a log entry at line 84 of FingerprintAuthenticationDialogFragment class (inside 'onCreateView' method) which helped me to find out what it was really happening.

When everything works well, this log entry is shown with the right application package name:
04-08 11:19:55.140 12681 12681 D FingerprintAuthDialog: packageName: com.okode.demo

But, if the application crashes, this is the log:
04-08 12:11:02.362 29538 29538 D FingerprintAuthDialog: packageName: null

This made me realize that all plugin data, which was kept in memory, had been erased because OS had killed the application while this was on background and when the user tried to resume the application, then crashed trying to get a resource by using an invalid application package name.

These are the steps to reproduce the issue:

  1. Open your app
  2. Make your app show the fingerprint authentication dialog anyway
  3. Go to background KEEPING THE DIALOG VISIBLE (don't cancel it)
  4. Open several apps without resuming your app
  5. Resume your app from background to foreground
  6. Then your app will crash because all memory variables will be cleaned up

I'm gonna try to provide you with a pull request related to this issue and I will try to be as less intrusive as I can. So, feel free to share anything with me.

Environment

  • Plugin version: 1.6.0

Logs

04-08 12:11:02.351 29538 29538 D FingerprintAuthDialog: e: false
04-08 12:11:02.352  5050  6670 W StorageManager: getStorageLowBytes lowPercent : 5, lowBytes : 1273880780, maxLowBytes : 524288000
04-08 12:11:02.360 29582 29624 I cr_LibraryLoader: Time to load native libraries: 0 ms (timestamps 2512-2512)
04-08 12:11:02.362 29582 29624 I chromium: [INFO:library_loader_hooks.cc(50)] Chromium logging enabled: level = 0, default verbosity = 0
04-08 12:11:02.362 29538 29538 D FingerprintAuthDialog: packageName: null
04-08 12:11:02.362 29582 29624 I cr_LibraryLoader: Expected native library version number "73.0.3683.90", actual native library version number "73.0.3683.90"
04-08 12:11:02.363 29538 29538 W ResourceType: No package identifier when getting value for resource number 0x00000000
04-08 12:11:02.370 29538 29538 D AndroidRuntime: Shutting down VM
04-08 12:11:02.384  5050  6670 I chatty  : uid=1000(system) Binder:5050_F identical 4 lines
04-08 12:11:02.386  5050  6670 W StorageManager: getStorageLowBytes lowPercent : 5, lowBytes : 1273880780, maxLowBytes : 524288000
04-08 12:11:02.394 29538 29538 E AndroidRuntime: FATAL EXCEPTION: main
04-08 12:11:02.394 29538 29538 E AndroidRuntime: Process: com.okode.demo, PID: 29538
04-08 12:11:02.394 29538 29538 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.okode.demo/com.okode.demo.MainActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x0
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.app.ActivityThread.-wrap11(Unknown Source:0)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:105)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:164)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6944)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.content.res.Resources.getText(Resources.java:353)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.content.res.Resources.getString(Resources.java:447)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.app.Fragment.getString(Fragment.java:883)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at de.niklasmerz.cordova.fingerprint.FingerprintAuthenticationDialogFragment.onCreateView(FingerprintAuthenticationDialogFragment.java:89)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.app.Fragment.performCreateView(Fragment.java:2611)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1276)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1549)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1611)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3045)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2997)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.app.FragmentController.dispatchActivityCreated(FragmentController.java:179)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.app.Activity.performCreateCommon(Activity.java:7177)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.app.Activity.performCreate(Activity.java:7185)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)
04-08 12:11:02.394 29538 29538 E AndroidRuntime: 	... 9 more
  
@NiklasMerz
Copy link
Owner

Thanks for the detailed report and pull request. Every bug report should look like this. 🥇

I will have a look myself and comment on the PR.

@rpanadero
Copy link
Contributor Author

Thanks @NiklasMerz ! Have you been able to have a look ? I know that I could be a little bit confusing to understand, but it is quite easy to reproduce it especially on Samsung devices.

Thanks in advance !

@NiklasMerz
Copy link
Owner

I cannot reproduce this with my phone or the emulator. I probably need to get an older one. Let´s discuss this further in the PR. We need to be careful here.

@uifox
Copy link

uifox commented May 21, 2019

@rpanadero, @NiklasMerz
Using version 1.6 of this plugin we started to see crash events in FireBase that are most likely caused by the same issue.

The stack trace:

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.doxo.android/com.doxo.android.MainActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x0
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3086)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3229)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:6981)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)

Caused by android.content.res.Resources$NotFoundException: String resource ID #0x0
       at android.content.res.Resources.getText(Resources.java:363)
       at android.content.res.Resources.getString(Resources.java:456)
       at android.app.Fragment.getString(Fragment.java:790)
       at de.niklasmerz.cordova.fingerprint.FingerprintAuthenticationDialogFragment.onCreateView(FingerprintAuthenticationDialogFragment.java:88)
       at android.app.Fragment.performCreateView(Fragment.java:2522)
       at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1298)
       at android.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1576)
       at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1637)
       at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3050)
       at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3002)
       at android.app.FragmentController.dispatchActivityCreated(FragmentController.java:183)
       at android.app.Activity.performCreate(Activity.java:7333)
       at android.app.Activity.performCreate(Activity.java:7317)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3066)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3229)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:6981)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)

The crashing devices:

  • LG K20 Plus (Android 7), RAM free: 324.36 MB, Disk free: 8.66 GB
  • Galaxy S9 (Android 9), RAM free: 1.03 GB, Disk free: 29.35 GB

@NiklasMerz
Copy link
Owner

Please test #178 if it fixes this.

@NiklasMerz
Copy link
Owner

Closed since #179 fixed this issue. Thank you for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants