imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-transceivers.https.html is flaky on iOS simulator
https://bugs.webkit.org/show_bug.cgi?id=192037
Reviewed by Eric Carlson.
The stats report JS map should be created when resolving the stats promise with WebCore RTCStatsReport.
But resolving the promise might fail in case of a page being suspended.
In that case, no JSRTCStatsReport is created and there is no backing map.
Update the code to reflect that.
Covered by existing test.
* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::LibWebRTCMediaEndpoint::getStats):
* Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp:
(WebCore::LibWebRTCStatsCollector::~LibWebRTCStatsCollector):
(WebCore::LibWebRTCStatsCollector::OnStatsDelivered):
* Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@238642 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index e84e5af..6c7b714 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,23 @@
+2018-11-28 Youenn Fablet <youenn@apple.com>
+
+ imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-transceivers.https.html is flaky on iOS simulator
+ https://bugs.webkit.org/show_bug.cgi?id=192037
+
+ Reviewed by Eric Carlson.
+
+ The stats report JS map should be created when resolving the stats promise with WebCore RTCStatsReport.
+ But resolving the promise might fail in case of a page being suspended.
+ In that case, no JSRTCStatsReport is created and there is no backing map.
+ Update the code to reflect that.
+ Covered by existing test.
+
+ * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+ (WebCore::LibWebRTCMediaEndpoint::getStats):
+ * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp:
+ (WebCore::LibWebRTCStatsCollector::~LibWebRTCStatsCollector):
+ (WebCore::LibWebRTCStatsCollector::OnStatsDelivered):
+ * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h:
+
2018-11-28 Keith Rollin <krollin@apple.com>
Update generate-{derived,unified}-sources scripts to support generating .xcfilelist files
diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp
index a9ee827..3acb25c 100644
--- a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp
+++ b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp
@@ -285,13 +285,19 @@
void LibWebRTCMediaEndpoint::getStats(Ref<DeferredPromise>&& promise, WTF::Function<void(rtc::scoped_refptr<LibWebRTCStatsCollector>&&)>&& getStatsFunction)
{
- auto collector = LibWebRTCStatsCollector::create([promise = WTFMove(promise), protectedThis = makeRef(*this)](auto&& report) mutable {
+ auto collector = LibWebRTCStatsCollector::create([promise = WTFMove(promise), protectedThis = makeRef(*this)]() mutable -> RefPtr<RTCStatsReport> {
ASSERT(isMainThread());
- if (protectedThis->isStopped() || !report)
- return false;
+ if (protectedThis->isStopped())
+ return nullptr;
- promise->resolve<IDLInterface<RTCStatsReport>>(report.releaseNonNull());
- return true;
+ auto report = RTCStatsReport::create();
+
+ promise->resolve<IDLInterface<RTCStatsReport>>(report.copyRef());
+
+ // The promise resolution might fail in which case no backing map will be created.
+ if (!report->backingMap())
+ return nullptr;
+ return WTFMove(report);
});
LibWebRTCProvider::callOnWebRTCSignalingThread([getStatsFunction = WTFMove(getStatsFunction), collector = WTFMove(collector)]() mutable {
getStatsFunction(WTFMove(collector));
diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp
index 8683d73..1ac8378 100644
--- a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp
+++ b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp
@@ -44,7 +44,7 @@
return;
callOnMainThread([callback = WTFMove(m_callback)]() mutable {
- callback({ });
+ callback();
});
}
@@ -384,8 +384,8 @@
void LibWebRTCStatsCollector::OnStatsDelivered(const rtc::scoped_refptr<const webrtc::RTCStatsReport>& rtcReport)
{
callOnMainThread([protectedThis = rtc::scoped_refptr<LibWebRTCStatsCollector>(this), rtcReport] {
- auto report = RTCStatsReport::create();
- if (!protectedThis->m_callback(report.copyRef()))
+ auto report = protectedThis->m_callback();
+ if (!report)
return;
ASSERT(report->backingMap());
diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h
index 8b2a864..253b598 100644
--- a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h
+++ b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h
@@ -42,7 +42,7 @@
class LibWebRTCStatsCollector : public webrtc::RTCStatsCollectorCallback {
public:
- using CollectorCallback = WTF::CompletionHandler<bool(RefPtr<RTCStatsReport>&&)>;
+ using CollectorCallback = CompletionHandler<RefPtr<RTCStatsReport>()>;
static rtc::scoped_refptr<LibWebRTCStatsCollector> create(CollectorCallback&& callback) { return new rtc::RefCountedObject<LibWebRTCStatsCollector>(WTFMove(callback)); }
explicit LibWebRTCStatsCollector(CollectorCallback&&);