mre / timelapse

🎬 Native macOS app for recording timelapse videos of your desktop.
https://endler.dev/2020/timelapse/
Apache License 2.0
214 stars 18 forks source link

Recorder thread fails to join #23

Closed cmangla closed 4 years ago

cmangla commented 4 years ago

When I press "stop recording", the main thread calls '.join' on the recorder thread, which never returns, so then the encoder is never called to make the video.

Describe the Bug

This ugly hack is what I need to do to workaround this issue:

https://github.com/cmangla/timelapse/commit/98482c04de8f99654061577f943313770f586121

System Information

Additional Context

I did pip3 install -r <(cut -d= -f1 < requirements.txt ), so I got the latest versions of the dependencies. I couldn't build the versions listed in requirements.txt.

mre commented 4 years ago

That's weird. It works for me. I thought that by calling _set_stop(), which sets the flag to stop the recording thread after the next iteration, it would terminate recording. Maybe there's an edge case that is not covered? Anyway, I'd be happy to merge a PR that fixes that if you want to give it a shot. Thanks for the report.

cmangla commented 4 years ago

I tried very hard to figure out if there is some weird race condition in there. When _set.stop() is called, it seems to do its job. The loop in run() does indeed terminate. So I cannot figure out why Thread.join() then hangs. I even tried using a timeout in Thread.join, but that makes no difference: it hangs and does not time out.

The only clean solution I've found is to run Recorder in a different process. PR #24 does so.

cmangla commented 4 years ago

Thanks for merging PR #24 @mre.