Android EGL: Synchronize calls to eglCreateContext
Synchronize calls to EGL10/EGL14.eglCreateContext on EglBase.lock. The reason is that a deadlock between the remote render thread in eglSwapBuffers and MediaCodecVideoEncoder eglCreateContext was observed. The function calls that are now synchronized on EglBase.lock are: eglCreateContext, eglMakeCurrent, eglSwapBuffers, and SurfaceTexture.updateTexImage. BUG=webrtc:5702 Review-Url: https://codereview.webrtc.org/1937933002 Cr-Commit-Position: refs/heads/master@{#12603}
This commit is contained in:
@ -289,8 +289,10 @@ final class EglBase10 extends EglBase {
|
||||
int[] contextAttributes = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE};
|
||||
EGLContext rootContext =
|
||||
sharedContext == null ? EGL10.EGL_NO_CONTEXT : sharedContext.eglContext;
|
||||
EGLContext eglContext =
|
||||
egl.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes);
|
||||
final EGLContext eglContext;
|
||||
synchronized (EglBase.lock) {
|
||||
eglContext = egl.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes);
|
||||
}
|
||||
if (eglContext == EGL10.EGL_NO_CONTEXT) {
|
||||
throw new RuntimeException("Failed to create EGL context");
|
||||
}
|
||||
|
||||
@ -246,8 +246,10 @@ public final class EglBase14 extends EglBase {
|
||||
int[] contextAttributes = {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE};
|
||||
EGLContext rootContext =
|
||||
sharedContext == null ? EGL14.EGL_NO_CONTEXT : sharedContext.egl14Context;
|
||||
EGLContext eglContext =
|
||||
EGL14.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes, 0);
|
||||
final EGLContext eglContext;
|
||||
synchronized (EglBase.lock) {
|
||||
eglContext = EGL14.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes, 0);
|
||||
}
|
||||
if (eglContext == EGL14.EGL_NO_CONTEXT) {
|
||||
throw new RuntimeException("Failed to create EGL context");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user