Skip to content

Commit

Permalink
JITSI: catch all exceptions that occur on CaptureSession creation
Browse files Browse the repository at this point in the history
For some devices the captureFormat is never initialized,so captureFormat.width throws NPE.
Fatal Exception: java.lang.NullPointerException
Attempt to read from field 'int org.webrtc.CameraEnumerationAndroid$CaptureFormat.width' on a null object reference
org.webrtc.Camera2Session$CameraStateCallback.onOpened (Camera2Session.java:122)
android.hardware.camera2.impl.CameraDeviceImpl$1.run (CameraDeviceImpl.java:151)
android.os.Handler.handleCallback (Handler.java:938)
android.os.Handler.dispatchMessage (Handler.java:99)
android.os.Looper.loop (Looper.java:246)
android.os.HandlerThread.run (HandlerThread.java:67)
  • Loading branch information
tmoldovan8x8 authored and saghul committed Apr 9, 2021
1 parent 4d75330 commit 7ba1fdf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sdk/android/src/java/org/webrtc/Camera2Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ public void onOpened(CameraDevice camera) {
Logging.d(TAG, "Camera opened.");
cameraDevice = camera;

surfaceTextureHelper.setTextureSize(captureFormat.width, captureFormat.height);
surface = new Surface(surfaceTextureHelper.getSurfaceTexture());
try {
surfaceTextureHelper.setTextureSize(captureFormat.width, captureFormat.height);
surface = new Surface(surfaceTextureHelper.getSurfaceTexture());

camera.createCaptureSession(
Arrays.asList(surface), new CaptureSessionCallback(), cameraThreadHandler);
} catch (CameraAccessException e) {
} catch (Exception e) {
reportError("Failed to create capture session. " + e);
return;
}
Expand Down

0 comments on commit 7ba1fdf

Please sign in to comment.