Bug 1420585 - remove unnecessary stopCapture which causes deadlock. r=jib
authorMunro Mengjue Chiang <mchiang@mozilla.com>
Fri, 05 Jan 2018 15:50:23 +0800
changeset 453538 f5b452454285510ee2d3358332e19c3ad4fa0ec8
parent 453537 c5d312561c224c3c80b2eedb89d17c4f8b30bfe4
child 453539 0e8dc361a38f32d0faad3e85df0676d05e06b2d8
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1420585
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1420585 - remove unnecessary stopCapture which causes deadlock. r=jib MozReview-Commit-ID: F8xcOSPihDN
media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/VideoCaptureAndroid.java
--- a/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/VideoCaptureAndroid.java
+++ b/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/VideoCaptureAndroid.java
@@ -243,21 +243,23 @@ public class VideoCaptureAndroid impleme
       averageDurationMs = 1000000.0f / (max_mfps / frameDropRatio);
       camera.startPreview();
       exchange(result, true);
       return;
     } catch (RuntimeException e) {
       error = e;
     }
     Log.e(TAG, "startCapture failed", error);
-    if (camera != null) {
-      Exchanger<Boolean> resultDropper = new Exchanger<Boolean>();
-      stopCaptureOnCameraThread(resultDropper);
-      exchange(resultDropper, false);
-    }
+    // For some devices, camera.setParameters(parameters) would throw
+    // an exception when a specific resolution is set. Originally,
+    // stopCaptureOnCameraThread() is called here to clear up the state.
+    // However, stopCaptureOnCameraThread(), which uses Exchanger to
+    // synchronize and swap data with MediaManager thread, is supposed to be
+    // called by MediaManager thread like we did at stopCapture(). Calling
+    // this function directly in CameraThread will cause deadlock.
     exchange(result, false);
     return;
   }
 
   // Called by native code.  Returns true when camera is known to be stopped.
   @WebRTCJNITarget
   private synchronized boolean stopCapture() {
     Log.d(TAG, "stopCapture");