[RFC,v1,00/10] libcamera: software_isp: debayer_egl: Remove some leaks
mbox series

Message ID 20260804101949.353266-1-barnabas.pocze@ideasonboard.com
Headers show
Series
  • libcamera: software_isp: debayer_egl: Remove some leaks
Related show

Message

Barnabás Pőcze Aug. 4, 2026, 10:19 a.m. UTC
Currently `eGL::initEGLContext()` is called each time the camera is started,
so the `EGLContext` is leaked if the camera is started more than once.

Furthermore, mesa does not seem to have any thread destructors to clean up
the bound context when the thread is stopped.

So these are some RFC changes intended to address the above leaks.
(As well some other small changes.)

The effects can be observed with asan and e.g.

  $ lc-compliance -f '*CaptureStartStop/StillCapture__8' -c '\_SB_.PC00.LNK1'
  (which does 3 start-stop sequences)

but I have also extended `cam` to be able to repeat the capture sessions, and that
very clearly shows a start-stop leak:

  before:
    repeat | result
         4 | SUMMARY: AddressSanitizer: 8979617 byte(s) leaked in 72738 allocation(s).
         8 | SUMMARY: AddressSanitizer: 17536873 byte(s) leaked in 144057 allocation(s).
        16 | SUMMARY: AddressSanitizer: 34717529 byte(s) leaked in 286697 allocation(s).
        32 | SUMMARY: AddressSanitizer: 69078457 byte(s) leaked in 571977 allocation(s).

  after:
    repeat | result
        32 | SUMMARY: AddressSanitizer: 487117 byte(s) leaked in 1425 allocation(s).

Barnabás Pőcze (10):
  libcamera: egl: Remove `gl{Use,Delete}Program()`
  libcamera: egl: Remove `eGL::surface_`
  libcamera: egl: Do not load `glGetString` dynamically
  libcamera: egl: Ensure all members are always initialized
  libcamera: egl: Add `resetEGLContext()`
  libcamera: software_isp: debayer_egl: Avoid EGL context leaks
  libcamera: egl: initEGLContext(): Avoid double init
  libcamera: software_isp: debayer_egl: Remove EGL context switch
  libcamera: egl: Make it possible to unmake the context
  libcamera: software_isp: debayer_egl: Unmake EGL context

 include/libcamera/internal/egl.h           | 17 ++--
 src/libcamera/egl.cpp                      | 97 +++++++++-------------
 src/libcamera/software_isp/debayer_egl.cpp |  8 +-
 3 files changed, 49 insertions(+), 73 deletions(-)

--
2.55.0