Changeset 282444 in webkit
- Timestamp:
- Sep 15, 2021, 1:19:01 AM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 9 edited
-
ThirdParty/libwebrtc/ChangeLog (modified) (1 diff)
-
ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp (modified) (1 diff)
-
ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp (modified) (1 diff)
-
ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp (modified) (1 diff)
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp (modified) (5 diffs)
-
WebCore/Modules/mediastream/libwebrtc/LibWebRTCObservers.h (modified) (3 diffs)
-
WebCore/testing/MockLibWebRTCPeerConnection.cpp (modified) (4 diffs)
-
WebCore/testing/MockLibWebRTCPeerConnection.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/ThirdParty/libwebrtc/ChangeLog
r282197 r282444 1 2021-09-15 Youenn Fablet <youenn@apple.com> 2 3 Migrate to libwebrtc non-racy setRemoteDescription/setLocalDescription variants 4 https://bugs.webkit.org/show_bug.cgi?id=230262 5 6 Reviewed by Darin Adler. 7 8 * Configurations/libwebrtc.iOS.exp: 9 * Configurations/libwebrtc.iOSsim.exp: 10 * Configurations/libwebrtc.mac.exp: 11 1 12 2021-09-09 Youenn Fablet <youenn@apple.com> 2 13 -
trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp
r282197 r282444 26 26 __ZN6webrtc19RTCCertificateStats5kTypeE 27 27 __ZN6webrtc19RTCDataChannelStats5kTypeE 28 __ZN6webrtc24CreateSessionDescriptionE RKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES8_PNS_13SdpParseErrorE28 __ZN6webrtc24CreateSessionDescriptionENS_7SdpTypeERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEPNS_13SdpParseErrorE 29 29 __ZN6webrtc24RTCIceCandidatePairStats5kTypeE 30 30 __ZN6webrtc24RTCInboundRTPStreamStats5kTypeE -
trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp
r282197 r282444 26 26 __ZN6webrtc19RTCCertificateStats5kTypeE 27 27 __ZN6webrtc19RTCDataChannelStats5kTypeE 28 __ZN6webrtc24CreateSessionDescriptionE RKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES8_PNS_13SdpParseErrorE28 __ZN6webrtc24CreateSessionDescriptionENS_7SdpTypeERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEPNS_13SdpParseErrorE 29 29 __ZN6webrtc24RTCIceCandidatePairStats5kTypeE 30 30 __ZN6webrtc24RTCInboundRTPStreamStats5kTypeE -
trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp
r282197 r282444 26 26 __ZN6webrtc19RTCCertificateStats5kTypeE 27 27 __ZN6webrtc19RTCDataChannelStats5kTypeE 28 __ZN6webrtc24CreateSessionDescriptionE RKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES8_PNS_13SdpParseErrorE28 __ZN6webrtc24CreateSessionDescriptionENS_7SdpTypeERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEPNS_13SdpParseErrorE 29 29 __ZN6webrtc24RTCIceCandidatePairStats5kTypeE 30 30 __ZN6webrtc24RTCInboundRTPStreamStats5kTypeE -
trunk/Source/WebCore/ChangeLog
r282443 r282444 1 2021-09-15 Youenn Fablet <youenn@apple.com> 2 3 Migrate to libwebrtc non-racy setRemoteDescription/setLocalDescription variants 4 https://bugs.webkit.org/show_bug.cgi?id=230262 5 6 Reviewed by Darin Adler. 7 8 We were using the old versions of libwebrtc SetLocalDescription/SetRemoteDescription. 9 As per the header file, these versions are potentially racy. 10 This patch migrates to new versions of the same API which in addition take more modern parameters instead of raw pointers. 11 We also modernize a bit the code by using methods manipulating unique_ptr instead of raw pointers. 12 Drive-by fix: Add support for getting back to new for ICE gathering state. This was missing and without it, 13 imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-explicit-rollback-iceGatheringState.html would time out. 14 Update mock to implement the new method versions. 15 16 Covered by existing tests. 17 18 * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp: 19 (WebCore::sessionDescriptionType): 20 (WebCore::LibWebRTCMediaEndpoint::doSetLocalDescription): 21 (WebCore::LibWebRTCMediaEndpoint::doSetRemoteDescription): 22 (WebCore::LibWebRTCMediaEndpoint::OnIceGatheringChange): 23 * Modules/mediastream/libwebrtc/LibWebRTCObservers.h: 24 * testing/MockLibWebRTCPeerConnection.cpp: 25 (WebCore::MockLibWebRTCPeerConnection::SetLocalDescription): 26 (WebCore::MockLibWebRTCPeerConnection::SetRemoteDescription): 27 * testing/MockLibWebRTCPeerConnection.h: 28 1 29 2021-09-15 Said Abou-Hallawa <said@apple.com> 2 30 -
trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp
r282362 r282444 128 128 } 129 129 130 static inline const char*sessionDescriptionType(RTCSdpType sdpType)130 static inline webrtc::SdpType sessionDescriptionType(RTCSdpType sdpType) 131 131 { 132 132 switch (sdpType) { 133 133 case RTCSdpType::Offer: 134 return "offer";134 return webrtc::SdpType::kOffer; 135 135 case RTCSdpType::Pranswer: 136 return "pranswer";136 return webrtc::SdpType::kPrAnswer; 137 137 case RTCSdpType::Answer: 138 return "answer";138 return webrtc::SdpType::kAnswer; 139 139 case RTCSdpType::Rollback: 140 return "rollback"; 141 } 142 143 ASSERT_NOT_REACHED(); 144 return ""; 140 return webrtc::SdpType::kRollback; 141 } 145 142 } 146 143 … … 155 152 156 153 webrtc::SdpParseError error; 157 std::unique_ptr<webrtc::SessionDescriptionInterface> sessionDescription(webrtc::CreateSessionDescription(sessionDescriptionType(description->type()), description->sdp().utf8().data(), &error));154 auto sessionDescription = webrtc::CreateSessionDescription(sessionDescriptionType(description->type()), description->sdp().utf8().data(), &error); 158 155 159 156 if (!sessionDescription) { … … 168 165 } 169 166 170 m_backend->SetLocalDescription( &m_setLocalSessionDescriptionObserver, sessionDescription.release());167 m_backend->SetLocalDescription(WTFMove(sessionDescription), &m_setLocalSessionDescriptionObserver); 171 168 } 172 169 … … 176 173 177 174 webrtc::SdpParseError error; 178 std::unique_ptr<webrtc::SessionDescriptionInterface> sessionDescription(webrtc::CreateSessionDescription(sessionDescriptionType(description.type()), description.sdp().utf8().data(), &error));175 auto sessionDescription = webrtc::CreateSessionDescription(sessionDescriptionType(description.type()), description.sdp().utf8().data(), &error); 179 176 if (!sessionDescription) { 180 177 m_peerConnectionBackend.setRemoteDescriptionFailed(Exception { SyntaxError, fromStdString(error.description) }); 181 178 return; 182 179 } 183 m_backend->SetRemoteDescription(&m_setRemoteSessionDescriptionObserver, sessionDescription.release()); 180 181 m_backend->SetRemoteDescription(WTFMove(sessionDescription), &m_setRemoteSessionDescriptionObserver); 184 182 185 183 startLoggingStats(); … … 539 537 else if (state == webrtc::PeerConnectionInterface::kIceGatheringGathering) 540 538 protectedThis->m_peerConnectionBackend.connection().updateIceGatheringState(RTCIceGatheringState::Gathering); 539 else if (state == webrtc::PeerConnectionInterface::kIceGatheringNew) 540 protectedThis->m_peerConnectionBackend.connection().updateIceGatheringState(RTCIceGatheringState::New); 541 541 }); 542 542 } -
trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCObservers.h
r267799 r282444 60 60 61 61 template<typename Endpoint> 62 class SetLocalSessionDescriptionObserver final : public webrtc::Set SessionDescriptionObserver{62 class SetLocalSessionDescriptionObserver final : public webrtc::SetLocalDescriptionObserverInterface { 63 63 public: 64 64 explicit SetLocalSessionDescriptionObserver(Endpoint &endpoint) … … 67 67 } 68 68 69 void OnSuccess() final { m_endpoint.setLocalSessionDescriptionSucceeded(); }70 void OnFailure(webrtc::RTCError error) final { m_endpoint.setLocalSessionDescriptionFailed(toExceptionCode(error.type()), error.message()); }71 72 69 void AddRef() const { m_endpoint.AddRef(); } 73 70 rtc::RefCountReleaseStatus Release() const { return m_endpoint.Release(); } 74 71 75 72 private: 73 void OnSetLocalDescriptionComplete(webrtc::RTCError error) final 74 { 75 if (!error.ok()) { 76 m_endpoint.setLocalSessionDescriptionFailed(toExceptionCode(error.type()), error.message()); 77 return; 78 } 79 m_endpoint.setLocalSessionDescriptionSucceeded(); 80 } 81 76 82 Endpoint& m_endpoint; 77 83 }; 78 84 79 85 template<typename Endpoint> 80 class SetRemoteSessionDescriptionObserver final : public webrtc::Set SessionDescriptionObserver{86 class SetRemoteSessionDescriptionObserver final : public webrtc::SetRemoteDescriptionObserverInterface { 81 87 public: 82 88 explicit SetRemoteSessionDescriptionObserver(Endpoint &endpoint) … … 85 91 } 86 92 87 void OnSuccess() final { m_endpoint.setRemoteSessionDescriptionSucceeded(); }88 void OnFailure(webrtc::RTCError error) final { m_endpoint.setRemoteSessionDescriptionFailed(toExceptionCode(error.type()), error.message()); }89 90 93 void AddRef() const { m_endpoint.AddRef(); } 91 94 rtc::RefCountReleaseStatus Release() const { return m_endpoint.Release(); } 92 95 93 96 private: 97 void OnSetRemoteDescriptionComplete(webrtc::RTCError error) final 98 { 99 if (!error.ok()) { 100 m_endpoint.setRemoteSessionDescriptionFailed(toExceptionCode(error.type()), error.message()); 101 return; 102 } 103 m_endpoint.setRemoteSessionDescriptionSucceeded(); 104 } 105 94 106 Endpoint& m_endpoint; 95 107 }; -
trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp
r281985 r282444 206 206 207 207 private: 208 void SetLocalDescription( webrtc::SetSessionDescriptionObserver* observer, webrtc::SessionDescriptionInterface* sessionDescription) final208 void SetLocalDescription(std::unique_ptr<webrtc::SessionDescriptionInterface>, rtc::scoped_refptr<webrtc::SetLocalDescriptionObserverInterface> observer) final 209 209 { 210 std::unique_ptr<webrtc::SessionDescriptionInterface> toBeFreed(sessionDescription);211 210 releaseInNetworkThread(*this, *observer); 212 211 } … … 261 260 } 262 261 263 void MockLibWebRTCPeerConnection::SetLocalDescription( webrtc::SetSessionDescriptionObserver* observer, webrtc::SessionDescriptionInterface* sessionDescription)262 void MockLibWebRTCPeerConnection::SetLocalDescription(std::unique_ptr<webrtc::SessionDescriptionInterface> sessionDescription, rtc::scoped_refptr<webrtc::SetLocalDescriptionObserverInterface> observer) 264 263 { 265 264 bool isCorrectState = true; … … 283 282 if (!isCorrectState) { 284 283 LibWebRTCProvider::callOnWebRTCSignalingThread([observer] { 285 observer->On Failure(webrtc::RTCError(webrtc::RTCErrorType::INVALID_STATE));284 observer->OnSetLocalDescriptionComplete(webrtc::RTCError(webrtc::RTCErrorType::INVALID_STATE)); 286 285 }); 287 286 return; 288 287 } 289 288 290 std::unique_ptr<webrtc::SessionDescriptionInterface> toBeFreed(sessionDescription);291 289 LibWebRTCProvider::callOnWebRTCSignalingThread([this, observer] { 292 observer->OnS uccess();290 observer->OnSetLocalDescriptionComplete(webrtc::RTCError::OK()); 293 291 gotLocalDescription(); 294 292 }); 295 293 } 296 294 297 void MockLibWebRTCPeerConnection::SetRemoteDescription( webrtc::SetSessionDescriptionObserver* observer, webrtc::SessionDescriptionInterface* sessionDescription)295 void MockLibWebRTCPeerConnection::SetRemoteDescription(std::unique_ptr<webrtc::SessionDescriptionInterface> sessionDescription, rtc::scoped_refptr<webrtc::SetRemoteDescriptionObserverInterface> observer) 298 296 { 299 297 bool isCorrectState = true; … … 317 315 if (!isCorrectState) { 318 316 LibWebRTCProvider::callOnWebRTCSignalingThread([observer] { 319 observer->On Failure(webrtc::RTCError(webrtc::RTCErrorType::INVALID_STATE));317 observer->OnSetRemoteDescriptionComplete(webrtc::RTCError(webrtc::RTCErrorType::INVALID_STATE)); 320 318 }); 321 319 return; 322 320 } 323 321 324 std::unique_ptr<webrtc::SessionDescriptionInterface> toBeFreed(sessionDescription);325 322 LibWebRTCProvider::callOnWebRTCSignalingThread([observer] { 326 observer->OnS uccess();323 observer->OnSetRemoteDescriptionComplete(webrtc::RTCError::OK()); 327 324 }); 328 325 ASSERT(sessionDescription); -
trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.h
r281985 r282444 300 300 301 301 protected: 302 void SetRemoteDescription(webrtc::SetSessionDescriptionObserver*, webrtc::SessionDescriptionInterface*) final ;303 void SetRemoteDescription(std::unique_ptr<webrtc::SessionDescriptionInterface>, rtc::scoped_refptr<webrtc::SetRemoteDescriptionObserverInterface>) override { }302 void SetRemoteDescription(webrtc::SetSessionDescriptionObserver*, webrtc::SessionDescriptionInterface*) final { ASSERT_NOT_REACHED(); } 303 void SetRemoteDescription(std::unique_ptr<webrtc::SessionDescriptionInterface>, rtc::scoped_refptr<webrtc::SetRemoteDescriptionObserverInterface>) override; 304 304 bool RemoveIceCandidates(const std::vector<cricket::Candidate>&) override { return true; } 305 305 rtc::scoped_refptr<webrtc::DtlsTransportInterface> LookupDtlsTransportByMid(const std::string&) override { return { }; } … … 315 315 webrtc::RTCError SetBitrate(const webrtc::BitrateSettings&) final { return { }; } 316 316 317 void SetLocalDescription(webrtc::SetSessionDescriptionObserver*, webrtc::SessionDescriptionInterface*) override; 317 void SetLocalDescription(webrtc::SetSessionDescriptionObserver*, webrtc::SessionDescriptionInterface*) final { ASSERT_NOT_REACHED(); }; 318 void SetLocalDescription(std::unique_ptr<webrtc::SessionDescriptionInterface>, rtc::scoped_refptr<webrtc::SetLocalDescriptionObserverInterface>) override; 318 319 bool GetStats(webrtc::StatsObserver*, webrtc::MediaStreamTrackInterface*, StatsOutputLevel) override { return false; } 319 320 void CreateOffer(webrtc::CreateSessionDescriptionObserver*, const webrtc::PeerConnectionInterface::RTCOfferAnswerOptions&) override;
Note:
See TracChangeset
for help on using the changeset viewer.