Skip to content
Permalink
Browse files
[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
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295613 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
eric-carlson committed Jun 16, 2022
1 parent 0fca67f commit ea5f10646c740d05d56eb37337281359abd480ac
Showing 1 changed file with 23 additions and 17 deletions.
@@ -212,11 +212,13 @@ - (void)pickerCanceledForSession:(SCContentSharingSession *)session

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 @@ static void findSharableDevice(RetainPtr<SCShareableContent>&& shareableContent,
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) {
streamFailedWithError(nil, "Failed to allocate SCContentFilter"_s);
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) {
streamFailedWithError(nil, "Failed to allocate SCContentFilter"_s);
return;
}
}

if (!m_captureHelper)
@@ -405,10 +409,12 @@ static void findSharableDevice(RetainPtr<SCShareableContent>&& shareableContent,

#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()]);

0 comments on commit ea5f106

Please sign in to comment.