Bug 192379

Summary: [MediaStream] Cleanup up Mac screen capture class
Product: WebKit Reporter: Eric Carlson <eric.carlson>
Component: WebRTCAssignee: Eric Carlson <eric.carlson>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, darin, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 192514    
Attachments:
Description Flags
Patch
none
Patch for landing. none

Description Eric Carlson 2018-12-04 14:13:42 PST
Minor cleanup.
Comment 1 Radar WebKit Bug Importer 2018-12-04 14:14:04 PST
<rdar://problem/46465458>
Comment 2 Eric Carlson 2018-12-04 14:20:50 PST
Created attachment 356532 [details]
Patch
Comment 3 youenn fablet 2018-12-04 18:44:01 PST
Comment on attachment 356532 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=356532&action=review

> Source/WebCore/ChangeLog:12
> +        (WebCore::DisplayCaptureManagerCocoa::captureDevices): Initialize Display devices first.

Maybe document why we need to do this

> Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:156
>              weakThis->frameAvailable(status, displayTime, frameSurface, updateRef);

This is existing code but the weakThis check is not thread safe here. weakThis may be dead between if and next call.

> Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:-167
> -        });

Do we need the call to frameAvailable to be in a background thread?
Comment 4 Eric Carlson 2018-12-05 11:54:22 PST
Created attachment 356632 [details]
Patch for landing.
Comment 5 WebKit Commit Bot 2018-12-05 12:22:02 PST
Comment on attachment 356632 [details]
Patch for landing.

Clearing flags on attachment: 356632

Committed r238904: <https://trac.webkit.org/changeset/238904>
Comment 6 WebKit Commit Bot 2018-12-05 12:22:04 PST
All reviewed patches have been landed.  Closing bug.
Comment 7 Darin Adler 2018-12-06 12:44:16 PST
Comment on attachment 356632 [details]
Patch for landing.

View in context: https://bugs.webkit.org/attachment.cgi?id=356632&action=review

> Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:144
> +        CFDictionaryRef streamOptions = (__bridge CFDictionaryRef) @{

Doing the cast here may be incompatible with ARC. Instead the local variable should be an NSDictionary * and the cast to CFDictionaryRef should go below at the call site. Or we can use two local variables.

> Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:148
> +            (__bridge NSString *)kCGDisplayStreamMinimumFrameTime :@(1 / frameRate()),
> +            (__bridge NSString *)kCGDisplayStreamQueueDepth:@(screenQueueMaximumLength),
> +            (__bridge NSString *)kCGDisplayStreamColorSpace:(__bridge id)sRGBColorSpaceRef(),
> +            (__bridge NSString *)kCGDisplayStreamShowCursor : @(YES),

Formatting here is a little messy, inconsistent about whether there is a space before and after the colon.
Comment 8 Eric Carlson 2018-12-07 14:04:22 PST
(In reply to Darin Adler from comment #7)
> Comment on attachment 356632 [details]
> Patch for landing.
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=356632&action=review
> 
> > Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:144
> > +        CFDictionaryRef streamOptions = (__bridge CFDictionaryRef) @{
> 
> Doing the cast here may be incompatible with ARC. Instead the local variable
> should be an NSDictionary * and the cast to CFDictionaryRef should go below
> at the call site. Or we can use two local variables.
> 
> > Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:148
> > +            (__bridge NSString *)kCGDisplayStreamMinimumFrameTime :@(1 / frameRate()),
> > +            (__bridge NSString *)kCGDisplayStreamQueueDepth:@(screenQueueMaximumLength),
> > +            (__bridge NSString *)kCGDisplayStreamColorSpace:(__bridge id)sRGBColorSpaceRef(),
> > +            (__bridge NSString *)kCGDisplayStreamShowCursor : @(YES),
> 
> Formatting here is a little messy, inconsistent about whether there is a
> space before and after the colon.

Thanks, I will fix these in bug 192514.