Apparence-io / CamerAwesome

📸 Embedding a camera experience within your own app shouldn't be that hard. A flutter plugin to integrate awesome Android / iOS camera experience.
https://ApparenceKit.dev
MIT License
952 stars 241 forks source link

[App Crash] com.apparence.camerawesome.CameraStateManager.stopCamera() on a null object reference #40

Closed shekohex closed 3 years ago

shekohex commented 3 years ago

that seems weird but if you added the package and didn't use it anywhere, it makes the app crash at exit.

Steps to Reproduce

Just add

camerawesome: ^0.1.1+1

to a new flutter project. and compile it and open it then exit the app by clicking the back button.

Expected results

Nothing, the app should exit without a crash.

Actual results

It seems that camerawesome hooks into app lifecycle and tries to clean up things .. even it is not used anywhere in the code.

About your device

D/AndroidRuntime(31610): Shutting down VM
E/AndroidRuntime(31610): FATAL EXCEPTION: main
E/AndroidRuntime(31610): Process: re.edgewa.wallet, PID: 31610
E/AndroidRuntime(31610): java.lang.RuntimeException: Unable to destroy activity {re.edgewa.wallet/re.edgewa.wallet.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.apparence.camerawesome.CameraStateManager.stopCamera()' on a null object reference
E/AndroidRuntime(31610):    at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4942)
E/AndroidRuntime(31610):    at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4971)
E/AndroidRuntime(31610):    at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:44)
E/AndroidRuntime(31610):    at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
E/AndroidRuntime(31610):    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
E/AndroidRuntime(31610):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2017)
E/AndroidRuntime(31610):    at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(31610):    at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime(31610):    at android.app.ActivityThread.main(ActivityThread.java:7397)
E/AndroidRuntime(31610):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(31610):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/AndroidRuntime(31610):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
E/AndroidRuntime(31610): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.apparence.camerawesome.CameraStateManager.stopCamera()' on a null object reference
E/AndroidRuntime(31610):    at com.apparence.camerawesome.CamerawesomePlugin.onDetachedFromActivity(CamerawesomePlugin.java:486)
E/AndroidRuntime(31610):    at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.detachFromActivity(FlutterEngineConnectionRegistry.java:389)
E/AndroidRuntime(31610):    at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onDetach(FlutterActivityAndFragmentDelegate.java:539)
E/AndroidRuntime(31610):    at io.flutter.embedding.android.FlutterActivity.release(FlutterActivity.java:589)
E/AndroidRuntime(31610):    at io.flutter.embedding.android.FlutterActivity.onDestroy(FlutterActivity.java:610)
E/AndroidRuntime(31610):    at android.app.Activity.performDestroy(Activity.java:8056)
E/AndroidRuntime(31610):    at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1342)
E/AndroidRuntime(31610):    at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4927)
E/AndroidRuntime(31610):    ... 11 more
Brand Model OS
--- --- 10

g-apparence commented 3 years ago

Oh effectivelly this is weird, had planned a day of work on the plugin. Will look into it today.

g-apparence commented 3 years ago

This fixes it. Reproduced and fixed, thank you for taking the time to report it.