android-gpuimage-plus icon indicating copy to clipboard operation
android-gpuimage-plus copied to clipboard

Fatal exception

Open Sp4Rx opened this issue 5 years ago • 4 comments

Unable to start preview and I have no clue why. This worked on most of the phones I have tested but on my crashlytics I'm getting this crash.

Fatal Exception: java.lang.RuntimeException: startPreview failed
   at android.hardware.Camera.startPreview(Camera.java)
   at org.wysaid.camera.CameraInstance.startPreview(CameraInstance.java:174)
   at org.wysaid.camera.CameraInstance.startPreview(CameraInstance.java:180)
   at com.leher.recorder.CameraGLSurfaceView.onSurfaceChanged(CameraGLSurfaceView.java:441)
   at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1532)
   at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1259)

Sp4Rx avatar Apr 10 '19 07:04 Sp4Rx

Maybe the user disabled the camera permission. Please paste more info about user device, android ver and so on if you have.

wysaid avatar Apr 10 '19 11:04 wysaid

You are right its due to the permission. Though its not a crash. I think the logs which I have mentioned before is due to this.

Actually I'm checking permission at my fragment's onResume and then calling mCameraView.resumePreview();(this is extended from your CameraGLSurfaceView). And in your CameraGLSurfaceView's onSurfaceCreated you are doing cameraInstance().tryOpenCamera(null, facing) . So for the first time it will give an error if there is no permission.

2019-04-11 18:19:23.366 31055-31216/com.leher I/libCGE_java: try open camera...
2019-04-11 18:19:23.369 31055-31216/com.leher W/CameraBase: An error occurred while connecting to camera 1: Service not available
2019-04-11 18:19:23.369 31055-31216/com.leher E/libCGE_java: Open Camera Failed!
2019-04-11 18:19:23.369 31055-31216/com.leher W/System.err: java.lang.RuntimeException: Fail to connect to camera service
2019-04-11 18:19:23.370 31055-31216/com.leher W/System.err:     at android.hardware.Camera.<init>(Camera.java:540)
2019-04-11 18:19:23.370 31055-31216/com.leher W/System.err:     at android.hardware.Camera.open(Camera.java:372)
2019-04-11 18:19:23.370 31055-31216/com.leher W/System.err:     at org.wysaid.camera.CameraInstance.tryOpenCamera(CameraInstance.java:107)
2019-04-11 18:19:23.370 31055-31216/com.leher W/System.err:     at com.leher.recorder.CameraGLSurfaceView.onSurfaceCreated(CameraGLSurfaceView.java:351)
2019-04-11 18:19:23.370 31055-31216/com.leher W/System.err:     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1521)
2019-04-11 18:19:23.370 31055-31216/com.leher W/System.err:     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1253)
2019-04-11 18:19:23.370 31055-31216/com.leher E/libCGE_java: 相机启动失败!!

Sp4Rx avatar Apr 11 '19 13:04 Sp4Rx

Get it. The app in the repo is just a demo. You can do more stable check before the camera is required~

wysaid avatar Apr 12 '19 11:04 wysaid

This issue can be closed. The problem was different. You have a singleton camera. So before closing my fragment I need to call your release method at onStop.

As I'm not calling it the next time I'm opening the camera it was already busy and cased the crash.

Sp4Rx avatar Apr 13 '19 07:04 Sp4Rx