chore(todo): debug patch

This commit is contained in:
Keeley Hammond
2025-04-15 16:36:03 -07:00
parent e364a20ba1
commit 589272e065
5 changed files with 159 additions and 408 deletions

View File

@@ -12,8 +12,8 @@ async function getNativePickerSource (preferredDisplaySurface: string) {
// Fake video window that activates the native system picker
// This is used to get around the need for a screen/window
// id in Chrome's desktopCapturer.
let fakeVideoWindowId = -1;
const kMacOsNativePickerId = -4;
// let fakeVideoWindowId = -1;
// const kMacOsNativePickerId = -4;
if (process.platform !== 'darwin') {
throw new Error('Native system picker option is currently only supported on MacOS');
@@ -53,7 +53,7 @@ async function getNativePickerSource (preferredDisplaySurface: string) {
throw new Error('No media streams found');
}
mediaStreams[0].id = `none:${kMacOsNativePickerId}:${fakeVideoWindowId--}`;
// mediaStreams[0].id = `none:${kMacOsNativePickerId}:${fakeVideoWindowId--}`;
console.log('SESSION.TS mediaStreams', mediaStreams);
return mediaStreams[0];
}
@@ -89,7 +89,7 @@ Session.prototype.setDisplayMediaRequestHandler = function (handler, opts) {
return callback({ video: await getNativePickerSource(request.preferredDisplaySurface) });
}
return handler(request, callback);
// return handler(request, callback);
}, opts);
};

View File

@@ -128,7 +128,6 @@ chore_remove_reference_to_chrome_browser_themes.patch
feat_enable_customizing_symbol_color_in_framecaptionbutton.patch
build_allow_electron_mojom_interfaces_to_depend_on_blink.patch
osr_shared_texture_remove_keyed_mutex_on_win_dxgi.patch
feat_allow_usage_of_sccontentsharingpicker_on_supported_platforms.patch
chore_partial_revert_of.patch
fix_software_compositing_infinite_loop.patch
fix_add_method_which_disables_headless_mode_on_native_widget.patch
@@ -144,3 +143,4 @@ fix_enable_wrap_iter_in_string_view_and_array.patch
fix_linter_error.patch
fix_take_snapped_status_into_account_when_showing_a_window.patch
feat_make_macos_sccontentsharingpicker_work_in_electron_and_return_screen_window_or_both.patch
fix_debug_desktop_capturer_picture.patch

View File

@@ -1,383 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <marshallofsound@electronjs.org>
Date: Thu, 8 Aug 2024 08:39:10 -0700
Subject: feat: allow usage of SCContentSharingPicker on supported platforms
This is implemented as a magic "window id" that instead of pulling an SCStream manually
instead farms out to the screen picker.
diff --git a/content/browser/media/capture/desktop_capture_device_mac.cc b/content/browser/media/capture/desktop_capture_device_mac.cc
index afb657b7c9e1ede1273532b16428d37cc5d75c59..16707cf516cd34682c84ea2ccebddaa0f84e01f8 100644
--- a/content/browser/media/capture/desktop_capture_device_mac.cc
+++ b/content/browser/media/capture/desktop_capture_device_mac.cc
@@ -29,7 +29,7 @@ class DesktopCaptureDeviceMac : public IOSurfaceCaptureDeviceBase {
~DesktopCaptureDeviceMac() override = default;
// IOSurfaceCaptureDeviceBase:
- void OnStart() override {
+ void OnStart(std::optional<bool> use_native_picker) override {
requested_format_ = capture_params().requested_format;
requested_format_.pixel_format = media::PIXEL_FORMAT_NV12;
DCHECK_GT(requested_format_.frame_size.GetArea(), 0);
diff --git a/content/browser/media/capture/io_surface_capture_device_base_mac.cc b/content/browser/media/capture/io_surface_capture_device_base_mac.cc
index 4ec4c895423151d2c907d97de1461cbde8c8a639..0e59797833b81c07299b8c342f591e192183c6f1 100644
--- a/content/browser/media/capture/io_surface_capture_device_base_mac.cc
+++ b/content/browser/media/capture/io_surface_capture_device_base_mac.cc
@@ -20,7 +20,7 @@ void IOSurfaceCaptureDeviceBase::AllocateAndStart(
client_ = std::move(client);
capture_params_ = params;
- OnStart();
+ OnStart(params.use_native_picker);
}
void IOSurfaceCaptureDeviceBase::StopAndDeAllocate() {
diff --git a/content/browser/media/capture/io_surface_capture_device_base_mac.h b/content/browser/media/capture/io_surface_capture_device_base_mac.h
index e2771b7b281274cdcb601a5bc78a948ad592087b..48d116823a28213e50775f378e6ce04ce3af5072 100644
--- a/content/browser/media/capture/io_surface_capture_device_base_mac.h
+++ b/content/browser/media/capture/io_surface_capture_device_base_mac.h
@@ -25,7 +25,7 @@ class CONTENT_EXPORT IOSurfaceCaptureDeviceBase
~IOSurfaceCaptureDeviceBase() override;
// OnStart is called by AllocateAndStart.
- virtual void OnStart() = 0;
+ virtual void OnStart(std::optional<bool> use_native_picker) = 0;
// OnStop is called by StopAndDeAllocate.
virtual void OnStop() = 0;
diff --git a/content/browser/media/capture/screen_capture_kit_device_mac.mm b/content/browser/media/capture/screen_capture_kit_device_mac.mm
index 7e17594c30ac3cf8cb484b53563b03fc75bd2e0b..0e4a68f2fd8179640f877cb258b4049610fd49da 100644
--- a/content/browser/media/capture/screen_capture_kit_device_mac.mm
+++ b/content/browser/media/capture/screen_capture_kit_device_mac.mm
@@ -27,6 +27,61 @@
std::optional<float>,
bool)>;
using ErrorCallback = base::RepeatingClosure;
+using CancelCallback = base::RepeatingClosure;
+
+API_AVAILABLE(macos(15.0))
+@interface ScreenCaptureKitPickerHelper
+ : NSObject <SCContentSharingPickerObserver>
+
+- (void)contentSharingPicker:(SCContentSharingPicker *)picker
+ didCancelForStream:(SCStream *)stream;
+
+- (void)contentSharingPicker:(SCContentSharingPicker *)picker
+ didUpdateWithFilter:(SCContentFilter *)filter
+ forStream:(SCStream *)stream;
+
+- (void)contentSharingPickerStartDidFailWithError:(NSError *)error;
+
+@end
+
+@implementation ScreenCaptureKitPickerHelper {
+ base::RepeatingCallback<void(SCContentFilter *)> _pickerCallback;
+ ErrorCallback _errorCallback;
+ CancelCallback _cancelCallback;
+}
+
+- (void)contentSharingPicker:(SCContentSharingPicker *)picker
+ didCancelForStream:(SCStream *)stream {
+ // TODO: This doesn't appear to be called on Apple's side;
+ // implement this logic
+ _cancelCallback.Run();
+}
+
+- (void)contentSharingPicker:(SCContentSharingPicker *)picker
+ didUpdateWithFilter:(SCContentFilter *)filter
+ forStream:(SCStream *)stream {
+ if (stream == nil) {
+ _pickerCallback.Run(filter);
+ [picker removeObserver:self];
+ }
+}
+
+- (void)contentSharingPickerStartDidFailWithError:(NSError *)error {
+ _errorCallback.Run();
+}
+
+- (instancetype)initWithStreamPickCallback:(base::RepeatingCallback<void(SCContentFilter *)>)pickerCallback
+ cancelCallback:(CancelCallback)cancelCallback
+ errorCallback:(ErrorCallback)errorCallback {
+ if (self = [super init]) {
+ _pickerCallback = pickerCallback;
+ _cancelCallback = cancelCallback;
+ _errorCallback = errorCallback;
+ }
+ return self;
+}
+
+@end
namespace {
API_AVAILABLE(macos(12.3))
@@ -123,18 +178,22 @@ @interface ScreenCaptureKitDeviceHelper
: NSObject <SCStreamDelegate, SCStreamOutput>
- (instancetype)initWithSampleCallback:(SampleCallback)sampleCallback
+ cancelCallback:(CancelCallback)cancelCallback
errorCallback:(ErrorCallback)errorCallback;
@end
@implementation ScreenCaptureKitDeviceHelper {
SampleCallback _sampleCallback;
+ CancelCallback _cancelCallback;
ErrorCallback _errorCallback;
}
- (instancetype)initWithSampleCallback:(SampleCallback)sampleCallback
+ cancelCallback:(CancelCallback)cancelCallback
errorCallback:(ErrorCallback)errorCallback {
if (self = [super init]) {
_sampleCallback = sampleCallback;
+ _cancelCallback = cancelCallback;
_errorCallback = errorCallback;
}
return self;
@@ -211,29 +270,53 @@ + (SCStreamConfiguration*)streamConfigurationWithFrameSize:(gfx::Size)frameSize
class API_AVAILABLE(macos(12.3)) ScreenCaptureKitDeviceMac
: public IOSurfaceCaptureDeviceBase,
- public ScreenCaptureKitResetStreamInterface {
+ public ScreenCaptureKitResetStreamInterface
+ {
public:
explicit ScreenCaptureKitDeviceMac(const DesktopMediaID& source,
- SCContentFilter* filter)
+ [[maybe_unused]] SCContentFilter* filter)
: source_(source),
- filter_(filter),
device_task_runner_(base::SingleThreadTaskRunner::GetCurrentDefault()) {
SampleCallback sample_callback = base::BindPostTask(
device_task_runner_,
base::BindRepeating(&ScreenCaptureKitDeviceMac::OnStreamSample,
weak_factory_.GetWeakPtr()));
+ CancelCallback cancel_callback = base::BindPostTask(
+ device_task_runner_,
+ base::BindRepeating(&ScreenCaptureKitDeviceMac::OnStreamError,
+ weak_factory_.GetWeakPtr()));
ErrorCallback error_callback = base::BindPostTask(
device_task_runner_,
base::BindRepeating(&ScreenCaptureKitDeviceMac::OnStreamError,
weak_factory_.GetWeakPtr()));
helper_ = [[ScreenCaptureKitDeviceHelper alloc]
initWithSampleCallback:sample_callback
+ cancelCallback:cancel_callback
errorCallback:error_callback];
+
+ if (@available(macOS 15.0, *)) {
+ auto picker_callback = base::BindPostTask(
+ device_task_runner_,
+ base::BindRepeating(&ScreenCaptureKitDeviceMac::OnContentFilterReady, weak_factory_.GetWeakPtr())
+ );
+ picker_helper_ = [[ScreenCaptureKitPickerHelper alloc] initWithStreamPickCallback:picker_callback cancelCallback:cancel_callback errorCallback:error_callback];
+ [[SCContentSharingPicker sharedPicker] addObserver:picker_helper_];
+ }
}
ScreenCaptureKitDeviceMac(const ScreenCaptureKitDeviceMac&) = delete;
ScreenCaptureKitDeviceMac& operator=(const ScreenCaptureKitDeviceMac&) =
delete;
- ~ScreenCaptureKitDeviceMac() override = default;
+ ~ScreenCaptureKitDeviceMac() override {
+ if (@available(macOS 15.0, *)) {
+ auto* picker = [SCContentSharingPicker sharedPicker];
+ ScreenCaptureKitDeviceMac::active_streams_--;
+ picker.maximumStreamCount = @(ScreenCaptureKitDeviceMac::active_streams_);
+ if (ScreenCaptureKitDeviceMac::active_streams_ == 0 && picker.active) {
+ picker.active = false;
+ [[SCContentSharingPicker sharedPicker] removeObserver:picker_helper_];
+ }
+ }
+ }
void OnShareableContentCreated(SCShareableContent* content) {
DCHECK(device_task_runner_->RunsTasksInCurrentSequence());
@@ -301,7 +384,7 @@ void CreateStream(SCContentFilter* filter) {
return;
}
- if (@available(macOS 14.0, *)) {
+ if (@available(macOS 15.0, *)) {
// Update the content size. This step is neccessary when used together
// with SCContentSharingPicker. If the Chrome picker is used, it will
// change to retina resolution if applicable.
@@ -310,6 +393,9 @@ void CreateStream(SCContentFilter* filter) {
filter.contentRect.size.height * filter.pointPixelScale);
}
+ OnContentFilterReady(filter);
+ }
+ void OnContentFilterReady(SCContentFilter* filter) {
gfx::RectF dest_rect_in_frame;
actual_capture_format_ = capture_params().requested_format;
actual_capture_format_.pixel_format = media::PIXEL_FORMAT_NV12;
@@ -323,6 +409,7 @@ void CreateStream(SCContentFilter* filter) {
stream_ = [[SCStream alloc] initWithFilter:filter
configuration:config
delegate:helper_];
+
{
NSError* error = nil;
bool add_stream_output_result =
@@ -480,7 +567,7 @@ void OnStreamError() {
if (fullscreen_module_) {
fullscreen_module_->Reset();
}
- OnStart();
+ OnStart(std::nullopt);
} else {
client()->OnError(media::VideoCaptureError::kScreenCaptureKitStreamError,
FROM_HERE, "Stream delegate called didStopWithError");
@@ -503,23 +590,41 @@ void OnUpdateConfigurationError() {
}
// IOSurfaceCaptureDeviceBase:
- void OnStart() override {
+ void OnStart(std::optional<bool> use_native_picker) override {
DCHECK(device_task_runner_->RunsTasksInCurrentSequence());
- if (filter_) {
- // SCContentSharingPicker is used where filter_ is set on creation.
- CreateStream(filter_);
- } else {
- // Chrome picker is used.
- auto content_callback = base::BindPostTask(
- device_task_runner_,
- base::BindRepeating(
- &ScreenCaptureKitDeviceMac::OnShareableContentCreated,
- weak_factory_.GetWeakPtr()));
- auto handler = ^(SCShareableContent* content, NSError* error) {
- content_callback.Run(content);
- };
- [SCShareableContent getShareableContentWithCompletionHandler:handler];
+
+ if (@available(macOS 15.0, *)) {
+ constexpr bool DefaultUseNativePicker = true;
+ if (use_native_picker.value_or(DefaultUseNativePicker) &&
+ source_.id == DesktopMediaID::kMacOsNativePickerId &&
+ source_.window_id < 0) {
+ auto* picker = [SCContentSharingPicker sharedPicker];
+ ScreenCaptureKitDeviceMac::active_streams_++;
+ picker.maximumStreamCount = @(ScreenCaptureKitDeviceMac::active_streams_);
+ if (!picker.active) {
+ picker.active = true;
+ }
+ NSMutableArray<NSNumber*>* exclude_ns_windows = [NSMutableArray array];
+ [[[[NSApplication sharedApplication] windows] filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSWindow* win, NSDictionary *bindings) {
+ return [win sharingType] == NSWindowSharingNone;
+ }]] enumerateObjectsUsingBlock:^(NSWindow* win, NSUInteger idx, BOOL *stop) {
+ [exclude_ns_windows addObject:@([win windowNumber])];
+ }];
+ picker.defaultConfiguration.excludedWindowIDs = exclude_ns_windows;
+ [picker present];
+ return;
+ }
}
+
+ auto content_callback = base::BindPostTask(
+ device_task_runner_,
+ base::BindRepeating(
+ &ScreenCaptureKitDeviceMac::OnShareableContentCreated,
+ weak_factory_.GetWeakPtr()));
+ auto handler = ^(SCShareableContent* content, NSError* error) {
+ content_callback.Run(content);
+ };
+ [SCShareableContent getShareableContentWithCompletionHandler:handler];
}
void OnStop() override {
DCHECK(device_task_runner_->RunsTasksInCurrentSequence());
@@ -577,8 +682,9 @@ void ResetStreamTo(SCWindow* window) override {
}
private:
+ static int active_streams_;
+
const DesktopMediaID source_;
- SCContentFilter* const filter_;
const scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_;
// The actual format of the video frames that are sent to `client`.
@@ -594,6 +700,10 @@ void ResetStreamTo(SCWindow* window) override {
// Helper class that acts as output and delegate for `stream_`.
ScreenCaptureKitDeviceHelper* __strong helper_;
+ // Helper class that acts as an observer for SCContentSharingPicker
+ API_AVAILABLE(macos(15.0))
+ ScreenCaptureKitPickerHelper* __strong picker_helper_;
+
// This is used to detect when a captured presentation enters fullscreen mode.
// If this happens, the module will call the ResetStreamTo function.
std::unique_ptr<ScreenCaptureKitFullscreenModule> fullscreen_module_;
@@ -606,6 +716,8 @@ void ResetStreamTo(SCWindow* window) override {
base::WeakPtrFactory<ScreenCaptureKitDeviceMac> weak_factory_{this};
};
+int ScreenCaptureKitDeviceMac::active_streams_ = 0;
+
} // namespace
// Although ScreenCaptureKit is available in 12.3 there were some bugs that
diff --git a/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc b/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc
index 0ab684dc8e792359abb90b91917eddae42e6123d..f0f08a834f06c7669da6030640434308a5cbd056 100644
--- a/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc
+++ b/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc
@@ -316,8 +316,16 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
break;
}
+#if defined(USE_AURA)
+ bool allow_window_id = false;
+#elif BUILDFLAG(IS_MAC)
+ bool allow_window_id =
+ desktop_id.id == DesktopMediaID::kMacOsNativePickerId;
+#endif
+
#if defined(USE_AURA) || BUILDFLAG(IS_MAC)
- if (desktop_id.window_id != DesktopMediaID::kNullId) {
+ if (!allow_window_id &&
+ desktop_id.window_id != DesktopMediaID::kNullId) {
// For the other capturers, when a bug reports the type of capture it's
// easy enough to determine which capturer was used, but it's a little
// fuzzier with window capture.
@@ -333,13 +341,15 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
}
#endif // defined(USE_AURA) || BUILDFLAG(IS_MAC)
+ media::VideoCaptureParams updated_params = params;
+ updated_params.use_native_picker = stream_type != blink::mojom::MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE;
// All cases other than tab capture or Aura desktop/window capture.
TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("video_and_image_capture"),
"UsingDesktopCapturer", TRACE_EVENT_SCOPE_THREAD);
start_capture_closure = base::BindOnce(
&InProcessVideoCaptureDeviceLauncher::
DoStartDesktopCaptureOnDeviceThread,
- base::Unretained(this), desktop_id, params,
+ base::Unretained(this), desktop_id, updated_params,
CreateDeviceClient(media::VideoCaptureBufferType::kSharedMemory,
kMaxNumberOfBuffers, std::move(receiver),
std::move(receiver_on_io_thread)),
diff --git a/content/public/browser/desktop_media_id.h b/content/public/browser/desktop_media_id.h
index 415156d403a59bf426cf4561a9d58ecdb27524b4..78aa7b2359c684d5305bf6352751dfbb7ca00d29 100644
--- a/content/public/browser/desktop_media_id.h
+++ b/content/public/browser/desktop_media_id.h
@@ -27,6 +27,8 @@ struct CONTENT_EXPORT DesktopMediaID {
static constexpr Id kNullId = 0;
// Represents a fake id to create a dummy capturer for autotests.
static constexpr Id kFakeId = -3;
+ // Represents an id to use native macOS picker for screenshare
+ static constexpr Id kMacOsNativePickerId = -4;
#if defined(USE_AURA) || BUILDFLAG(IS_MAC)
// Assigns integer identifier to the |window| and returns its DesktopMediaID.
diff --git a/media/capture/video_capture_types.h b/media/capture/video_capture_types.h
index 53e8077c9c0b635df0abdeca43fa9a6373c68252..2805e36cc42190d8197d83f5df235094570e3d5d 100644
--- a/media/capture/video_capture_types.h
+++ b/media/capture/video_capture_types.h
@@ -355,6 +355,8 @@ struct CAPTURE_EXPORT VideoCaptureParams {
// Flag indicating whether HiDPI mode should be enabled for tab capture
// sessions.
bool is_high_dpi_enabled = true;
+
+ std::optional<bool> use_native_picker;
};
CAPTURE_EXPORT std::ostream& operator<<(

View File

@@ -357,10 +357,10 @@ index 0dbc7ebc4ba6066eb6b20f8e66f50a1dff4d94f3..17d658ee011b81208b77ee1e65925ae9
NOTREACHED();
}
diff --git a/content/browser/media/capture/screen_capture_kit_device_mac.mm b/content/browser/media/capture/screen_capture_kit_device_mac.mm
index 0e4a68f2fd8179640f877cb258b4049610fd49da..0fb8d036b7696e5303fbcd463114114aa3227a08 100644
index 7e17594c30ac3cf8cb484b53563b03fc75bd2e0b..fef50841f472bf3e76c171d9e106c689157adaae 100644
--- a/content/browser/media/capture/screen_capture_kit_device_mac.mm
+++ b/content/browser/media/capture/screen_capture_kit_device_mac.mm
@@ -364,6 +364,7 @@ void OnShareableContentCreated(SCShareableContent* content) {
@@ -281,6 +281,7 @@ void OnShareableContentCreated(SCShareableContent* content) {
if (!fullscreen_module_) {
fullscreen_module_ = MaybeCreateScreenCaptureKitFullscreenModule(
device_task_runner_, *this, window);
@@ -368,7 +368,7 @@ index 0e4a68f2fd8179640f877cb258b4049610fd49da..0fb8d036b7696e5303fbcd463114114a
}
}
}
@@ -728,6 +729,7 @@ void ResetStreamTo(SCWindow* window) override {
@@ -616,6 +617,7 @@ void ResetStreamTo(SCWindow* window) override {
SCContentFilter* filter) {
switch (source.type) {
case DesktopMediaID::TYPE_SCREEN:
@@ -377,7 +377,7 @@ index 0e4a68f2fd8179640f877cb258b4049610fd49da..0fb8d036b7696e5303fbcd463114114a
// It will not stitch desktops together. If
// kScreenCaptureKitFullDesktopFallback is enabled, we will fallback to
diff --git a/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc b/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc
index f0f08a834f06c7669da6030640434308a5cbd056..a34dcdbad1c3d32de59a1574de485bd831599aa1 100644
index 0ab684dc8e792359abb90b91917eddae42e6123d..2351919905fbec6c1bfe9ce59d799192a9e2e0e6 100644
--- a/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc
+++ b/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc
@@ -177,19 +177,20 @@ DesktopCaptureImplementation CreatePlatformDependentVideoCaptureDevice(
@@ -465,26 +465,30 @@ index f0f08a834f06c7669da6030640434308a5cbd056..a34dcdbad1c3d32de59a1574de485bd8
start_capture_closure =
base::BindOnce(std::move(after_start_capture_callback), nullptr);
break;
@@ -319,13 +329,18 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
#if defined(USE_AURA)
bool allow_window_id = false;
#elif BUILDFLAG(IS_MAC)
@@ -316,8 +326,21 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
break;
}
+#if defined(USE_AURA)
+ bool allow_window_id = false;
+#elif BUILDFLAG(IS_MAC)
+
bool allow_window_id =
desktop_id.id == DesktopMediaID::kMacOsNativePickerId;
+ bool allow_window_id =
+ desktop_id.id == DesktopMediaID::kMacOsNativePickerId;
+
+ LOG(ERROR) << "allow_window_id: " << allow_window_id << " desktop_id.id: " << desktop_id.id;
#endif
+#endif
+
#if defined(USE_AURA) || BUILDFLAG(IS_MAC)
- if (desktop_id.window_id != DesktopMediaID::kNullId) {
+ LOG(ERROR) << "in if block";
if (!allow_window_id &&
desktop_id.window_id != DesktopMediaID::kNullId) {
+ if (!allow_window_id &&
+ desktop_id.window_id != DesktopMediaID::kNullId) {
+ LOG(ERROR) << "allow_window_id: " << allow_window_id << " desktop_id.window_id: " << desktop_id.window_id;
// For the other capturers, when a bug reports the type of capture it's
// easy enough to determine which capturer was used, but it's a little
// fuzzier with window capture.
@@ -354,6 +369,7 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
@@ -344,6 +367,7 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
kMaxNumberOfBuffers, std::move(receiver),
std::move(receiver_on_io_thread)),
std::move(after_start_capture_callback));
@@ -492,7 +496,7 @@ index f0f08a834f06c7669da6030640434308a5cbd056..a34dcdbad1c3d32de59a1574de485bd8
break;
}
#endif // BUILDFLAG(ENABLE_SCREEN_CAPTURE)
@@ -368,6 +384,7 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
@@ -358,6 +382,7 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
// above are NOTREACHED() then.
#if BUILDFLAG(ENABLE_SCREEN_CAPTURE)
state_ = State::DEVICE_START_IN_PROGRESS;
@@ -500,7 +504,7 @@ index f0f08a834f06c7669da6030640434308a5cbd056..a34dcdbad1c3d32de59a1574de485bd8
device_task_runner_->PostTask(FROM_HERE, std::move(start_capture_closure));
#endif
}
@@ -418,9 +435,11 @@ void InProcessVideoCaptureDeviceLauncher::OnDeviceStarted(
@@ -408,9 +433,11 @@ void InProcessVideoCaptureDeviceLauncher::OnDeviceStarted(
base::OnceClosure done_cb,
std::unique_ptr<media::VideoCaptureDevice> device) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
@@ -512,7 +516,7 @@ index f0f08a834f06c7669da6030640434308a5cbd056..a34dcdbad1c3d32de59a1574de485bd8
switch (state_copy) {
case State::DEVICE_START_IN_PROGRESS:
callbacks->OnDeviceLaunchFailed(
@@ -439,13 +458,15 @@ void InProcessVideoCaptureDeviceLauncher::OnDeviceStarted(
@@ -429,13 +456,15 @@ void InProcessVideoCaptureDeviceLauncher::OnDeviceStarted(
auto launched_device = std::make_unique<InProcessLaunchedVideoCaptureDevice>(
std::move(device), device_task_runner_);
@@ -529,7 +533,7 @@ index f0f08a834f06c7669da6030640434308a5cbd056..a34dcdbad1c3d32de59a1574de485bd8
launched_device.reset();
callbacks->OnDeviceLaunchAborted();
std::move(done_cb).Run();
@@ -505,7 +526,8 @@ void InProcessVideoCaptureDeviceLauncher::DoStartDesktopCaptureOnDeviceThread(
@@ -495,7 +524,8 @@ void InProcessVideoCaptureDeviceLauncher::DoStartDesktopCaptureOnDeviceThread(
std::unique_ptr<media::VideoCaptureDeviceClient> device_client,
ReceiveDeviceCallback result_callback) {
DCHECK(device_task_runner_->BelongsToCurrentThread());
@@ -539,7 +543,7 @@ index f0f08a834f06c7669da6030640434308a5cbd056..a34dcdbad1c3d32de59a1574de485bd8
std::unique_ptr<media::VideoCaptureDevice> video_capture_device;
DesktopCaptureImplementation implementation =
@@ -514,8 +536,10 @@ void InProcessVideoCaptureDeviceLauncher::DoStartDesktopCaptureOnDeviceThread(
@@ -504,8 +534,10 @@ void InProcessVideoCaptureDeviceLauncher::DoStartDesktopCaptureOnDeviceThread(
DVLOG(1) << __func__ << " implementation " << implementation << " type "
<< desktop_id.type;
ReportDesktopCaptureImplementationAndType(implementation, desktop_id.type);

View File

@@ -0,0 +1,130 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Keeley Hammond <khammond@slack-corp.com>
Date: Tue, 15 Apr 2025 16:34:52 -0700
Subject: fix: debug desktop capturer picture
diff --git a/content/browser/media/capture/screen_capture_kit_device_mac.mm b/content/browser/media/capture/screen_capture_kit_device_mac.mm
index fef50841f472bf3e76c171d9e106c689157adaae..1e9ffc1e097439eea731e2cff6193c5f50c984d8 100644
--- a/content/browser/media/capture/screen_capture_kit_device_mac.mm
+++ b/content/browser/media/capture/screen_capture_kit_device_mac.mm
@@ -286,6 +286,25 @@ void OnShareableContentCreated(SCShareableContent* content) {
}
}
break;
+ case DesktopMediaID::TYPE_NONE:
+ for (SCWindow* window in content.windows) {
+ LOG(ERROR) << "Inside TYPE_NONE for loop";
+ LOG(ERROR) << "source_.id: " << source_.id;
+ LOG(ERROR) << "window.windowID: " << window.windowID;
+ if (source_.id == window.windowID) {
+ LOG(ERROR) << "window.windowID: " << window.windowID;
+ filter = [[SCContentFilter alloc]
+ initWithDesktopIndependentWindow:window];
+ CGRect frame = window.frame;
+ stream_config_content_size_ = gfx::Size(frame.size);
+ if (!fullscreen_module_) {
+ fullscreen_module_ = MaybeCreateScreenCaptureKitFullscreenModule(
+ device_task_runner_, *this, window);
+ break;
+ }
+ }
+ }
+ break;
default:
NOTREACHED();
}
diff --git a/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc b/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc
index 2351919905fbec6c1bfe9ce59d799192a9e2e0e6..aa97cad0ca0fecc8dfc1ee44760ab1d36086785c 100644
--- a/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc
+++ b/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc
@@ -104,6 +104,7 @@ void IncrementDesktopCaptureCounters(const DesktopMediaID& device_id) {
: SCREEN_CAPTURER_CREATED_WITHOUT_AUDIO);
break;
case DesktopMediaID::TYPE_WINDOW:
+ case DesktopMediaID::TYPE_NONE:
IncrementDesktopCaptureCounter(WINDOW_CAPTURER_CREATED);
break;
case DesktopMediaID::TYPE_WEB_CONTENTS:
@@ -112,8 +113,8 @@ void IncrementDesktopCaptureCounters(const DesktopMediaID& device_id) {
device_id.audio_share ? TAB_VIDEO_CAPTURER_CREATED_WITH_AUDIO
: TAB_VIDEO_CAPTURER_CREATED_WITHOUT_AUDIO);
break;
- case DesktopMediaID::TYPE_NONE:
- NOTREACHED();
+ // case DesktopMediaID::TYPE_NONE:
+ // NOTREACHED();
}
}
@@ -285,13 +286,15 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
const DesktopMediaID desktop_id = DesktopMediaID::Parse(device_id);
LOG(ERROR) << "desktop_id.is_null(): " << desktop_id.is_null();
LOG(ERROR) << "desktop_id.id: " << desktop_id.id;
- LOG(ERROR) << "DesktopMediaID::kMacOsNativePickerId: " << DesktopMediaID::kMacOsNativePickerId;
- if (desktop_id.is_null() && desktop_id.id != DesktopMediaID::kMacOsNativePickerId) {
- LOG(ERROR) << "in null case";
- start_capture_closure =
- base::BindOnce(std::move(after_start_capture_callback), nullptr);
- break;
- }
+ // TODO(Keeley): kMacOsNativePickerId seems to have been removed upstream.
+ // Reconcile this with the upstream changes.
+ // LOG(ERROR) << "DesktopMediaID::kMacOsNativePickerId: " << DesktopMediaID::kMacOsNativePickerId;
+ // if (desktop_id.is_null() && desktop_id.id != DesktopMediaID::kMacOsNativePickerId) {
+ // LOG(ERROR) << "in null case";
+ // start_capture_closure =
+ // base::BindOnce(std::move(after_start_capture_callback), nullptr);
+ // break;
+ // }
if (desktop_id.id == DesktopMediaID::kFakeId) {
start_capture_closure = base::BindOnce(
@@ -329,18 +332,16 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
#if defined(USE_AURA)
bool allow_window_id = false;
#elif BUILDFLAG(IS_MAC)
-
- bool allow_window_id =
- desktop_id.id == DesktopMediaID::kMacOsNativePickerId;
-
- LOG(ERROR) << "allow_window_id: " << allow_window_id << " desktop_id.id: " << desktop_id.id;
+ // bool allow_window_id =
+ // desktop_id.id == DesktopMediaID::kMacOsNativePickerId;
+ // LOG(ERROR) << "allow_window_id: " << allow_window_id << " desktop_id.id: " << desktop_id.id;
#endif
#if defined(USE_AURA) || BUILDFLAG(IS_MAC)
- LOG(ERROR) << "in if block";
- if (!allow_window_id &&
- desktop_id.window_id != DesktopMediaID::kNullId) {
- LOG(ERROR) << "allow_window_id: " << allow_window_id << " desktop_id.window_id: " << desktop_id.window_id;
+ // if (!allow_window_id &&
+ // desktop_id.window_id != DesktopMediaID::kNullId) {
+ if (desktop_id.window_id != DesktopMediaID::kNullId) {
+ // LOG(ERROR) << "allow_window_id: " << allow_window_id << " desktop_id.window_id: " << desktop_id.window_id;
// For the other capturers, when a bug reports the type of capture it's
// easy enough to determine which capturer was used, but it's a little
// fuzzier with window capture.
@@ -525,7 +526,7 @@ void InProcessVideoCaptureDeviceLauncher::DoStartDesktopCaptureOnDeviceThread(
ReceiveDeviceCallback result_callback) {
DCHECK(device_task_runner_->BelongsToCurrentThread());
LOG(INFO) << "DO START DESKTOP CAPTURE ON DEVICE THREAD " << desktop_id.id;
- DCHECK(!desktop_id.is_null() || desktop_id.id == DesktopMediaID::kMacOsNativePickerId);
+ // DCHECK(!desktop_id.is_null() || desktop_id.id == DesktopMediaID::kMacOsNativePickerId);
std::unique_ptr<media::VideoCaptureDevice> video_capture_device;
DesktopCaptureImplementation implementation =
diff --git a/content/browser/renderer_host/media/video_capture_manager.cc b/content/browser/renderer_host/media/video_capture_manager.cc
index bd11a0fcdc084da00407c80e4ee229a130fdedc8..74d9ce9facea9cda90073ca6b70e8c4be3b62f6f 100644
--- a/content/browser/renderer_host/media/video_capture_manager.cc
+++ b/content/browser/renderer_host/media/video_capture_manager.cc
@@ -920,6 +920,8 @@ void VideoCaptureManager::DestroyControllerIfNoClients(
// closed.
CloseNativeScreenCapturePicker(
DesktopMediaID::Parse(controller->device_id()));
+ LOG(ERROR) << "Closing native screen capture picker";
+ LOG(ERROR) << "VideoCaptureManager: " << string_stream.str();
// The VideoCaptureController is removed from |controllers_| immediately.
// The controller is deleted immediately, and the device is freed