cordova-plugin-camera: App crashes randomly after taking a picture with the camera
Bug Report
Problem
After taking a picture, pushing the OK Button (marked below) of camera-plugin crashes the app randomly.
What is expected to happen?
The picture should be available in the app for further action.
What does actually happen?
The app crashes.
Information
2020-09-25 16:42:08.277 19807-19807/com.domain.app D/AndroidRuntime: Shutting down VM
2020-09-25 16:42:08.281 19807-19807/com.domain.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.domain.app, PID: 19807
java.lang.RuntimeException: Unable to resume activity {com.domain.app/com.domain.app.MainActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=34, result=-1, data=null} to activity {com.domain.app/com.domain.app.MainActivity}: java.lang.NullPointerException: filename cannot be null
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4626)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4659)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2261)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8107)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=34, result=-1, data=null} to activity {com.domain.app/com.domain.app.MainActivity}: java.lang.NullPointerException: filename cannot be null
at android.app.ActivityThread.deliverResults(ActivityThread.java:5324)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4613)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4659)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2261)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8107)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
Caused by: java.lang.NullPointerException: filename cannot be null
at android.media.ExifInterface.<init>(ExifInterface.java:1390)
at org.apache.cordova.camera.ExifHelper.createInFile(ExifHelper.java:56)
at org.apache.cordova.camera.CameraLauncher.processResultFromCamera(CameraLauncher.java:481)
at org.apache.cordova.camera.CameraLauncher.onActivityResult(CameraLauncher.java:808)
at org.apache.cordova.CordovaInterfaceImpl.onActivityResult(CordovaInterfaceImpl.java:159)
at org.apache.cordova.CordovaActivity.onActivityResult(CordovaActivity.java:361)
at android.app.Activity.dispatchActivityResult(Activity.java:8294)
at android.app.ActivityThread.deliverResults(ActivityThread.java:5317)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4613)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4659)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2261)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8107)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Runti
Command or Code
Environment, Platform, Device
Chrashes have first appeared on Samsung Galaxy Tab A (SM-T515) after Android 10 update. Same device running android 9 seams to work fine.
Version information
Cordova Packages:
cli: 10.0.0
common: 4.0.2
create: 3.0.0
lib: 10.0.0
common: 4.0.2
fetch: 3.0.0
serve: 4.0.0
Project Installed Platforms:
android: 9.0.0
Project Installed Plugins:
com-darryncampbell-cordova-plugin-intent: 1.3.0
com.mirasense.scanditsdk.plugin: 5.14.4
cordova-plugin-app-version: 0.1.9
cordova-plugin-camera: 5.0.0 (bug appears on older versions too)
cordova-plugin-device: 2.0.3
cordova-plugin-file: 6.0.2
cordova-plugin-network-information: 2.0.2
cordova-plugin-whitelist: 1.3.4
cordova-plugin-x-toast: 2.7.2
phonegap-plugin-barcodescanner: 8.1.0
Environment:
OS: Microsoft Windows 10 Pro 10.0.18362 (18362) (win32 10.0.18362) x64
Node: v13.12.0
npm: 6.14.4
Checklist
- I searched for existing GitHub issues
- I updated all Cordova tooling to most recent version
- I included all the necessary information above
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 44 (14 by maintainers)
Links to this issue
Commits related to this issue
- GH-665 - store the imageFilePath when the app is paused (onSaveInstance) and restore it back. — committed to PieterVanPoyer/cordova-plugin-camera by PieterVanPoyer 4 years ago
- GH-665 - store the imageFilePath when the app is paused (onSaveInstance) and restore it back. — committed to PieterVanPoyer/cordova-plugin-camera by PieterVanPoyer 4 years ago
- Bugfix issue 665 (#700) * GH-665 - store the imageFilePath when the app is paused (onSaveInstance) and restore it back. * Update src/android/CameraLauncher.java whitespace layout Co-authored-by... — committed to apache/cordova-plugin-camera by PieterVanPoyer 3 years ago
Hi @keo9ren @tenglandct
There is indeed a scenario that results in a NullPointerException and crashes the Android plugin. I did make a change to plugin code, you can test it with next commands. I did only corrected the Android failure.
You can install and test the plugin (on Android) with next command.
You could test it with next reproduction repo: https://github.com/PieterVanPoyer/cordova-camera-plugin-testing-app
Kind regards Pieter