Open Bug 1056433 Opened 10 years ago Updated 2 years ago

getStats should be allowed on a closed PeerConnection

Categories

(Core :: WebRTC, defect, P2)

defect

Tracking

()

People

(Reporter: jib, Unassigned)

References

()

Details

Change getStats so that calling it on a closed PeerConnection does not throw, but instead makes available the stats at the time the PeerConnection closed. Use-case: A webpage wants stats about the call that just terminated from the other side - e.g. how many frames dropped? Basically we already cache a final call to getStats internally for about:webrtc, so this bug is about returning this to content when getStats is called after close.
Rank: 35
Priority: -- → P3
backlog: --- → webRTC+
Mass change P3->P4 to align with new Mozilla triage process.
Priority: P3 → P4
We already take a snapshot of stats at time of close internally, for about:webrtc so this could be low-hanging fruit.
Rank: 35 → 19
Priority: P4 → P2
Steps to reproduce: 1. Open https://jsfiddle.net/jib1/wmae5jtn/ and allow access 2. Click "Close!" button Expected results: - Stats numbers should stop increasing, and fps which should go to 0. Actual result: - TypeError: stats is null

Here's some newer STRs for this bug that don't require interaction:

  1. Open https://jsfiddle.net/jib1/6rzL3asv/18/

Expected result (Chrome):

checking
connected
[object Object]
[object Object]
disconnected
failed

Actual result (Firefox):

checking
connected
[object Object]
undefined
disconnected
failed

Spec support on preserving stats after transceiver.stop() and pc.close():

"With a few exceptions, monitored objects, once created, exist for the duration of their associated RTCPeerConnection. This ensures statistics from them are available in the result from getStats() even past the associated peer connection being closed.

Only a few monitored objects have shorter lifetimes. Statistics from these objects are no longer available in subsequent getStats() results. The object descriptions in [WEBRTC-STATS] describe when these monitored objects are deleted. "

And

"RTP monitored objects are not deleted."

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.