RESOLVED FIXED 189958
[MediaStream] Add Mac window capture source
https://bugs.webkit.org/show_bug.cgi?id=189958
Summary [MediaStream] Add Mac window capture source
Eric Carlson
Reported 2018-09-25 11:24:09 PDT
Add Mac window capture source
Attachments
Patch (41.42 KB, patch)
2018-09-25 11:48 PDT, Eric Carlson
ews-watchlist: commit-queue-
Patch for landing (41.73 KB, patch)
2018-09-25 18:11 PDT, Eric Carlson
no flags
Archive of layout-test-results from ews122 for ios-simulator-wk2 (2.32 MB, application/zip)
2018-09-25 18:47 PDT, EWS Watchlist
no flags
Radar WebKit Bug Importer
Comment 1 2018-09-25 11:24:30 PDT
Eric Carlson
Comment 2 2018-09-25 11:48:34 PDT
youenn fablet
Comment 3 2018-09-25 15:03:03 PDT
Comment on attachment 350774 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=350774&action=review > Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp:176 > + if (m_lastSampleBuffer && m_lastFullSizedPixelBuffer && CFEqual(m_lastFullSizedPixelBuffer.get(), pixelBuffer.get())) { If we set intrinsic size, we will not reuse m_lastSampleBuffer since it will be nullified. Can we be in a case where m_initrinsicSize is not changed but this->size() is so that we should not reuse m_lastSampleBuffer? > Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp:193 > + if (m_pixelBufferResizer) No need for this if check > Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp:209 > + if (m_pixelBufferConformer) No need for this if check > Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:129 > + RetainPtr<CGDisplayModeRef> displayMode = adoptCF(CGDisplayCopyDisplayMode(m_displayID)); s/RetainPtr<CGDisplayModeRef>/auto ? > Source/WebCore/platform/mediastream/mac/WindowDisplayCaptureSourceMac.h:33 > +#include <wtf/Lock.h> We probably do not need all these includes, lock does not seem used, DisplayCaptureSourceCocoa.h seems used. PixelBufferConformerCV could be forward declared . > Source/WebCore/platform/mediastream/mac/WindowDisplayCaptureSourceMac.h:46 > + WindowDisplayCaptureSourceMac(uint32_t, String&&); Add name for uint32_t? Maybe make the constructor private since there are static methods. > Source/WebCore/platform/mediastream/mac/WindowDisplayCaptureSourceMac.h:49 > + static void windowCaptureDevices(Vector<CaptureDevice>&); Might be easier to have something like Vector<CaptureDevice> windowCaptureDevices()? > Source/WebCore/platform/mediastream/mac/WindowDisplayCaptureSourceMac.h:58 > + RetainPtr<CGImageRef> windowImage(bool); bool is not easy to understand, maybe add the name here, use an enum or rename windowImage to windowImageWithResize? > Source/WebCore/platform/mediastream/mac/WindowDisplayCaptureSourceMac.mm:58 > + CFIndex windowCount = CFArrayGetCount(windows.get()); s/CFIndex/auto/ > Source/WebCore/platform/mediastream/mac/WindowDisplayCaptureSourceMac.mm:59 > + for (CFIndex i = 0; i < windowCount; i++) { Ditto here. > Source/WebCore/platform/mediastream/mac/WindowDisplayCaptureSourceMac.mm:155 > + m_lastImage = image; WTFMove() and use m_lastImage below, or maybe do not make m_lastImage not retained pointer? It also seems like we are storing m_lastImage, m_lastFullSizedPixelBuffer and m_lastSampleBuffer for the same reason of optimizing. Maybe there could be a simpler way? > Source/WebCore/platform/mediastream/mac/WindowDisplayCaptureSourceMac.mm:188 > + CVReturn status = CVPixelBufferPoolCreate(kCFAllocatorDefault, pixelBufferPoolOptions, sourcePixelBufferOptions, &bufferPool); Maybe we should have a routine helper here that would take width, height and format type and return a RetainPtr<CVPixelBufferPoolRef>.
Eric Carlson
Comment 4 2018-09-25 17:22:58 PDT
Comment on attachment 350774 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=350774&action=review >> Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp:176 >> + if (m_lastSampleBuffer && m_lastFullSizedPixelBuffer && CFEqual(m_lastFullSizedPixelBuffer.get(), pixelBuffer.get())) { > > If we set intrinsic size, we will not reuse m_lastSampleBuffer since it will be nullified. > Can we be in a case where m_initrinsicSize is not changed but this->size() is so that we should not reuse m_lastSampleBuffer? m_lastSampleBuffer is also nullified in settingsDidChange, which is called when size changes. >> Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp:193 >> + if (m_pixelBufferResizer) > > No need for this if check Fixed. >> Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp:209 >> + if (m_pixelBufferConformer) > > No need for this if check OK >> Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:129 >> + RetainPtr<CGDisplayModeRef> displayMode = adoptCF(CGDisplayCopyDisplayMode(m_displayID)); > > s/RetainPtr<CGDisplayModeRef>/auto ? Fixed. >> Source/WebCore/platform/mediastream/mac/WindowDisplayCaptureSourceMac.h:33 >> +#include <wtf/Lock.h> > > We probably do not need all these includes, lock does not seem used, DisplayCaptureSourceCocoa.h seems used. > PixelBufferConformerCV could be forward declared . Fixed. >> Source/WebCore/platform/mediastream/mac/WindowDisplayCaptureSourceMac.h:46 >> + WindowDisplayCaptureSourceMac(uint32_t, String&&); > > Add name for uint32_t? > Maybe make the constructor private since there are static methods. Fixed. >> Source/WebCore/platform/mediastream/mac/WindowDisplayCaptureSourceMac.h:49 >> + static void windowCaptureDevices(Vector<CaptureDevice>&); > > Might be easier to have something like Vector<CaptureDevice> windowCaptureDevices()? It would look better, but they we will need to copy the vector it returns when building the list of window and screen "devices". >> Source/WebCore/platform/mediastream/mac/WindowDisplayCaptureSourceMac.h:58 >> + RetainPtr<CGImageRef> windowImage(bool); > > bool is not easy to understand, maybe add the name here, use an enum or rename windowImage to windowImageWithResize? We don't need the option yet, so I just removed it. >> Source/WebCore/platform/mediastream/mac/WindowDisplayCaptureSourceMac.mm:58 >> + CFIndex windowCount = CFArrayGetCount(windows.get()); > > s/CFIndex/auto/ Fixed. >> Source/WebCore/platform/mediastream/mac/WindowDisplayCaptureSourceMac.mm:59 >> + for (CFIndex i = 0; i < windowCount; i++) { > > Ditto here. Ditto. >> Source/WebCore/platform/mediastream/mac/WindowDisplayCaptureSourceMac.mm:155 >> + m_lastImage = image; > > WTFMove() and use m_lastImage below, or maybe do not make m_lastImage not retained pointer? > It also seems like we are storing m_lastImage, m_lastFullSizedPixelBuffer and m_lastSampleBuffer for the same reason of optimizing. > Maybe there could be a simpler way? m_lastImage is a CGImage, which is a retain counted object so we need a retain pointer for it. >> Source/WebCore/platform/mediastream/mac/WindowDisplayCaptureSourceMac.mm:188 >> + CVReturn status = CVPixelBufferPoolCreate(kCFAllocatorDefault, pixelBufferPoolOptions, sourcePixelBufferOptions, &bufferPool); > > Maybe we should have a routine helper here that would take width, height and format type and return a RetainPtr<CVPixelBufferPoolRef>. Good idea, we do this in a number of places. I will do this in a follow up patch.
Eric Carlson
Comment 5 2018-09-25 18:11:10 PDT
Created attachment 350823 [details] Patch for landing
EWS Watchlist
Comment 6 2018-09-25 18:47:35 PDT
Comment on attachment 350774 [details] Patch Attachment 350774 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: https://webkit-queues.webkit.org/results/9350472 New failing tests: fast/frames/lots-of-objects.html imported/w3c/web-platform-tests/dom/nodes/Document-characterSet-normalization.html
EWS Watchlist
Comment 7 2018-09-25 18:47:37 PDT
Created attachment 350827 [details] Archive of layout-test-results from ews122 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews122 Port: ios-simulator-wk2 Platform: Mac OS X 10.13.6
Eric Carlson
Comment 8 2018-09-25 19:06:30 PDT
(In reply to Build Bot from comment #6) > Comment on attachment 350774 [details] > Patch > > Attachment 350774 [details] did not pass ios-sim-ews (ios-simulator-wk2): > Output: https://webkit-queues.webkit.org/results/9350472 > > New failing tests: > fast/frames/lots-of-objects.html > imported/w3c/web-platform-tests/dom/nodes/Document-characterSet- > normalization.html This failure is unrelated to the changes in this patch.
WebKit Commit Bot
Comment 9 2018-09-25 19:33:10 PDT
Comment on attachment 350823 [details] Patch for landing Clearing flags on attachment: 350823 Committed r236494: <https://trac.webkit.org/changeset/236494>
Note You need to log in before you can comment on or make changes to this bug.