Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 62cf082

Browse files
committed
Bug 1703522. Allow IOSurface capture by default. r=pehrsons
This cuts the time spent in CaptureFrame for a buffer size of 3072x1920 from ~80ms to ~22ms for me. It makes it so that we use the IOSurfaces provided to the CGDisplayStreamCreate handler instead of calling CGDisplayCreateImage. It was enable by default in Chromium in 2018 via https://source.chromium.org/chromium/chromium/src/+/09cd5826e743af9dbcbde8ab36f73f5e0bd55f6c Differential Revision: https://phabricator.services.mozilla.com/D157273
1 parent 7669c81 commit 62cf082

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

dom/media/systemservices/video_engine/desktop_capture_impl.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "modules/desktop_capture/desktop_frame.h"
2929
#include "modules/desktop_capture/desktop_capture_options.h"
3030
#include "modules/video_capture/video_capture.h"
31+
#include "mozilla/StaticPrefs_media.h"
3132

3233
#if defined(_WIN32)
3334
# include "platform_uithread.h"
@@ -335,6 +336,12 @@ int32_t DesktopCaptureImpl::LazyInitDesktopCapturer() {
335336
// Leave desktop effects enabled during WebRTC captures.
336337
options.set_disable_effects(false);
337338

339+
#if defined(WEBRTC_MAC)
340+
if (mozilla::StaticPrefs::media_webrtc_capture_allow_iosurface()) {
341+
options.set_allow_iosurface(true);
342+
}
343+
#endif
344+
338345
if (_deviceType == CaptureDeviceType::Screen) {
339346
std::unique_ptr<DesktopCapturer> pScreenCapturer =
340347
DesktopCapturer::CreateScreenCapturer(options);

modules/libpref/init/StaticPrefList.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10081,6 +10081,11 @@
1008110081
value: @IS_EARLY_BETA_OR_EARLIER@
1008210082
mirror: always
1008310083

10084+
- name: media.webrtc.capture.allow-iosurface
10085+
type: RelaxedAtomicBool
10086+
value: true
10087+
mirror: always
10088+
1008410089
- name: media.block-autoplay-until-in-foreground
1008510090
type: bool
1008610091
#if !defined(MOZ_WIDGET_ANDROID)

0 commit comments

Comments
 (0)