Bug 206929 - Make sure MediaRecorder.requestData returns data with the new writer backend
Summary: Make sure MediaRecorder.requestData returns data with the new writer backend
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
: 212275 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-01-29 07:15 PST by youenn fablet
Modified: 2020-06-16 10:02 PDT (History)
10 users (show)

See Also:


Attachments
Patch (6.35 KB, patch)
2020-01-29 07:20 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Adding deprecation macros (6.49 KB, patch)
2020-06-15 02:29 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (6.67 KB, patch)
2020-06-16 01:02 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2020-01-29 07:15:36 PST
Make sure MediaRecorder.requestData returns data with the new writer backend
Comment 1 youenn fablet 2020-01-29 07:20:22 PST
Created attachment 389134 [details]
Patch
Comment 2 youenn fablet 2020-06-15 02:02:37 PDT
*** Bug 212275 has been marked as a duplicate of this bug. ***
Comment 3 youenn fablet 2020-06-15 02:03:01 PDT
<rdar://problem/63601261>
Comment 4 youenn fablet 2020-06-15 02:29:00 PDT
Created attachment 401889 [details]
Adding deprecation macros
Comment 5 Darin Adler 2020-06-15 08:38:19 PDT
Comment on attachment 401889 [details]
Adding deprecation macros

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

> Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:489
> +            ALLOW_DEPRECATED_DECLARATIONS_BEGIN
> +            [m_writer flush];
> +            ALLOW_DEPRECATED_DECLARATIONS_END

Do we have to write code using a deprecated function? What’s the long term strategy for the deprecation? Why can’t we take advantage of it now?

> Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:496
> +                RefPtr<SharedBuffer> buffer;
> +                if (weakThis)
> +                    buffer = WTFMove(m_data);
> +
> +                completionHandler(WTFMove(buffer));

How about this version?

    if (!weakThis)
        return completionHandler({ });

    completionHandler(WTFMove(m_data));

Seems easier to read than the one with the local variable and double WTFMove? And has the same early exit here as above. I probably would have written it with nullptr and without using a "void return", but I figured we could stay consistent.
Comment 6 youenn fablet 2020-06-16 00:27:14 PDT
(In reply to Darin Adler from comment #5)
> Comment on attachment 401889 [details]
> Adding deprecation macros
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=401889&action=review
> 
> > Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:489
> > +            ALLOW_DEPRECATED_DECLARATIONS_BEGIN
> > +            [m_writer flush];
> > +            ALLOW_DEPRECATED_DECLARATIONS_END
> 
> Do we have to write code using a deprecated function? What’s the long term
> strategy for the deprecation? Why can’t we take advantage of it now?

The replacement method is not available yet everywhere.
Plan is to switch at some point.

> > Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:496
> > +                RefPtr<SharedBuffer> buffer;
> > +                if (weakThis)
> > +                    buffer = WTFMove(m_data);
> > +
> > +                completionHandler(WTFMove(buffer));
> 
> How about this version?
> 
>     if (!weakThis)
>         return completionHandler({ });
> 
>     completionHandler(WTFMove(m_data));
> 
> Seems easier to read than the one with the local variable and double
> WTFMove? And has the same early exit here as above. I probably would have
> written it with nullptr and without using a "void return", but I figured we
> could stay consistent.

I wrote the double move to ensure m_data gets cleared.
I'll do the early return.
Comment 7 youenn fablet 2020-06-16 01:02:12 PDT
Created attachment 401986 [details]
Patch for landing
Comment 8 youenn fablet 2020-06-16 01:03:30 PDT
Went with sd::exchange
Comment 9 EWS 2020-06-16 02:18:13 PDT
Committed r263084: <https://trac.webkit.org/changeset/263084>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 401986 [details].
Comment 10 Darin Adler 2020-06-16 09:25:10 PDT
Comment on attachment 401889 [details]
Adding deprecation macros

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

>>> Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:496
>>> +                completionHandler(WTFMove(buffer));
>> 
>> How about this version?
>> 
>>     if (!weakThis)
>>         return completionHandler({ });
>> 
>>     completionHandler(WTFMove(m_data));
>> 
>> Seems easier to read than the one with the local variable and double WTFMove? And has the same early exit here as above. I probably would have written it with nullptr and without using a "void return", but I figured we could stay consistent.
> 
> I wrote the double move to ensure m_data gets cleared.
> I'll do the early return.

If you want to ensure m_data gets cleared, then we should write std::exchange(m_data, {}) instead of WTFMove(m_data).
Comment 11 youenn fablet 2020-06-16 10:02:57 PDT
(In reply to Darin Adler from comment #10)
> Comment on attachment 401889 [details]
> Adding deprecation macros
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=401889&action=review
> 
> >>> Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:496
> >>> +                completionHandler(WTFMove(buffer));
> >> 
> >> How about this version?
> >> 
> >>     if (!weakThis)
> >>         return completionHandler({ });
> >> 
> >>     completionHandler(WTFMove(m_data));
> >> 
> >> Seems easier to read than the one with the local variable and double WTFMove? And has the same early exit here as above. I probably would have written it with nullptr and without using a "void return", but I figured we could stay consistent.
> > 
> > I wrote the double move to ensure m_data gets cleared.
> > I'll do the early return.
> 
> If you want to ensure m_data gets cleared, then we should write
> std::exchange(m_data, {}) instead of WTFMove(m_data).

Yes, that is what I ended up landing.