Bug 216415

Summary: End of media capture should not be reported before 3 seconds of the start of capture
Product: WebKit Reporter: youenn fablet <youennf>
Component: WebRTCAssignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: eric.carlson, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch for landing none

Description youenn fablet 2020-09-11 12:07:20 PDT
End of media capture should not be reported before 3 seconds of the start of capture
Comment 1 youenn fablet 2020-09-11 12:12:45 PDT
Created attachment 408554 [details]
Patch
Comment 2 youenn fablet 2020-09-14 00:32:15 PDT
Created attachment 408684 [details]
Patch
Comment 3 youenn fablet 2020-09-14 02:08:37 PDT
<rdar://problem/68512358>
Comment 4 Radar WebKit Bug Importer 2020-09-14 02:08:59 PDT
<rdar://problem/68839151>
Comment 5 Eric Carlson 2020-09-14 08:39:41 PDT
Comment on attachment 408684 [details]
Patch

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

> Source/WebKit/ChangeLog:8
> +        Add support for delaying of end of capture.

We're not delaying the end of capture, just the state transition. Also, I think it would be helpful to state why this is being changed. 

Maybe just: A capture indicator should be visible to the user for at least three seconds.

> Source/WebKit/ChangeLog:9
> +        A timer is scheduled when transitioning from no capture to capture.

s/transitioning from no capture to capture/transitioning from capture to no capture/

> Source/WebKit/UIProcess/API/C/WKPage.cpp:3004
> +void WKPageSetMediaCaptureReportingDelayForTesting(WKPageRef page, double delay)
> +{
> +    toImpl(page)->setMediaCaptureReportingDelay(Seconds(delay));
> +}

It seems a shame to add new C API

> Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:330
> +@property (nonatomic, setter=_setMediaCaptureReportingDelayForTesting:) double _mediaCaptureReportingDelayForTesting WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));

Should this go in WKWebViewPrivateForTesting.h instead?

> Source/WebKit/UIProcess/WebPageProxy.cpp:9073
> +    bool isReportingCapture = m_reportedMediaCaptureState & MediaProducer::MediaCaptureMask;

`haveReportedCapture` might be better.
Comment 6 youenn fablet 2020-09-14 08:51:03 PDT
Thanks for the review.
Will update the patch according all comments before landing.

(In reply to Eric Carlson from comment #5)
> Comment on attachment 408684 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=408684&action=review
> 
> > Source/WebKit/ChangeLog:8
> > +        Add support for delaying of end of capture.
> 
> We're not delaying the end of capture, just the state transition. Also, I
> think it would be helpful to state why this is being changed. 
> 
> Maybe just: A capture indicator should be visible to the user for at least
> three seconds.

OK

> > Source/WebKit/UIProcess/API/C/WKPage.cpp:3004
> > +void WKPageSetMediaCaptureReportingDelayForTesting(WKPageRef page, double delay)
> > +{
> > +    toImpl(page)->setMediaCaptureReportingDelay(Seconds(delay));
> > +}
> 
> It seems a shame to add new C API

Yes, I initially went ObjC.
I added this one so that other ports do not have to add their own versions to continue running some of the existing tests.

> > Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:330
> > +@property (nonatomic, setter=_setMediaCaptureReportingDelayForTesting:) double _mediaCaptureReportingDelayForTesting WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
> 
> Should this go in WKWebViewPrivateForTesting.h instead?

Did not know about it, yes!
Comment 7 youenn fablet 2020-09-15 00:58:22 PDT
Created attachment 408799 [details]
Patch for landing
Comment 8 EWS 2020-09-15 01:56:52 PDT
Committed r267081: <https://trac.webkit.org/changeset/267081>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 408799 [details].