Bug 235951 - LibWebRTCCodecs should not need to create IOSurfaces
Summary: LibWebRTCCodecs should not need to create IOSurfaces
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
Depends on:
Blocks: 235952 235953 235954
  Show dependency treegraph
 
Reported: 2022-02-01 07:20 PST by youenn fablet
Modified: 2022-02-02 05:22 PST (History)
11 users (show)

See Also:


Attachments
Patch (65.48 KB, patch)
2022-02-01 08:04 PST, youenn fablet
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (69.00 KB, patch)
2022-02-01 08:53 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (69.13 KB, patch)
2022-02-01 09:20 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (69.13 KB, patch)
2022-02-01 23:28 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (69.23 KB, patch)
2022-02-02 02:23 PST, 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 2022-02-01 07:20:04 PST
LibWebRTCCodecs should not need to create IOSurfaces
Comment 1 Radar WebKit Bug Importer 2022-02-01 07:20:52 PST
<rdar://problem/88326654>
Comment 2 youenn fablet 2022-02-01 08:04:41 PST
Created attachment 450528 [details]
Patch
Comment 3 youenn fablet 2022-02-01 08:53:34 PST
Created attachment 450535 [details]
Patch
Comment 4 Eric Carlson 2022-02-01 09:13:55 PST
Comment on attachment 450528 [details]
Patch

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

> Source/ThirdParty/libwebrtc/ChangeLog:9
> +        Introduce helper routines to copy a webrtc VideoFrame in a bufer and get a CVPixelBuffer from a webrtc VideoFrame.

s/bufer/buffer/

> Source/WebCore/platform/cocoa/SharedVideoFrameInfo.mm:187
> +    if (CVPixelBufferGetWidthOfPlane(rawPixelBuffer, 1) != m_widthPlaneB || CVPixelBufferGetHeightOfPlane(rawPixelBuffer, 1) != m_heightPlaneB)

This leaves the buffer base address locked. Maybe use `makeScopeExit` to unlock instead?
Comment 5 youenn fablet 2022-02-01 09:20:33 PST
Created attachment 450539 [details]
Patch
Comment 6 youenn fablet 2022-02-01 09:22:16 PST
(In reply to Eric Carlson from comment #4)
> Comment on attachment 450528 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=450528&action=review
> 
> > Source/ThirdParty/libwebrtc/ChangeLog:9
> > +        Introduce helper routines to copy a webrtc VideoFrame in a bufer and get a CVPixelBuffer from a webrtc VideoFrame.
> 
> s/bufer/buffer/

Fixed

> > Source/WebCore/platform/cocoa/SharedVideoFrameInfo.mm:187
> > +    if (CVPixelBufferGetWidthOfPlane(rawPixelBuffer, 1) != m_widthPlaneB || CVPixelBufferGetHeightOfPlane(rawPixelBuffer, 1) != m_heightPlaneB)
> 
> This leaves the buffer base address locked. Maybe use `makeScopeExit` to
> unlock instead?

Right, fixed!
Comment 7 Eric Carlson 2022-02-01 12:13:51 PST
Comment on attachment 450539 [details]
Patch

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

> Source/ThirdParty/libwebrtc/ChangeLog:9
> +        Introduce helper routines to copy a webrtc VideoFrame in a memory buffer and get a CVPixelBuffer from a webrtc VideoFrame.

s/in a memory buffer/into a memory buffer/

> Source/WebCore/platform/cocoa/SharedVideoFrameInfo.h:79
> +

Nit: extra blank line.

> Source/WebCore/platform/cocoa/SharedVideoFrameInfo.mm:210
> +    CVPixelBufferUnlockBaseAddress(rawPixelBuffer, 0);

This is unnecessary.

> Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm:70
>          for (auto decoder : decoders.values())

`auto&`?

> Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.cpp:71
> +    if (!m_storage || m_storage->size() < size) {

Should we also reallocate if m_storage is (significantly?) larger than needed?

> Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.cpp:135
> +

Nit: extra blank

> Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.h:96
> +

Ditto
Comment 8 youenn fablet 2022-02-01 23:26:08 PST
> > Source/WebCore/platform/cocoa/SharedVideoFrameInfo.mm:210
> > +    CVPixelBufferUnlockBaseAddress(rawPixelBuffer, 0);
> 
> This is unnecessary.

OK

> > Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm:70
> >          for (auto decoder : decoders.values())
> 
> `auto&`?

decoder is a pointer so auto is fine here.

> > Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.cpp:71
> > +    if (!m_storage || m_storage->size() < size) {
> 
> Should we also reallocate if m_storage is (significantly?) larger than
> needed?

Good question. I guess we should consider it.
What would be a reasonable heuristic?
Comment 9 youenn fablet 2022-02-01 23:28:06 PST
Created attachment 450616 [details]
Patch for landing
Comment 10 youenn fablet 2022-02-02 02:23:57 PST
Created attachment 450628 [details]
Patch for landing
Comment 11 EWS 2022-02-02 05:22:11 PST
Committed r288951 (246680@main): <https://commits.webkit.org/246680@main>

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