[RFC,v1,10/10] libcamera: software_isp: debayer_egl: Unmake EGL context
diff mbox series

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

Commit Message

Barnabás Pőcze Aug. 4, 2026, 10:19 a.m. UTC
In `SoftwareIsp`, the worker thread is recreated each time it is started.
In order to avoid any potential leaks from the egl implementation, remove
the currently bound egl context in `DebayerEGL::stop()`.

Mesa does not seem to have any destructors for its egl thread data,
so the context in those cases does not seem to be properly destroyed.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/libcamera/software_isp/debayer_egl.cpp | 1 +
 1 file changed, 1 insertion(+)

Comments

Milan Zamazal Aug. 5, 2026, 11:36 a.m. UTC | #1
Barnabás Pőcze <barnabas.pocze@ideasonboard.com> writes:

> In `SoftwareIsp`, the worker thread is recreated each time it is started.
> In order to avoid any potential leaks from the egl implementation, remove
> the currently bound egl context in `DebayerEGL::stop()`.

Should it be perhaps done in resetEGLContext, the counterpart of
initEGLContext, where the context is set?

> Mesa does not seem to have any destructors for its egl thread data,
> so the context in those cases does not seem to be properly destroyed.
>
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>  src/libcamera/software_isp/debayer_egl.cpp | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp
> index afc6b02748..3405cdd56a 100644
> --- a/src/libcamera/software_isp/debayer_egl.cpp
> +++ b/src/libcamera/software_isp/debayer_egl.cpp
> @@ -680,6 +680,7 @@ void DebayerEGL::stop()
>  	if (programId_)
>  		glDeleteProgram(programId_);
>  
> +	egl_.makeCurrent(false);
>  	egl_.resetEGLContext();
>  }
Barnabás Pőcze Aug. 5, 2026, 12:59 p.m. UTC | #2
2026. 08. 05. 13:36 keltezéssel, Milan Zamazal írta:
> Barnabás Pőcze <barnabas.pocze@ideasonboard.com> writes:
> 
>> In `SoftwareIsp`, the worker thread is recreated each time it is started.
>> In order to avoid any potential leaks from the egl implementation, remove
>> the currently bound egl context in `DebayerEGL::stop()`.
> 
> Should it be perhaps done in resetEGLContext, the counterpart of
> initEGLContext, where the context is set?

Good point, I initially did not want to do that because the context
should be destroy-able from a different thread, as far as I'm aware.

But given the very narrow use cases here, and that it would make it a perfect
"inverse" of `initEGLContext()`, I'll try to do it.

And then I suppose the modification to `makeCurrent()` won't be needed.


> 
>> Mesa does not seem to have any destructors for its egl thread data,
>> so the context in those cases does not seem to be properly destroyed.
>>
>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
>> ---
>>   src/libcamera/software_isp/debayer_egl.cpp | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp
>> index afc6b02748..3405cdd56a 100644
>> --- a/src/libcamera/software_isp/debayer_egl.cpp
>> +++ b/src/libcamera/software_isp/debayer_egl.cpp
>> @@ -680,6 +680,7 @@ void DebayerEGL::stop()
>>   	if (programId_)
>>   		glDeleteProgram(programId_);
>>   
>> +	egl_.makeCurrent(false);
>>   	egl_.resetEGLContext();
>>   }
>

Patch
diff mbox series

diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp
index afc6b02748..3405cdd56a 100644
--- a/src/libcamera/software_isp/debayer_egl.cpp
+++ b/src/libcamera/software_isp/debayer_egl.cpp
@@ -680,6 +680,7 @@  void DebayerEGL::stop()
 	if (programId_)
 		glDeleteProgram(programId_);
 
+	egl_.makeCurrent(false);
 	egl_.resetEGLContext();
 }