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

Webtorrent makes NWjs freez and hang #1224

Closed
vankasteelj opened this issue Nov 9, 2017 · 10 comments
Closed

Webtorrent makes NWjs freez and hang #1224

vankasteelj opened this issue Nov 9, 2017 · 10 comments

Comments

@vankasteelj
Copy link

@vankasteelj vankasteelj commented Nov 9, 2017

I'm using webtorrent inside a nwjs app. I'm using it to download videos that are played on a localhost port, and read from MPV. I use a single instance of webtorrent and download a single file.

Most of the time, webtorrent will work flawlessly. But sometimes, in an upredicable manner, it will make the entire app freez and then hang, with CPU usage going up to 50%.

I'm guessing there's some loop somewhere that goes nuts, you can simulate a similar freez in console by running a bunch of expensive operations in an infinite loop. But I can't log anything, because the app freezes and I have no other choice than killing nwjs' process.

What version of WebTorrent?

  • 0.98.20
  • it already happened with 98 and 98.1

What operating system and Node.js version?

  • Windows 10, nwjs 26.4 (node 9+)
  • not related to nwjs version, I used a few different versions, it happens with all, but randomly.

What browser and version? (if using WebTorrent in the browser)
No browser (well, except nwjs)

What did you expect to happen?
Download goes flawlessly like always

What actually happened?
once in a while, webtorrent will make the entire app hang, like a loop gone mad or something, and CPU usage will rise up to 50% of an intel m3

@DiegoRBaquero

This comment has been minimized.

Copy link
Member

@DiegoRBaquero DiegoRBaquero commented Nov 10, 2017

Can you post full logs while this happens?

@vankasteelj

This comment has been minimized.

Copy link
Author

@vankasteelj vankasteelj commented Nov 11, 2017

I can't, as it makes nwjs freez. Hence it doesnt write the part of the log when it happens, because it's frozen. Unless you have an idea to bypass nwjs somehow, but I doubt its doable since webtorrent gets called by nwjs' node

@transitive-bullshit

This comment has been minimized.

Copy link
Member

@transitive-bullshit transitive-bullshit commented Nov 24, 2017

Maybe post the full console output from up until the error occurs in a pastebin and link here? I'm not super familiar with nwjs's APIs, but I would expect them to have some verbose logging option during initialization.

@t-mullen

This comment has been minimized.

Copy link

@t-mullen t-mullen commented Dec 15, 2017

If it's an infinite loop, you should be able to pause in devtools?

https://github.com/nwjs/nw.js/wiki/debugging-with-devtools

@vankasteelj

This comment has been minimized.

Copy link
Author

@vankasteelj vankasteelj commented Dec 16, 2017

devtool cannot be opened or focused when nwjs process hangs.

I've noticed that the issue only appears when you download multiple files over a somewhat long period of time.

EG:

  • spawn webtorrent, attach a link, download a file = always ok
  • do that 5 times in a row, it might hang
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented May 3, 2018

Duplicate of #1026.

High CPU is a known bug of WebTorrent in some circumstances, for now. I suggest not running in the same thread as your UI. In WebTorrent Desktop, for example, we have a separate thread just for WebTorrent so it will never freeze the UI.

@feross feross closed this May 3, 2018
@vankasteelj

This comment has been minimized.

Copy link
Author

@vankasteelj vankasteelj commented May 3, 2018

RAM usage is also high, like 1500Mb

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented May 3, 2018

WebTorrent Desktop doesn't have high RAM usage in normal usage. If you can share example code that reproduces the issue, or explain how to reproduce it in more depth, that would be helpful.

@vankasteelj

This comment has been minimized.

Copy link
Author

@vankasteelj vankasteelj commented May 5, 2018

Here's my streamer: https://github.com/vankasteelj/frak/blob/master/app/js/lib/streamer.js

High RAM usage only happens when webtorrent "freezes", as described above.

As with the above linked file, you could reproduce doing this:

Streamer.start('some torrent');
Streamer.stop(); // once the file is downloaded

Repeat a few times with different torrents, without reloading the browser (nwjs, in my case).

Usually after 4 or 6 video files, it will freeze.

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented May 9, 2018

Thanks for the sample code. I believe this is just yet another instance of the known CPU issues with WebTorrent. Please follow this issue #1026 for updates.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.