Skip to content

Interceptor.loop() goroutine leak #384

Closed
pion/ice
#840

Description

@denis1kor

Your environment.

  • Version: v.0.1.37
  • Browser: Firefox - 129.0.2, Chrome - 138, Safari - not tested

What did you do?

Hello everyone, this is my first GitHub issue, so please guide me if I am doing something wrong. I am trying to create a simple server which will accept requests from a browser and create a WebRTC connection with audio track. I noticed that if I reload the page shortly after connection is established, goroutine leak will be created.
Here are results from profiler:
Image

Important: I can reproduce this issue only when the server is located on a remote host. I cannot reproduce it on the local server.

What did you expect?

WebRTC connection to close properly.

What happened?

PeerConnection is closing partially, and the interceptor goroutines are never closing.
Seams like PeerConnection.close() stuck during execution. To be more specific it stuck at iceTransport.GracefulStop():
repository - webrtc, file - peerconnection.go:
2443 if pc.iceTransport != nil {
2444 here --> gracefulCloseErrors = append(gracefulCloseErrors, pc.iceTransport.GracefulStop())
2445 }

I investigated it a little bit, and i think problem is in handlerNotifier.Close() function. If Close() is graceful we will need to wait for WaitGroup to unblock the execution:
repository - ice, file - agent_handlers.go:
68 if graceful {
69 // if we were closed ungracefully before, we now
70 // want ot wait.
71 here --> defer h.notifiers.Wait()
72 }
I assume that handlerNotifier.EnqueueConnectionState() function never gets to "WaitGroup.done()" for some reason.

Activity

  1. charlieblevins commented on Nov 25, 2025

    @charlieblevins

    @denis1kor could you please re-post the profiler image? I'm seeing a broken image link (see below).

    can you supply a small program that reproduces the issue?

    Image
  2. JoTurk commented on Nov 26, 2025

    @JoTurk
    Member

    @denis1kor @charlieblevins can you please check if this pion/ice#840 fixes this issue?

  3. JoTurk commented on Nov 26, 2025

    @JoTurk
    Member

    I'll reopen this until the fix is confirmed

  4. reopened this on Nov 26, 2025
  5. denis1kor commented on Nov 27, 2025

    @denis1kor
    Author

    @charlieblevins i re-posted the image. I will create the program that reproduces the issue and attach it to the report in few days

  6. denis1kor commented on Nov 27, 2025

    @denis1kor
    Author

    @joeturki Unfortunately, i still can reproduce this issue

  7. JoTurk commented on Nov 27, 2025

    @JoTurk
    Member

    @denis1kor we're currently trying this fix for another issue (maybe it's related) pion/sctp@0c627f6

    Do you know if it happens only for ICE-TCP? Is there a way for me to debug this issue and how to reproduce it?

    Edit: if you're using TCP and datachannels this probably fixes this issue : pion/sctp#441

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions