Fix a deadlock in EglRenderer.releaseEglSurface.
Main thread is waiting for an operation on the render thread to complete while holding the handler lock. Something can be waiting on the render thread for this lock. This CL changes the behaviour so that the lock is released before waiting for the operation to complete. BUG=webrtc:6602,webrtc:6470 R=magjed@webrtc.org Review-Url: https://codereview.webrtc.org/2449693003 Cr-Commit-Position: refs/heads/master@{#14773}
This commit is contained in:
parent
2d81eb33f5
commit
d0af5c6fd4
@ -380,23 +380,28 @@ public class EglRenderer implements VideoRenderer.Callbacks {
|
||||
* Release EGL surface. This function will block until the EGL surface is released.
|
||||
*/
|
||||
public void releaseEglSurface() {
|
||||
final CountDownLatch completionLatch = new CountDownLatch(1);
|
||||
// Ensure that the render thread is no longer touching the Surface before returning from this
|
||||
// function.
|
||||
eglSurfaceCreationRunnable.setSurface(null /* surface */);
|
||||
synchronized (handlerLock) {
|
||||
if (renderThreadHandler != null) {
|
||||
renderThreadHandler.removeCallbacks(eglSurfaceCreationRunnable);
|
||||
ThreadUtils.invokeAtFrontUninterruptibly(renderThreadHandler, new Runnable() {
|
||||
renderThreadHandler.postAtFrontOfQueue(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (eglBase != null) {
|
||||
eglBase.detachCurrent();
|
||||
eglBase.releaseSurface();
|
||||
}
|
||||
completionLatch.countDown();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
completionLatch.countDown();
|
||||
}
|
||||
}
|
||||
ThreadUtils.awaitUninterruptibly(completionLatch);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user