Repository navigation
Retain final stats after PeerConnection close - #3678
armaan4658 wants to merge 3 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## next #3678 +/- ##
==========================================
+ Coverage 91.37% 91.58% +0.21%
==========================================
Files 67 67
Lines 7860 7906 +46
==========================================
+ Hits 7182 7241 +59
+ Misses 678 665 -13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
calling getStats on a closed peerconnection returns very, very little these days, basically just the |
|
@fippo but the spec suggests that we keep them?
so even if browser violate this currently i think we should follow it since we follow w3c and not browser implementations. |
|
the spec problem is that the transceivers get removed along with |
|
I thought they were still maintained after shutdown and not removed? where does it say that we should remove them? we currently keep them per the spec https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-close I also think keeping counters after shutdown will be really helpful for most of our users since they don't have to keep counters at their side. otherwise the fix itself doesn't make much sense. |
|
Given Firefox decade-long failure to not throw on calling pc.getStats() after close we can be reasonably certain nobody cares. I'd align with Chromium/libwebrtc |
|
given that the original issue #2768, had
then we either make this fix unrelated and to just remove the logs. but doesn't close or fix the issue. or actually retain the counters and fix the original issue |
|
I do not see a point in keeping around ice stats while dropping RTP ones. Lets see what the spec oracles say. |
|
Imo we should keep everything after shutdown I can see it being useful for sfus |
|
Thanks for the review. Happy to go either way, but I'd like to confirm the scope
Which would you prefer? |
|
@armaan4658 feel free to do any or both, no preference from my side, we shouldn't wait for w3c |
|
@JoTurk I've updated the PR to keep the final stats after close, and the Could you take another look? Two questions:
|
JoTurk
left a comment
There was a problem hiding this comment.
looks good to me, should rebase and merge against next
b5ae79d to
1018a0c
Compare
|
@JoTurk I've rebased this onto One addition since your review: The rest works the same, but the conflicts meant reworking parts of the ICE and The remaining question is timestamps: inbound RTP shows the current |
1018a0c to
108cc03
Compare
|
@JoTurk could you approve the workflows when you get a chance? They're waiting on |
108cc03 to
5fea4a2
Compare
GetStats on a closed PeerConnection queried the closed ICE agent, which logged errors, and lost most of its stats. Save the ICE, SCTP and RTP stats before teardown and serve them after close. Fixes pion#2768
|
@JoTurk I've addressed your review and merged the latest |
Description
GetStats()on a closed PeerConnection logged threethe agent is closederrors and lost most of its stats. This keeps the final values, as discussed
in the review.
What gets saved, just before each is torn down:
ICETransport.stop(), before the agentis closed.
collectStatsthen returns the copy, so it no longer queries theclosed agent and the logs are gone.
SCTPTransport.Stop(), beforeAbort.Stats()keepsreturning these values after close.
PeerConnection.close(), before the transceiversstop. Stopping them removes the stream stats, and a stopped sender reports
nothing.
Data channel, DTLS, certificate and codec stats were already available after
close.
This does change what a closed PeerConnection reports (more stats instead of
none or zeros), so this PR is now based on
next, as requested. Outbound RTPis new since the last review, because
nextreports it andmaindoesn't.Not covered:
Close(), such as during renegotiation,still loses its stats.
ICETransport.GetSelectedCandidatePairStats()still queries the closed agent.GetStats()is already querying the agent as itcloses.
Two things I'd like your view on:
Timestampon eachcall, while outbound RTP, ICE and SCTP keep their closing timestamp.
RTPReceiver.collectStatsreadsremoteTrack.codecwithout the track's lockwhile
checkAndUpdateTrackwrites it. My test hit this under-racewhilepolling
GetStats()as the first packet arrived, so the test now waits forOnTrack. I left that read unchanged, since it isn't part of this fix. I canopen a separate issue for it.
Added
TestPeerConnection_GetStats_RetainedAfterClose.Reference issue
Fixes #2768