Repository navigation
refactor: desktop capturer module - #14835
Conversation
|
/cc @ilya-edrenkin this PR removes the patch created in electron/libchromiumcontent#418 , would like your review. Thanks! |
834a227 to
f7aebca
Compare
|
|
||
| // Initialize the source list. | ||
| if (source_lists_.empty()) { | ||
| std::vector<content::DesktopMediaID::Type> media_types = { |
| if (source_lists_.empty()) { | ||
| std::vector<content::DesktopMediaID::Type> media_types = { | ||
| content::DesktopMediaID::TYPE_SCREEN, | ||
| content::DesktopMediaID::TYPE_WINDOW}; |
There was a problem hiding this comment.
This seems to add overhead of forever owning and tracking an instance for screen tracking and an instance for window tracking even if the user is only tracking one of them.=
Is this intentional / desirable?
edit: OK after reading further it looks intentional since MediaCaptureDevicesDispatcher::CreateMediaList() can only be successfully called once, so this object must hold onto its pointers forever.
I am still learning context to the capture code so maybe there are reasons for this that I don't see, but this seems like an unintuitive API contact.
| int new_index) = 0; | ||
| virtual void OnSourceNameChanged(DesktopMediaList* list, int index) = 0; | ||
| virtual void OnSourceThumbnailChanged(DesktopMediaList* list, int index) = 0; | ||
| + virtual bool OnRefreshFinished(DesktopMediaList* list) = 0; |
There was a problem hiding this comment.
This could use a one-liner comment explaining what the bool retval signifies
| std::vector<std::unique_ptr<DesktopMediaList>> | ||
| MediaCaptureDevicesDispatcher::CreateMediaList( | ||
| const std::vector<content::DesktopMediaID::Type>& types) { | ||
| // Keep same order as the input |sources| and avoid duplicates. |
| std::unique_ptr<DesktopMediaList> screen_list = | ||
| std::make_unique<NativeDesktopMediaList>( | ||
| content::DesktopMediaID::TYPE_SCREEN, | ||
| std::move(screen_capturer_)); |
There was a problem hiding this comment.
Not sure that I understand this: MediaCaptureDevicesDispatcher is a singleton that gives up its screen_capturer_ unique ptr here. So CreateMediaList() can only be called successfully once?
If this is what we intend to ship, we should document it in a comment, or have the function throw if (!screen_capturer_) or something to signpost the expectations we have for the API.
| MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher() | ||
| : is_device_enumeration_disabled_(false) { | ||
| : screen_capturer_(content::desktop_capture::CreateScreenCapturer()), | ||
| window_capturer_(content::desktop_capture::CreateWindowCapturer()), |
There was a problem hiding this comment.
base::Singleton lazy-instantiates the MCDD, is that correct?
So we're not instantiating these capturers in every Electron instance whether the client asks for them or not?
|
FWIW the specs are passing for me locally: $ uname -om
x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
$ eltest debug --ci -g desktopCapturer
starting dbus @ /tmp/electron.dbusmock.wsVvUDKcfl
starting /home/charles/electron/electron-gn/src/out/debug/electron
1..6
ok 1 desktopCapturer should return a non-empty array of sources
ok 2 desktopCapturer throws an error for invalid options
ok 3 desktopCapturer does not throw an error when called more than once (regression)
ok 4 desktopCapturer responds to subsequent calls of different options
ok 5 desktopCapturer returns an empty display_id for window sources on Windows and Mac
ok 6 desktopCapturer returns display_ids matching the Screen API on Windows and Mac
# tests 6
# pass 6
# fail 0 |
32aebbd to
139dec4
Compare
ckerr
left a comment
There was a problem hiding this comment.
Obviously CI needs to go green before merging, but the changes so far LGTM
9a6d95c to
93a3d65
Compare
| } | ||
|
|
||
| void DesktopCapturer::OnSourceThumbnailChanged(int index) {} | ||
| if (!capture_window_ && !capture_screen_) |
There was a problem hiding this comment.
When a machine does not have any screen or window, no event would be emitted, this leads to the timeout of tests since the results is empty on CI machines.
There was a problem hiding this comment.
Removing this check still has a failing "responds to subsequent calls of different options" test in Linux CI, because desktopCapturer.getSources({ types: ['window'] }, callback) is not returning any result.
From the comments of other tests this test should probably just be disabled on Linux?
There was a problem hiding this comment.
When a machine does not have any screen or window, no event would be emitted
Ah, missed that!
Removing this check still has a failing "responds to subsequent calls of different options" test in Linux CI,
Before this PR, the refresh method was called irrespective of whether sources were captured https://github.com/electron/electron/blob/master/chromium_src/chrome/browser/media/native_desktop_media_list.cc#L209, the upstream implementation only tries to schedule a new refresh when atleast one source is captured https://cs.chromium.org/chromium/src/chrome/browser/media/webrtc/native_desktop_media_list.cc?sq=package:chromium&g=0&l=312, hence this method would never be called. I am thinking of emitting a new observer event when the source list empty from DesktopMediaListbase::UpdateSourceList which would allow us handle this scenario, we can't move the refresh call outside the existing check because it would preemptively block thumbnail captures for aura windows.
This reverts commit 5a28759.
* Creates the screen and window capturer for the liftime of the app * Fixes incorrect usage of weak ptr
93a3d65 to
00db215
Compare
00db215 to
1711010
Compare
|
@zcbenz the specs pass now. Thanks! |
|
The failed macOS tests are not related to this PR, I'm merging this with them ignored. |
|
No Release Notes |
Description of Change
hence the workaround of creating it on a separate thread which was causing incorrect usage of weak ptr as seen in #14816
Checklist
npm testpassesRelease Notes
Notes: no-notes