Cherry-pick 19a6a3753222. rdar://problem/97102894
In iOS 16 beta 20A5312j, Chrome 103 calls getUserMedia() will get black video
https://bugs.webkit.org/show_bug.cgi?id=242795
rdar://problem/97102894
Reviewed by Jer Noble.
* Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm:
(WebCore::AVVideoCaptureSource::setupSession):
WKWebView applications may not always have an identity due to a lower level bug.
In that case, we can capture using the previous API without identity.
Add logging to ensure we notice that we do not provide identity.
Canonical link: https://commits.webkit.org/252591@main
Canonical link: https://commits.webkit.org/252432.15@safari-7614.1.22.0-branch
diff --git a/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm b/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm
index 5e8a277..7a84051 100644
--- a/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm
+++ b/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm
@@ -423,10 +423,7 @@
#if ENABLE(APP_PRIVACY_REPORT)
auto identity = RealtimeMediaSourceCenter::singleton().identity();
- if (!identity) {
- ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "RealtimeMediaSourceCenter::identity() returned null!");
- return false;
- }
+ ERROR_LOG_IF(loggerPtr() && !identity, LOGIDENTIFIER, "RealtimeMediaSourceCenter::identity() returned null!");
if (identity && [PAL::getAVCaptureSessionClass() instancesRespondToSelector:@selector(initWithAssumedIdentity:)])
m_session = adoptNS([PAL::allocAVCaptureSessionInstance() initWithAssumedIdentity:identity.get()]);
@@ -437,6 +434,7 @@
if (!m_session) {
ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "failed to allocate AVCaptureSession");
+ captureFailed();
return false;
}