ShayBox / Mon2Cam

Workaround for multi-monitor Discord screensharing
MIT License
337 stars 33 forks source link

Freeze after ~10 minutes #57

Closed iTrooz closed 3 years ago

iTrooz commented 3 years ago

Hi ! I'm using manjaro with kernel 58, and when I launch mon2cam, the "screenshare" stop after roughly 10 minutes Here is the verbose logs, but I don't think there is something important! test.png (The program doesn't crash)

ShayBox commented 3 years ago

Yeah I've been getting this since the rewrite but nothing indicates any changes when it freezes, and nobody else was reporting it, could you provide a full log (you don't have to wait for it to freeze), and what gpu and monitor refreshrate do you have.

EDIT: Why is your log small enough to fit in a single picture... interesting

iTrooz commented 3 years ago

Here are my refresh rate test and my gpu is a GeForce GTX 1060 How can I provide a "full log" ?

devcexx commented 3 years ago

I'm having pretty much the same issue. Please let me know how can we help you to identify the root cause, I'll be glad to help on this :P.

Rdeisenroth commented 3 years ago

Im also having the same freezing issue... My current "workaround" until it's fixed is to automatically restart the program every two minutes: while true; do timeout 120s mon2cam --monitor 0;date ; sleep .3; done (the small delay here is used to be able to use CTRL+C to exit out of the loop)

x10an14 commented 3 years ago

I've got the same issue here - (timeout after ~10 minutes). @ShayBox please advice on how to further help you debug/figure this out! =)

My Linux info ``` [2020-12-26 12:18:01] 0 x10an14@x10-desktop:~ -> $ screenfetch _,met$$$$$gg. x10an14@x10-desktop ,g$$$$$$$$$$$$$$$P. OS: Debian 10 buster ,g$$P"" """Y$$.". Kernel: x86_64 Linux 4.19.0-13-amd64 ,$$P' `$$$. Uptime: 22h 7m ',$$P ,ggs. `$$b: Packages: 3866 `d$$' ,$P"' . $$$ Shell: bash 5.0.3 $$P d$' , $$P Resolution: 6560x2560 $$: $$. - ,d$$' WM: i3 $$\; Y$b._ _,d$P' CPU: AMD Ryzen 5 2600 Six-Core @ 12x 3.698GHz [48.0°C] Y$$. `.`"Y$$$$P"' GPU: GeForce GTX 1080 `$$b "-.__ RAM: 9230MiB / 32161MiB `Y$$ `Y$$. `$$b. `Y$$b. `"Y$b._ `"""" [2020-12-26 12:18:10] 0 x10an14@x10-desktop:~ -> $ ```
ShayBox commented 3 years ago

I really have no idea, no way to debug this, nothing is breaking

iTrooz commented 3 years ago

Okay, so.. The hunt is open for us

ShayBox commented 3 years ago

If you can find what's going on go ahead, but nothing is different from the bash script, ffmpeg or v4l2 is just breaking but not erroring

GamerGuy95953 commented 3 years ago

I am also having this same problem and also running manjaro. I know its v4l2 or ffmpeg but I'm just saying for anyone else to know it's not just them.

GamerGuy95953 commented 3 years ago

Im also having the same freezing issue... My current "workaround" until it's fixed is to automatically restart the program every two minutes: while true; do timeout 120s mon2cam --monitor 0;date ; sleep .3; done (the small delay here is used to be able to use CTRL+C to exit out of the loop)

I tried your command on Linux manjaro cinnamon and it just says "INFO x11 detected, to use Wayland add -w". I tried seeing the preview but it's just blank.

EDIT: Nevermind i got it working by doing sudo su then the command.

manugame commented 3 years ago

if you set framerate to 30, its doesn't freeze

iTrooz commented 3 years ago

Sadly, even with this I get the freeze (is it the -f 30 flag ?)

bruno-novo-it commented 3 years ago

Hi,

@iTrooz, i run like this mon2cam -f 30 --monitor 0 -x and doesn't freeze even after one hour sharing the screen in Discord. Can you try this to see if it work's?

iTrooz commented 3 years ago

Yep, and still freeze. Thanks for the help anyways

solonovamax commented 3 years ago

if you set framerate to 30, its doesn't freeze

i run like this mon2cam -f 30 --monitor 0 -x and doesn't freeze even after one hour sharing the screen in Discord. Can you try this to see if it work's?

Even with the framerate at 30 fps, it still freezes for me. I'm currently running it with mon2cam -x -e -f 30 -m 0 -r 1280:720, and it still seems to freeze for me.

D3SOX commented 3 years ago

I don't know why but it doesn't freeze for me with mon2cam -m 0 -f 29 -v The -v seems to be important for it not to freeze

solonovamax commented 3 years ago

I don't know why but doesn't freeze for me with mon2cam -m 0 -f 29 -v The -v seems to be important for it not to freeze

I just tested that out, and I mirrored your results. I ran mon2cam -x -e -f 30 -m 0 -r 1280:720 -v for about 40 minutes, without the stream pausing. Not sure why when it's run in verbose mode it works, but when run in normal mode, it doesn't.... That's pretty strange.

D3SOX commented 3 years ago

Maybe somehow the verbose mode keeps the ffmpeg process alive which would otherwise be killed after some time (still not sure why)

ShayBox commented 3 years ago

That is pretty strange, thanks for discovering this

devcexx commented 3 years ago

It seems that the stderr stream isn't read unless the verbose flag is set, but that descriptor is still redirected throught a pipe. If ffmpeg is writing to the stderr (actually it does everytime it prints the conversion progress), but there's no consumer reading from the pipe, it might happen that the pipe gets filled in a few minutes and any syscall to write to stderr would make the caller thread to sleep indefinitely, and might explain why ffmpeg stops responding after some time. Does it make any sense?

GamerGuy95953 commented 3 years ago

I don't know why but doesn't freeze for me with mon2cam -m 0 -f 29 -v The -v seems to be important for it not to freeze

Can confirm! Fixed my issue on Linux Manjaro Cinnamon. Thanks!

botiapa commented 3 years ago

@ShayBox Maybe we should redirect into /dev/null when in non verbose mode?

devcexx commented 3 years ago

@ShayBox Maybe we should redirect into /dev/null when in non verbose mode?

ShayBox commented 3 years ago

Yes this appears to be the problem, I left it running in verbose all night and it didn't freeze, I don't know what you mean about the gdb thing, you can modify the code if you want, im gonna add the redirecting to fix the problem

D3SOX commented 3 years ago

I'm glad I discovered this. It was more or less accidental though. I had used the old bash version for a long time and wanted to test the new version again (especially because of the hardware acceleration, which works really well by the way. It runs much smoother with -e vaapi for me). Then I just added the -v flag for testing, later I thought it is a bit too much output for me. So I removed it and noticed that the freezing happens again now.

I hope it helps to fix this problem soon. This issue is now open for quite some time.

ShayBox commented 3 years ago

The fix should be pushed, re-running the script should now work! (if you're using the alias, on arch you need to re-build the package)

D3SOX commented 3 years ago

you need to re-build the package

Or you use a package manager that tracks development packages image (yay -Syu --devel or paru)

D3SOX commented 3 years ago

The problem still happens for me at 8fdd0c1

ShayBox commented 3 years ago

Fixed now, forgot to invert a condition

D3SOX commented 3 years ago

I can confirm that it works now!

iTrooz commented 3 years ago

Works for me too ! I'll close the issue, thanks everyone :)