CainKernel / CainCamera

CainCamera is an Android Project to learn about development of beauty camera, image and short video
2.84k stars 777 forks source link

Issue while switching camera from rear camera to front camera in Android 8 only #145

Open ParthP-7 opened 3 years ago

ParthP-7 commented 3 years ago

2021-03-01 17:53:37.902 13154-13678/com.digiflixtv.app E/AndroidRuntime: FATAL EXCEPTION: CameraRenderer Process: com.digiflixtv.app, PID: 13154 java.lang.RuntimeException: Error during updateTexImage (see logcat for details) at android.graphics.SurfaceTexture.nativeUpdateTexImage(Native Method) at android.graphics.SurfaceTexture.updateTexImage(SurfaceTexture.java:243) at com.cgfay.camera.render.CameraRenderer.updateSurfaceTexture(CameraRenderer.java:409) at com.cgfay.camera.render.CameraRenderer.onDrawFrame(CameraRenderer.java:351) at com.cgfay.camera.render.CameraRenderHandler.handleMessage(CameraRenderHandler.java:73) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:192) at com.cgfay.camera.render.CameraRenderer.run(CameraRenderer.java:498)

CainKernel commented 3 years ago

Ididn‘t encounter this problem. maybe a compatibility exception. while switching camera, EGLContext may have been changed to another one by System. to fix it, you can try-catch this exception and don't draw this image texture when it occurs. if EGLContext is valid, then need to reinit and rebind surfaceTexture. if it still occurs, considering if memory leaks in OpenGL?