- Revision
- 287715
- Author
- [email protected]
- Date
- 2022-01-06 13:01:52 -0800 (Thu, 06 Jan 2022)
Log Message
Microphone device filtering heuristic is too harsh
https://bugs.webkit.org/show_bug.cgi?id=234596
<rdar://problem/86803287>
Reviewed by Eric Carlson.
Source/WebCore:
When audio capture happens, there are more audio devices and some audio devices get an input stream for echo cancellation.
We add an API to disable that filtering which is used when capture is not done in the process where audio enumeration is done.
A longer term solution should look at doing this filtering in all cases.
Manually tested in Safari and Minibrowser.
* WebCore.xcodeproj/project.pbxproj:
* platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp:
* platform/mediastream/mac/CoreAudioCaptureDeviceManager.h:
Source/WebKit:
* UIProcess/WebPageProxy.cpp:
Disable filtering if audio capture happens in GPUProcess.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (287714 => 287715)
--- trunk/Source/WebCore/ChangeLog 2022-01-06 20:51:35 UTC (rev 287714)
+++ trunk/Source/WebCore/ChangeLog 2022-01-06 21:01:52 UTC (rev 287715)
@@ -1,3 +1,21 @@
+2022-01-06 Youenn Fablet <[email protected]>
+
+ Microphone device filtering heuristic is too harsh
+ https://bugs.webkit.org/show_bug.cgi?id=234596
+ <rdar://problem/86803287>
+
+ Reviewed by Eric Carlson.
+
+ When audio capture happens, there are more audio devices and some audio devices get an input stream for echo cancellation.
+ We add an API to disable that filtering which is used when capture is not done in the process where audio enumeration is done.
+ A longer term solution should look at doing this filtering in all cases.
+
+ Manually tested in Safari and Minibrowser.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp:
+ * platform/mediastream/mac/CoreAudioCaptureDeviceManager.h:
+
2022-01-06 Simon Fraser <[email protected]>
A gentle momentum scroll into an edge sometimes fails to rubberband, stopping abruptly
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (287714 => 287715)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-01-06 20:51:35 UTC (rev 287714)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-01-06 21:01:52 UTC (rev 287715)
@@ -1055,7 +1055,7 @@
3F2B33EF165AF15600E3987C /* JSWebKitCSSViewportRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F2B33EA165AF15500E3987C /* JSWebKitCSSViewportRule.h */; };
3F42B31D1881191B00278AAC /* WebVideoFullscreenControllerAVKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F42B31B1881191B00278AAC /* WebVideoFullscreenControllerAVKit.h */; settings = {ATTRIBUTES = (Private, ); }; };
3F8020351E9E47BF00DEC61D /* CoreAudioCaptureDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F8020321E9E381D00DEC61D /* CoreAudioCaptureDevice.h */; };
- 3F8020371E9E47C500DEC61D /* CoreAudioCaptureDeviceManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F8020341E9E381D00DEC61D /* CoreAudioCaptureDeviceManager.h */; };
+ 3F8020371E9E47C500DEC61D /* CoreAudioCaptureDeviceManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F8020341E9E381D00DEC61D /* CoreAudioCaptureDeviceManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
3FBC4AF3189881560046EE38 /* VideoFullscreenInterfaceAVKit.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3FBC4AF1189881560046EE38 /* VideoFullscreenInterfaceAVKit.mm */; };
3FBC4AF4189881560046EE38 /* VideoFullscreenInterfaceAVKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FBC4AF2189881560046EE38 /* VideoFullscreenInterfaceAVKit.h */; settings = {ATTRIBUTES = (Private, ); }; };
3FF813A71DBA8640009BF001 /* PointerLockController.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CFC434F192406A900A0D3B5 /* PointerLockController.h */; settings = {ATTRIBUTES = (Private, ); }; };
Modified: trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp (287714 => 287715)
--- trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp 2022-01-06 20:51:35 UTC (rev 287714)
+++ trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp 2022-01-06 21:01:52 UTC (rev 287715)
@@ -111,28 +111,30 @@
return deviceHasStreams(deviceID, address);
}
-static bool isValidCaptureDevice(const CoreAudioCaptureDevice& device)
+static bool isValidCaptureDevice(const CoreAudioCaptureDevice& device, bool filterTapEnabledDevices)
{
- // Ignore output devices that have input only for echo cancellation.
- AudioObjectPropertyAddress address = {
- kAudioDevicePropertyTapEnabled,
- kAudioDevicePropertyScopeOutput,
+ if (filterTapEnabledDevices) {
+ // Ignore output devices that have input only for echo cancellation.
+ AudioObjectPropertyAddress address = {
+ kAudioDevicePropertyTapEnabled,
+ kAudioDevicePropertyScopeOutput,
#if HAVE(AUDIO_OBJECT_PROPERTY_ELEMENT_MAIN)
- kAudioObjectPropertyElementMain
+ kAudioObjectPropertyElementMain
#else
- ALLOW_DEPRECATED_DECLARATIONS_BEGIN
- kAudioObjectPropertyElementMaster
- ALLOW_DEPRECATED_DECLARATIONS_END
+ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
+ kAudioObjectPropertyElementMaster
+ ALLOW_DEPRECATED_DECLARATIONS_END
#endif
- };
- if (AudioObjectHasProperty(device.deviceID(), &address)) {
- RELEASE_LOG(WebRTC, "Ignoring output device that have input only for echo cancellation");
- return false;
+ };
+ if (AudioObjectHasProperty(device.deviceID(), &address)) {
+ RELEASE_LOG(WebRTC, "Ignoring output device that have input only for echo cancellation");
+ return false;
+ }
}
// Ignore non-aggregable devices.
UInt32 dataSize = 0;
- address = {
+ AudioObjectPropertyAddress address = {
kAudioObjectPropertyCreator,
kAudioObjectPropertyScopeGlobal,
#if HAVE(AUDIO_OBJECT_PROPERTY_ELEMENT_MAIN)
@@ -266,7 +268,7 @@
});
}
-static inline Vector<CoreAudioCaptureDevice> computeAudioDeviceList()
+static inline Vector<CoreAudioCaptureDevice> computeAudioDeviceList(bool filterTapEnabledDevices)
{
AudioObjectPropertyAddress address = {
kAudioHardwarePropertyDevices,
@@ -304,7 +306,7 @@
continue;
auto microphoneDevice = CoreAudioCaptureDevice::create(deviceID, CaptureDevice::DeviceType::Microphone, { });
- if (microphoneDevice && isValidCaptureDevice(microphoneDevice.value()))
+ if (microphoneDevice && isValidCaptureDevice(microphoneDevice.value(), filterTapEnabledDevices))
audioDevices.append(WTFMove(microphoneDevice.value()));
}
@@ -346,7 +348,7 @@
{
ASSERT(isMainThread());
- auto audioDevices = computeAudioDeviceList();
+ auto audioDevices = computeAudioDeviceList(m_filterTapEnabledDevices);
bool haveDeviceChanges = audioDevices.size() != m_coreAudioCaptureDevices.size();
if (!haveDeviceChanges) {
for (size_t cptr = 0; cptr < audioDevices.size(); ++cptr) {
Modified: trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureDeviceManager.h (287714 => 287715)
--- trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureDeviceManager.h 2022-01-06 20:51:35 UTC (rev 287714)
+++ trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureDeviceManager.h 2022-01-06 21:01:52 UTC (rev 287715)
@@ -27,7 +27,6 @@
#if ENABLE(MEDIA_STREAM) && PLATFORM(MAC)
-#include "CaptureDevice.h"
#include "CaptureDeviceManager.h"
#include <CoreAudio/CoreAudio.h>
#include <wtf/text/WTFString.h>
@@ -39,7 +38,7 @@
class CoreAudioCaptureDeviceManager final : public CaptureDeviceManager {
friend class NeverDestroyed<CoreAudioCaptureDeviceManager>;
public:
- static CoreAudioCaptureDeviceManager& singleton();
+ WEBCORE_EXPORT static CoreAudioCaptureDeviceManager& singleton();
const Vector<CaptureDevice>& captureDevices() final;
std::optional<CaptureDevice> captureDeviceWithPersistentID(CaptureDevice::DeviceType, const String&);
@@ -47,6 +46,8 @@
std::optional<CoreAudioCaptureDevice> coreAudioDeviceWithUID(const String&);
const Vector<CaptureDevice>& speakerDevices() const { return m_speakerDevices; }
+ void setFilterTapEnabledDevices(bool doFiltering) { m_filterTapEnabledDevices = doFiltering; }
+
private:
CoreAudioCaptureDeviceManager() = default;
~CoreAudioCaptureDeviceManager() = default;
@@ -61,6 +62,7 @@
Vector<CaptureDevice> m_speakerDevices;
Vector<CoreAudioCaptureDevice> m_coreAudioCaptureDevices;
bool m_wasRefreshAudioCaptureDevicesScheduled { false };
+ bool m_filterTapEnabledDevices { true };
};
} // namespace WebCore
Modified: trunk/Source/WebKit/ChangeLog (287714 => 287715)
--- trunk/Source/WebKit/ChangeLog 2022-01-06 20:51:35 UTC (rev 287714)
+++ trunk/Source/WebKit/ChangeLog 2022-01-06 21:01:52 UTC (rev 287715)
@@ -1,3 +1,14 @@
+2022-01-06 Youenn Fablet <[email protected]>
+
+ Microphone device filtering heuristic is too harsh
+ https://bugs.webkit.org/show_bug.cgi?id=234596
+ <rdar://problem/86803287>
+
+ Reviewed by Eric Carlson.
+
+ * UIProcess/WebPageProxy.cpp:
+ Disable filtering if audio capture happens in GPUProcess.
+
2022-01-06 Tim Horton <[email protected]>
Always assume Safari is "linked-on-or-after" any SDK version
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (287714 => 287715)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2022-01-06 20:51:35 UTC (rev 287714)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2022-01-06 21:01:52 UTC (rev 287715)
@@ -222,6 +222,7 @@
#include "VideoFullscreenManagerProxy.h"
#include "VideoFullscreenManagerProxyMessages.h"
#include <WebCore/AttributedString.h>
+#include <WebCore/CoreAudioCaptureDeviceManager.h>
#include <WebCore/RunLoopObserver.h>
#include <WebCore/SystemBattery.h>
#include <WebCore/VersionChecks.h>
@@ -8607,7 +8608,9 @@
{
#if ENABLE(MEDIA_STREAM)
MESSAGE_CHECK(m_process, m_process->webFrame(frameID));
-
+#if PLATFORM(MAC)
+ CoreAudioCaptureDeviceManager::singleton().setFilterTapEnabledDevices(!preferences().captureAudioInGPUProcessEnabled());
+#endif
userMediaPermissionRequestManager().requestUserMediaPermissionForFrame(userMediaID, frameID, userMediaDocumentOriginData.securityOrigin(), topLevelDocumentOriginData.securityOrigin(), WTFMove(request));
#else
UNUSED_PARAM(userMediaID);