Skip to content

High CPU load with empty RTCPeerConnection #156

@alysenko912

Description

@alysenko912

Hi! I have a problem with RTCPeerConnection.

I create two WebRTC clients, estabilish connection between them (offer-answer). Mic capture is in progress, but not data is not trasferred between them (checked peerConnection.stats) - and it seems fine, because i'm actually do not start transfering of any audio/video.

But with such an "empty" peer connection CPU usage is increaased up to 20%. Looks weird. Do you know what could cause such impact?

Sample code is below.

webRtcClientOne = WebRTCClient(peerConnectionFactory: factory)
webRtcClientTwo = WebRTCClient(peerConnectionFactory: factory)

webRtcClientOne.offer { [unowned self] oneSdp in
  webRtcClientTwo.set(remoteSdp: oneSdp) { [unowned self] _ in
    webRtcClientTwo.answer { [unowned self] twoSdp in
      webRtcClientOne.set(remoteSdp: twoSdp) { _ in
      }
    }
  }
}

timer = Timer.scheduledTimer(withTimeInterval: 5, repeats: true, block: { timer in
  self.webRtcClientOne.peerConnection.stats(for: nil, statsOutputLevel: .debug) { stats in
    print(stats)
  }
})

Stats show that no bytes sent, but CPU load is increased significantly (+20% on iPhone 7)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions