Skip to content

Potential memory leak in webrtc packet processing #3223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
renaynay opened this issue Mar 7, 2025 · 4 comments · Fixed by #3243
Closed

Potential memory leak in webrtc packet processing #3223

renaynay opened this issue Mar 7, 2025 · 4 comments · Fixed by #3243
Assignees
Labels
P0 Critical: Tackled by core team ASAP

Comments

@renaynay
Copy link

renaynay commented Mar 7, 2025

Non-critical but noticeable memory leak interestingly coming from context.Done somewhere from webrtc packet processing.

Flame graph from yesterday at ~15:00 UTC+1

https://flamegraph.com/share/c80d4436-fa8b-11ef-8d53-2a7e77e4af82

Flame graph from today at ~10:30 UTC+1

https://flamegraph.com/share/df3ef673-fb37-11ef-8d53-2a7e77e4af82

cc @Wondertan

@sukunrt sukunrt self-assigned this Mar 17, 2025
@sukunrt sukunrt added the P0 Critical: Tackled by core team ASAP label Mar 17, 2025
@sukunrt
Copy link
Member

sukunrt commented Mar 19, 2025

Thanks for reporting this.

I'm curious, are you using / are interested in using webrtc-direct in production?
I have a bunch of improvements I can make to the transport, but I'm unwilling to spend time on it without some interest from users.

@Wondertan
Copy link
Contributor

We do use webrtc-direct in production where we can't use webtransport. What kind of improvements do you mean?

@sukunrt
Copy link
Member

sukunrt commented Mar 20, 2025

  1. Having the certhash be persistent across restarts, like webtransport.
  2. There's probably potential for performance improvements. I already have a couple of draft PRs that I never pushed over the line in SCTP. Optimize payload queue for write path pion/sctp#320 Add receive chunk tracker for better received chunk handling pion/sctp#319

@Wondertan
Copy link
Contributor

Wondertan commented Mar 20, 2025

Having the certhash be persistent across restarts, like webtransport.

@sukunrt, this is indeed useful! We could then add them to dnsaddr, so certain browsers can connect over WebRTC directly.
Optimizations are less so, as long as it works. There are bigger bottlenecks on our side for WebRTC ones to be even visible.

sukunrt added a commit that referenced this issue Mar 21, 2025
This context wasn't being cancelled on all code paths. In particular,
contexts for connections that didn't complete negotiation were not being
cancelled.

The change arranges for either `udpmux.muxedConnection.Close` or 
`RemoveConnByUfrag` to call the other.

Fixes: #3223
sukunrt added a commit that referenced this issue Mar 24, 2025
This context wasn't being cancelled on all code paths. In particular,
contexts for connections that didn't complete negotiation were not being
cancelled.

The change arranges for either `udpmux.muxedConnection.Close` or 
`RemoveConnByUfrag` to call the other.

Fixes: #3223
sukunrt added a commit that referenced this issue Mar 24, 2025
This context wasn't being cancelled on all code paths. In particular,
contexts for connections that didn't complete negotiation were not being
cancelled.

The change arranges for either `udpmux.muxedConnection.Close` or 
`RemoveConnByUfrag` to call the other.

Fixes: #3223
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P0 Critical: Tackled by core team ASAP
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants