Skip to content

Commit 7ba1fdf

Browse files
tmoldovan8x8saghul
authored andcommitted
JITSI: catch all exceptions that occur on CaptureSession creation
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)
1 parent 4d75330 commit 7ba1fdf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sdk/android/src/java/org/webrtc/Camera2Session.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,13 @@ public void onOpened(CameraDevice camera) {
119119
Logging.d(TAG, "Camera opened.");
120120
cameraDevice = camera;
121121

122-
surfaceTextureHelper.setTextureSize(captureFormat.width, captureFormat.height);
123-
surface = new Surface(surfaceTextureHelper.getSurfaceTexture());
124122
try {
123+
surfaceTextureHelper.setTextureSize(captureFormat.width, captureFormat.height);
124+
surface = new Surface(surfaceTextureHelper.getSurfaceTexture());
125+
125126
camera.createCaptureSession(
126127
Arrays.asList(surface), new CaptureSessionCallback(), cameraThreadHandler);
127-
} catch (CameraAccessException e) {
128+
} catch (Exception e) {
128129
reportError("Failed to create capture session. " + e);
129130
return;
130131
}

0 commit comments

Comments
 (0)