Make AVVideoCaptureSource more robust to configuration failures
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 May 2019 21:29:14 +0000 (21:29 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 May 2019 21:29:14 +0000 (21:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197997
rdar://problem/50875662

Reviewed by Eric Carlson.

Covered by manual testing.

* platform/mediastream/mac/AVVideoCaptureSource.mm:
(WebCore::AVVideoCaptureSource::setSessionSizeAndFrameRate):
Make sure to commit configuration once calling beginConfiguration.
In case of error in setting frame rate, log the error but continue capturing.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245478 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm

index 5b989f3..fc3fdc9 100644 (file)
@@ -1,3 +1,18 @@
+2019-05-17  Youenn Fablet  <youenn@apple.com>
+
+        Make AVVideoCaptureSource more robust to configuration failures
+        https://bugs.webkit.org/show_bug.cgi?id=197997
+        rdar://problem/50875662
+
+        Reviewed by Eric Carlson.
+
+        Covered by manual testing.
+
+        * platform/mediastream/mac/AVVideoCaptureSource.mm:
+        (WebCore::AVVideoCaptureSource::setSessionSizeAndFrameRate):
+        Make sure to commit configuration once calling beginConfiguration.
+        In case of error in setting frame rate, log the error but continue capturing.
+
 2019-05-17  Rob Buis  <rbuis@igalia.com>
 
         Implement imagesrcset and imagesizes attributes on link rel=preload
index 3cdca30..f66d011 100644 (file)
@@ -324,20 +324,21 @@ void AVVideoCaptureSource::setSessionSizeAndFrameRate()
 
             auto* frameRateRange = frameDurationForFrameRate(m_currentFrameRate);
             ASSERT(frameRateRange);
-            if (!frameRateRange)
-                return;
+            if (frameRateRange) {
+                m_currentFrameRate = clampTo(m_currentFrameRate, frameRateRange.minFrameRate, frameRateRange.maxFrameRate);
 
-            m_currentFrameRate = clampTo(m_currentFrameRate, frameRateRange.minFrameRate, frameRateRange.maxFrameRate);
-
-            ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER, "setting frame rate to ", m_currentFrameRate);
-            [device() setActiveVideoMinFrameDuration: CMTimeMake(1, m_currentFrameRate)];
-            [device() setActiveVideoMaxFrameDuration: CMTimeMake(1, m_currentFrameRate)];
+                ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER, "setting frame rate to ", m_currentFrameRate);
+                [device() setActiveVideoMinFrameDuration: CMTimeMake(1, m_currentFrameRate)];
+                [device() setActiveVideoMaxFrameDuration: CMTimeMake(1, m_currentFrameRate)];
+            } else
+                ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "cannot find proper frame rate range for the selected preset\n");
 
             [device() unlockForConfiguration];
         }
     } @catch(NSException *exception) {
         ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "error configuring device ", [[exception name] UTF8String], ", reason : ", [[exception reason] UTF8String]);
-        return;
+        [device() unlockForConfiguration];
+        ASSERT_NOT_REACHED();
     }
     [m_session commitConfiguration];