Move waitOnCpu and waitOnGpu out of the synchronized block, which can cause deadlock.
PiperOrigin-RevId: 549217916
This commit is contained in:
parent
4e72fcf0cb
commit
085840388b
|
@ -78,17 +78,21 @@ public class AppTextureFrame implements TextureFrame {
|
|||
* Use {@link waitUntilReleasedWithGpuSync} whenever possible.
|
||||
*/
|
||||
public void waitUntilReleased() throws InterruptedException {
|
||||
GlSyncToken tokenToRelease = null;
|
||||
synchronized (this) {
|
||||
while (inUse && releaseSyncToken == null) {
|
||||
wait();
|
||||
}
|
||||
if (releaseSyncToken != null) {
|
||||
releaseSyncToken.waitOnCpu();
|
||||
releaseSyncToken.release();
|
||||
tokenToRelease = releaseSyncToken;
|
||||
inUse = false;
|
||||
releaseSyncToken = null;
|
||||
}
|
||||
}
|
||||
if (tokenToRelease != null) {
|
||||
tokenToRelease.waitOnCpu();
|
||||
tokenToRelease.release();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,17 +102,21 @@ public class AppTextureFrame implements TextureFrame {
|
|||
* TextureFrame.
|
||||
*/
|
||||
public void waitUntilReleasedWithGpuSync() throws InterruptedException {
|
||||
GlSyncToken tokenToRelease = null;
|
||||
synchronized (this) {
|
||||
while (inUse && releaseSyncToken == null) {
|
||||
wait();
|
||||
}
|
||||
if (releaseSyncToken != null) {
|
||||
releaseSyncToken.waitOnGpu();
|
||||
releaseSyncToken.release();
|
||||
tokenToRelease = releaseSyncToken;
|
||||
inUse = false;
|
||||
releaseSyncToken = null;
|
||||
}
|
||||
}
|
||||
if (tokenToRelease != null) {
|
||||
tokenToRelease.waitOnGpu();
|
||||
tokenToRelease.release();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user