-
Notifications
You must be signed in to change notification settings - Fork 546
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
Watchdog timeout when camera thread is busy #888
Comments
How do you use h264_omx codec? |
h264_omx encode by having motion call ffmpeg API, i.e. remove h264_omx from blacklist, then select h264_omx as the preferred encoder in the thread-1.conf file. |
The main function enters a forever loop in which is spawns as needed the threads for each camera which then go into their own loops grabbing and processing images. In each pass of the main loop, it waits for one second and then calls a watchdog function which decrements the watchdog counter. Each count on watchdog variable is therefore a decrement of one second. The counter is reset to the starting point during each pass of the camera motion loop. When it gets to the first predefined timeout, it sets the "finish" flag which is the best way to close it all down since it cleans everything up. If that works, then the thread will be restarted and the watchdog reset. If the thread doesn't respond to a "clean" shutdown the watchdog variable continues to count down to the kill timeout. If the thread still hasn't reset the counter then a kill request is sent not only to the camera thread but also to all of the other threads that it may have spawned. If motion is timing out on the encoding, then it is hanging up trying to flush the buffer or a particular function is no longer returning a value. The camera motion loop calls an event and the event sends the image for encoding. A watchdog means it never returned from that sequence back to the motion loop to reset the watchdog. I'd note that the buffer flushing situation could occur if a timelapse is requested. We get one image and we must write it out because the next image may not come for hours. So the same image keeps getting sent until the return code says it was not buffered. References: |
This appears to be caused by ffmpeg omx code not handling multiple buffers as reported here: raspberrypi/firmware#1087 |
Also omx-related: #433 |
Brief:
The Raspberry Pi firmware/userland behaviour changed a little bit recently, causing motion to incorrectly trigger a watchdog timeout and killing the camera thread when camera thread is busy.
When motion is configured to push high resolution (1600x1200) at high frame rate (20fps) that chokes the GPU, motion keeps printing EAGAIN message until the watchdog eventually times out. (works perfectly when GPU not choked, e.g. lower resolution or fps)
While printing this message (before watchdog timeout) EAGAIN period, everything works fine, still recording video as expected. Also during this EAGAIN period, if workload is throttled back a little bit (e.g. motion gap period), it resets the watchdog timer and doesn't timeout.
Full log here:
With the older rpi-firmware/userland version, motion prints out EAGAIN and buffered packet messages twice at the beginning of each video recording, and continues to work without watchdog timeout. I don't know what has changed in rpi-firmware/userland, and how motion watchdog detects a timeout. Can someone please shed a light on how motion watchdog works?
Note: Motion works fine with:
rpi-firmware version : ce8652e2c743f02f04cb29f23611cbf13765483b
rpi-userland version : a343dcad1dae4e93f4bfb99496697e207f91027e
The text was updated successfully, but these errors were encountered: