I am working with lazyGrid from android-compose to display a grid of videos like bellow
and I am showing the video feed using a custom view from a third party library.
For now everything works well, problems come when I try to reorder video tiles (eg. last one take place of first and so on): Some videos become frozen and some others become green.
and this is what I see on the log
E/libEGL: eglMakeCurrentImpl:1038 error 3002 (EGL_BAD_ACCESS)
E/Render: eglMakeCurrent failed
E/Render: EGL error = 0x3002
E/Render: cannot swap buffers!
Screen:
LazyVerticalGrid(
...
) {
items(items = members, key = { id }) { member ->
val context = LocalContext.current
AndroidView(factory = {
Renderer(context, ...).apply {
layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)
}
}
}
Custom view:
public class Renderer extends TextureView implements TextureView.SurfaceTextureListener {
private SurfaceTexture mSurface;
private EGLDisplay mEglDisplay;
private EGLSurface mEglSurface;
private EGLContext mEglContext;
private EGL10 mEgl;
private EGLConfig eglConfig;
private GL10 mGl;
... //some code for creating the surface
}
Any ideas please ? what can cause the EGL_BAD_ACCESS and buffers issues ?
I don't have good knowledge on open-gl
So the issue is happening because I am creating multiple TextureView
s on top each others which the TextureView
does not allow. I need to disconnect the old TextureView
from the parent before creating new one or moving other on top of it.
The solution is to use SurfaceView
view instead of TextureView