Title: [295613] trunk/Source/WebCore/platform/mediastream/mac/ScreenCaptureKitCaptureSource.mm
Revision
295613
Author
[email protected]
Date
2022-06-16 14:48:09 -0700 (Thu, 16 Jun 2022)

Log Message

[macOS] Unable to resume screen sharing after it is paused
https://bugs.webkit.org/show_bug.cgi?id=241693
rdar://93573937

Reviewed by Youenn Fablet.

* Source/WebCore/platform/mediastream/mac/ScreenCaptureKitCaptureSource.mm:
(WebCore::ScreenCaptureKitCaptureSource::stop): Clear m_contentStream in the completion handler.
(WebCore::ScreenCaptureKitCaptureSource::startContentStream): Don't recreate instance variables
that already exist.

Canonical link: https://commits.webkit.org/251618@main

Modified Paths

Diff

Modified: trunk/Source/WebCore/platform/mediastream/mac/ScreenCaptureKitCaptureSource.mm (295612 => 295613)


--- trunk/Source/WebCore/platform/mediastream/mac/ScreenCaptureKitCaptureSource.mm	2022-06-16 20:45:19 UTC (rev 295612)
+++ trunk/Source/WebCore/platform/mediastream/mac/ScreenCaptureKitCaptureSource.mm	2022-06-16 21:48:09 UTC (rev 295613)
@@ -212,11 +212,13 @@
 
     if (m_contentStream) {
         auto stopHandler = makeBlockPtr([weakThis = WeakPtr { *this }] (NSError *error) mutable {
-            if (!error)
-                return;
 
             callOnMainRunLoop([weakThis = WTFMove(weakThis), error = RetainPtr { error }]() mutable {
-                if (weakThis)
+                if (!weakThis)
+                    return;
+
+                weakThis->m_contentStream = nil;
+                if (error)
                     weakThis->streamFailedWithError(WTFMove(error), "-[SCStream stopCaptureWithCompletionHandler:] failed"_s);
             });
         });
@@ -384,18 +386,20 @@
         return;
     }
 
-    m_contentFilter = switchOn(m_content.value(),
-        [] (const RetainPtr<SCDisplay> display) -> RetainPtr<SCContentFilter> {
-            return adoptNS([PAL::allocSCContentFilterInstance() initWithDisplay:display.get() excludingWindows:@[]]);
-        },
-        [] (const RetainPtr<SCWindow> window)  -> RetainPtr<SCContentFilter> {
-            return adoptNS([PAL::allocSCContentFilterInstance() initWithDesktopIndependentWindow:window.get()]);
+    if (!m_contentFilter) {
+        m_contentFilter = switchOn(m_content.value(),
+            [] (const RetainPtr<SCDisplay> display) -> RetainPtr<SCContentFilter> {
+                return adoptNS([PAL::allocSCContentFilterInstance() initWithDisplay:display.get() excludingWindows:@[]]);
+            },
+            [] (const RetainPtr<SCWindow> window)  -> RetainPtr<SCContentFilter> {
+                return adoptNS([PAL::allocSCContentFilterInstance() initWithDesktopIndependentWindow:window.get()]);
+            }
+        );
+
+        if (!m_contentFilter) {
+            streamFailedWithError(nil, "Failed to allocate SCContentFilter"_s);
+            return;
         }
-    );
-
-    if (!m_contentFilter) {
-        streamFailedWithError(nil, "Failed to allocate SCContentFilter"_s);
-        return;
     }
 
     if (!m_captureHelper)
@@ -405,10 +409,12 @@
 
 #if HAVE(SC_CONTENT_SHARING_SESSION)
     if (ScreenCaptureKitSharingSessionManager::isAvailable()) {
-        m_contentSharingSession = ScreenCaptureKitSharingSessionManager::singleton().takeSharingSessionForFilter(m_contentFilter.get());
         if (!m_contentSharingSession) {
-            streamFailedWithError(nil, "Failed to get SharingSession"_s);
-            return;
+            m_contentSharingSession = ScreenCaptureKitSharingSessionManager::singleton().takeSharingSessionForFilter(m_contentFilter.get());
+            if (!m_contentSharingSession) {
+                streamFailedWithError(nil, "Failed to get SharingSession"_s);
+                return;
+            }
         }
 
         m_contentStream = adoptNS([PAL::allocSCStreamInstance() initWithSharingSession:m_contentSharingSession.get() captureOutputProperties:streamConfiguration().get() delegate:m_captureHelper.get()]);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to