[libcamera-devel,0/2] android: Wait on acquisition fences in CameraStream
mbox series

Message ID 20210924170234.152783-1-jacopo@jmondi.org
Headers show
Series
  • android: Wait on acquisition fences in CameraStream
Related show

Message

Jacopo Mondi Sept. 24, 2021, 5:02 p.m. UTC
An acquisition fence is associated to each camera3_stream_buffer_t part of a
capture request.

Streams generated by libcamera (Type::Direct) are queued to the
libcamera::Camera and their fences are waited on by the CameraWorker class.

Acquisition fences for Streams generated by post-processing have been so far
ignored and the fence was not closed, resulting in a leak that crashed the
camera service with:

 FATAL FileDescriptor file_descriptor.cpp:265 Failed to dup() fd: Too many open files

Fix this by instrumenting CameraStream to handle fences in the process()
function.

This is a temporary workaround until libcamera is not instrumented with a
mechanism to handle fences internally.

Thanks
   j

Jacopo Mondi (2):
  android: wait on fences in CameraStream::process()
  android: Post-pone fences reset in result

 src/android/camera_device.cpp | 46 +++++++++++++++++++++++-----------
 src/android/camera_stream.cpp | 47 ++++++++++++++++++++++++++++++++++-
 src/android/camera_stream.h   |  4 ++-
 3 files changed, 81 insertions(+), 16 deletions(-)

--
2.32.0

Comments

Hirokazu Honda Sept. 27, 2021, 5:09 a.m. UTC | #1
Hi Jacopo, thank you for fixing this.

On Sat, Sep 25, 2021 at 2:01 AM Jacopo Mondi <jacopo@jmondi.org> wrote:
>
> An acquisition fence is associated to each camera3_stream_buffer_t part of a
> capture request.
>
> Streams generated by libcamera (Type::Direct) are queued to the
> libcamera::Camera and their fences are waited on by the CameraWorker class.
>
> Acquisition fences for Streams generated by post-processing have been so far
> ignored and the fence was not closed, resulting in a leak that crashed the
> camera service with:
>
>  FATAL FileDescriptor file_descriptor.cpp:265 Failed to dup() fd: Too many open files
>
> Fix this by instrumenting CameraStream to handle fences in the process()
> function.
>
> This is a temporary workaround until libcamera is not instrumented with a
> mechanism to handle fences internally.
>

Laurent, is this what you mentioned me last week?

-Hiro
> Thanks
>    j
>
> Jacopo Mondi (2):
>   android: wait on fences in CameraStream::process()
>   android: Post-pone fences reset in result
>
>  src/android/camera_device.cpp | 46 +++++++++++++++++++++++-----------
>  src/android/camera_stream.cpp | 47 ++++++++++++++++++++++++++++++++++-
>  src/android/camera_stream.h   |  4 ++-
>  3 files changed, 81 insertions(+), 16 deletions(-)
>
> --
> 2.32.0
>