Re: [webrtc-stats] Is keeping stats around a memory problem?

Copying my idea from the mailing list:

I've been pondering other options, and came up with one:
<pre>
partial interface RTCPeerConnection {
   attribute EventHandler onstatsobjectended;
}
</pre>
and an event
<pre>
interface RTCStatsEvent : Event {
   readonly attribute RTCStats finalStats;
}
</pre>

The advantage of this is that as long as there's no listener attached,
this produces no overhead that grows over time; when there's a listener
attached, the memory and time overhead is the caller's problem.

It's trivial to shim getCompletedStats on top of this:
<pre>
pc.onstatsobjectended = function(e) {
   pc._completedStats.pushBack(e.finalStats);
}

pc.prototype.getCompletedStats = function() {
   return pc._completedStats;
}
</pre>
The same thing can be added to RTPSender and RTPReceiver, of course.

Thoughts? Is this simpler than getCompletedStats? Are there huge
disadvantages to this approach?


-- 
GitHub Notification of comment by alvestrand
Please view or discuss this issue at https://github.com/w3c/webrtc-stats/issues/235#issuecomment-358316276 using your GitHub account

Received on Wednesday, 17 January 2018 14:13:20 UTC