Bug 1147857: be careful about WebRTC stats query creation r=jib

This commit is contained in:
Randell Jesup 2015-03-27 15:52:56 -04:00
parent 3b75ea9aff
commit d8c68a04b7
2 changed files with 22 additions and 13 deletions

View File

@ -289,14 +289,20 @@ PeerConnectionCtx::EverySecondTelemetryCallback_m(nsITimer* timer, void *closure
p != ctx->mPeerConnections.end(); ++p) {
if (p->second->HasMedia()) {
queries->append(nsAutoPtr<RTCStatsQuery>(new RTCStatsQuery(true)));
p->second->BuildStatsQuery_m(nullptr, // all tracks
queries->back());
if (NS_WARN_IF(NS_FAILED(p->second->BuildStatsQuery_m(nullptr, // all tracks
queries->back())))) {
queries->popBack();
} else {
MOZ_ASSERT(queries->back()->report);
}
}
}
rv = RUN_ON_THREAD(stsThread,
WrapRunnableNM(&EverySecondTelemetryCallback_s, queries),
NS_DISPATCH_NORMAL);
NS_ENSURE_SUCCESS_VOID(rv);
if (!queries->empty()) {
rv = RUN_ON_THREAD(stsThread,
WrapRunnableNM(&EverySecondTelemetryCallback_s, queries),
NS_DISPATCH_NORMAL);
NS_ENSURE_SUCCESS_VOID(rv);
}
}
#endif

View File

@ -2807,17 +2807,22 @@ PeerConnectionImpl::BuildStatsQuery_m(
RTCStatsQuery *query) {
if (!HasMedia()) {
return NS_OK;
return NS_ERROR_UNEXPECTED;
}
if (!mMedia->ice_ctx() || !mThread) {
CSFLogError(logTag, "Could not build stats query, critical components of "
"PeerConnectionImpl not set.");
// Note: mMedia->ice_ctx() is deleted on STS thread; so make sure we grab and hold
// a ref instead of making multiple calls. NrIceCtx uses threadsafe refcounting.
query->iceCtx = mMedia->ice_ctx();
if (!query->iceCtx) {
CSFLogError(logTag, "Could not build stats query, no ice_ctx");
return NS_ERROR_UNEXPECTED;
}
if (!mThread) {
CSFLogError(logTag, "Could not build stats query, no MainThread");
return NS_ERROR_UNEXPECTED;
}
nsresult rv = GetTimeSinceEpoch(&(query->now));
if (NS_FAILED(rv)) {
CSFLogError(logTag, "Could not build stats query, could not get timestamp");
return rv;
@ -2884,8 +2889,6 @@ PeerConnectionImpl::BuildStatsQuery_m(
}
}
query->iceCtx = mMedia->ice_ctx();
// From the list of MediaPipelines, determine the set of NrIceMediaStreams
// we are interested in.
std::set<size_t> levelsToGrab;