⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 283369 in webkit


Ignore:
Timestamp:
Oct 1, 2021, 8:34:21 AM (5 years ago)
Author:
youenn@apple.com
Message:

Attribute IOSurfaces created by camera and decoders to responsible WebProcess
https://bugs.webkit.org/show_bug.cgi?id=231075

Reviewed by Chris Dumez.

Source/WebCore:

Manually tested.

  • platform/graphics/RemoteVideoSample.h:

Source/WebKit:

Make sure to mark camera and decoder generated IOSurfaces as owned by the responsible WebProcess.

  • GPUProcess/GPUConnectionToWebProcess.cpp:
  • GPUProcess/webrtc/LibWebRTCCodecsProxy.mm:
  • UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
  • UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r283367 r283369  
     12021-10-01  Youenn Fablet  <youenn@apple.com>
     2
     3        Attribute IOSurfaces created by camera and decoders to responsible WebProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=231075
     5
     6        Reviewed by Chris Dumez.
     7
     8        Manually tested.
     9
     10        * platform/graphics/RemoteVideoSample.h:
     11
    1122021-10-01  Antti Koivisto  <antti@apple.com>
    213
  • trunk/Source/WebCore/platform/graphics/RemoteVideoSample.h

    r281984 r283369  
    4848    WEBCORE_EXPORT static std::unique_ptr<RemoteVideoSample> create(RetainPtr<CVPixelBufferRef>&&, MediaTime&& presentationTime, MediaSample::VideoRotation = MediaSample::VideoRotation::None);
    4949    WEBCORE_EXPORT IOSurfaceRef surface() const;
     50
     51#if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY)
     52    void setOwnershipIdentity(task_id_token_t newOwner);
     53#endif
    5054
    5155    const MediaTime& time() const { return m_time; }
     
    116120};
    117121
     122#if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY)
     123inline void RemoteVideoSample::setOwnershipIdentity(task_id_token_t newOwner)
     124{
     125    if (m_ioSurface)
     126        m_ioSurface->setOwnershipIdentity(newOwner);
     127}
     128#endif
     129
    118130}
    119131
  • trunk/Source/WebKit/ChangeLog

    r283361 r283369  
     12021-10-01  Youenn Fablet  <youenn@apple.com>
     2
     3        Attribute IOSurfaces created by camera and decoders to responsible WebProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=231075
     5
     6        Reviewed by Chris Dumez.
     7
     8        Make sure to mark camera and decoder generated IOSurfaces as owned by the responsible WebProcess.
     9
     10        * GPUProcess/GPUConnectionToWebProcess.cpp:
     11        * GPUProcess/webrtc/LibWebRTCCodecsProxy.mm:
     12        * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
     13        * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
     14
    1152021-10-01  Carlos Garcia Campos  <cgarcia@igalia.com>
    216
  • trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp

    r281640 r283369  
    189189    }
    190190
     191#if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY)
     192    std::optional<task_id_token_t> webProcessIdentityToken() const final
     193    {
     194        return m_process.webProcessIdentityToken();
     195    }
     196#endif
     197
    191198    GPUConnectionToWebProcess& m_process;
    192199};
  • trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm

    r283036 r283369  
    7575}
    7676
     77static Function<void(CVPixelBufferRef pixelBuffer, uint32_t timeStampNs, uint32_t timeStamp)> createDecoderCallback(RTCDecoderIdentifier identifier, GPUConnectionToWebProcess& gpuConnectionToWebProcess)
     78{
     79    return [connection = Ref { gpuConnectionToWebProcess.connection() },
     80#if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY)
     81        token = gpuConnectionToWebProcess.webProcessIdentityToken(),
     82#endif
     83        identifier](CVPixelBufferRef pixelBuffer, uint32_t timeStampNs, uint32_t timeStamp) {
     84        if (auto sample = WebCore::RemoteVideoSample::create(pixelBuffer, MediaTime(timeStampNs, 1))) {
     85#if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY)
     86            sample->setOwnershipIdentity(token);
     87#endif
     88            connection->send(Messages::LibWebRTCCodecs::CompletedDecoding { identifier, timeStamp, *sample }, 0);
     89        }
     90    };
     91}
     92
    7793void LibWebRTCCodecsProxy::createH264Decoder(RTCDecoderIdentifier identifier)
    7894{
     
    8096    Locker locker { m_lock };
    8197    ASSERT(!m_decoders.contains(identifier));
    82     m_decoders.add(identifier, webrtc::createLocalH264Decoder(makeBlockPtr([connection = Ref { m_gpuConnectionToWebProcess.connection() }, identifier](CVPixelBufferRef pixelBuffer, uint32_t timeStampNs, uint32_t timeStamp) {
    83         if (auto sample = WebCore::RemoteVideoSample::create(pixelBuffer, MediaTime(timeStampNs, 1)))
    84             connection->send(Messages::LibWebRTCCodecs::CompletedDecoding { identifier, timeStamp, *sample }, 0);
    85     }).get()));
     98    m_decoders.add(identifier, webrtc::createLocalH264Decoder(makeBlockPtr(createDecoderCallback(identifier, m_gpuConnectionToWebProcess)).get()));
    8699}
    87100
     
    91104    Locker locker { m_lock };
    92105    ASSERT(!m_decoders.contains(identifier));
    93     m_decoders.add(identifier, webrtc::createLocalH265Decoder(makeBlockPtr([connection = Ref { m_gpuConnectionToWebProcess.connection() }, identifier](CVPixelBufferRef pixelBuffer, uint32_t timeStampNs, uint32_t timeStamp) {
    94         if (auto sample = WebCore::RemoteVideoSample::create(pixelBuffer, MediaTime(timeStampNs, 1)))
    95             connection->send(Messages::LibWebRTCCodecs::CompletedDecoding { identifier, timeStamp, *sample }, 0);
    96     }).get()));
     106    m_decoders.add(identifier, webrtc::createLocalH265Decoder(makeBlockPtr(createDecoderCallback(identifier, m_gpuConnectionToWebProcess)).get()));
    97107}
    98108
     
    102112    Locker locker { m_lock };
    103113    ASSERT(!m_decoders.contains(identifier));
    104     m_decoders.add(identifier, webrtc::createLocalVP9Decoder(makeBlockPtr([connection = Ref { m_gpuConnectionToWebProcess.connection() }, identifier](CVPixelBufferRef pixelBuffer, uint32_t timeStampNs, uint32_t timeStamp) {
    105         if (auto sample = WebCore::RemoteVideoSample::create(pixelBuffer, MediaTime(timeStampNs, 1)))
    106             connection->send(Messages::LibWebRTCCodecs::CompletedDecoding { identifier, timeStamp, *sample }, 0);
    107     }).get()));
     114    m_decoders.add(identifier, webrtc::createLocalVP9Decoder(makeBlockPtr(createDecoderCallback(identifier, m_gpuConnectionToWebProcess)).get()));
    108115}
    109116
  • trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp

    r280722 r283369  
    126126
    127127    void setShouldApplyRotation(bool shouldApplyRotation) { m_shouldApplyRotation = true; }
     128#if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY)
     129    void setWebProcessIdentityToken(std::optional<task_id_token_t> token) { m_webProcessIdentityToken = token;}
     130#endif
    128131
    129132private:
     
    185188        } else
    186189            remoteSample = RemoteVideoSample::create(sample);
    187         if (remoteSample)
     190        if (remoteSample) {
     191#if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY)
     192            if (m_webProcessIdentityToken)
     193                remoteSample->setOwnershipIdentity(*m_webProcessIdentityToken);
     194#endif
    188195            m_connection->send(Messages::RemoteCaptureSampleManager::VideoSampleAvailable(m_id, WTFMove(*remoteSample)), 0);
     196        }
    189197    }
    190198
     
    250258    MediaTime m_startTime;
    251259    bool m_shouldReset { false };
     260#if HAVE(TASK_IDENTITY_TOKEN)
     261    std::optional<task_id_token_t> m_webProcessIdentityToken;
     262#endif
    252263};
    253264
     
    313324
    314325        ASSERT(!m_proxies.contains(id));
    315         m_proxies.add(id, makeUnique<SourceProxy>(id, m_connectionProxy->connection(), WTFMove(source)));
     326        auto proxy = makeUnique<SourceProxy>(id, m_connectionProxy->connection(), WTFMove(source));
     327#if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY)
     328        if (device.type() != WebCore::CaptureDevice::DeviceType::Microphone)
     329            proxy->setWebProcessIdentityToken(m_connectionProxy->webProcessIdentityToken());
     330#endif
     331
     332        m_proxies.add(id, WTFMove(proxy));
    316333    } else
    317334        invalidConstraints = WTFMove(sourceOrError.errorMessage);
    318 
    319335
    320336    completionHandler(succeeded, invalidConstraints, WTFMove(settings), WTFMove(capabilities), WTFMove(presets), size, frameRate);
  • trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h

    r279912 r283369  
    5959        virtual Logger& logger() = 0;
    6060        virtual bool setCaptureAttributionString() { return true; }
     61#if HAVE(IOSURFACE_SET_OWNERSHIP_IDENTITY)
     62        virtual std::optional<task_id_token_t> webProcessIdentityToken() const { return { }; };
     63#endif
    6164    };
    6265    explicit UserMediaCaptureManagerProxy(UniqueRef<ConnectionProxy>&&);
Note: See TracChangeset for help on using the changeset viewer.