Skip to content
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

RTC peers are not garbage collected in a timely manner on Chromium-based browsers #787

Open
R0quef0rt opened this issue Mar 17, 2021 · 2 comments

Comments

@R0quef0rt
Copy link

What version of this package are you using?
^9.9.3

What operating system, Node.js, and npm version?
This happens on both Windows 10 and Ubuntu 20.024. It's not an NPM or Node problem.

What happened?
This is a known bug in Chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=825576

This is currently affecting my ability to use WebTorrent: webtorrent/webtorrent#2017

RTC peers are released too slowly, causing an error that breaks both WebTorrent Desktop and the browser-only version of WebTorrent (while running in Chromium browsers). The following error will be seen in WD's "Developer > Show WebTorrent Process" menu: Failed to construct 'RTCPeerConnection': Cannot create so many PeerConnections

When this occurs, WebTorrent is completely unable to seed data. It is permanently broken until the process has been restarted.

This code can be used to fix the problem:

function forcePeerGC () {
  queueMicrotask(() => {
    let img = document.createElement('img')
    img.src = window.URL.createObjectURL(new Blob([new ArrayBuffer(5e+7)]))
    img.onerror = function () {
      window.URL.revokeObjectURL(this.src)
      img = null
    }
  })
}

setInterval(forcePeerGC, 30000)

What did you expect to happen?
Ideally, Chromium would perform proper garbage collection. But since that bug has existed for 3 years, I think it's unlikely to be fixed anytime soon.

Are you willing to submit a pull request to fix this bug?
I am willing to do this, though I have tried and I am struggling to figure out how. Tests fail because the "document" object does not exist in Node, and neither does the "new Blob()" function.

@DavidRadan
Copy link

DavidRadan commented Mar 4, 2024

Hi Guys ,
Any news regarding this BUG ?
Did you managed to solve this somehow ?
This issue still happening in the lib i'm afraid ( still didn't applied the fix above ) .
Thanks

@DavidRadan
Copy link

DavidRadan commented Mar 5, 2024

After applying the fix above the issue still remains !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants