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.
|
* Use {@link waitUntilReleasedWithGpuSync} whenever possible.
|
||||||
*/
|
*/
|
||||||
public void waitUntilReleased() throws InterruptedException {
|
public void waitUntilReleased() throws InterruptedException {
|
||||||
|
GlSyncToken tokenToRelease = null;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
while (inUse && releaseSyncToken == null) {
|
while (inUse && releaseSyncToken == null) {
|
||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
if (releaseSyncToken != null) {
|
if (releaseSyncToken != null) {
|
||||||
releaseSyncToken.waitOnCpu();
|
tokenToRelease = releaseSyncToken;
|
||||||
releaseSyncToken.release();
|
|
||||||
inUse = false;
|
inUse = false;
|
||||||
releaseSyncToken = null;
|
releaseSyncToken = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (tokenToRelease != null) {
|
||||||
|
tokenToRelease.waitOnCpu();
|
||||||
|
tokenToRelease.release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,17 +102,21 @@ public class AppTextureFrame implements TextureFrame {
|
||||||
* TextureFrame.
|
* TextureFrame.
|
||||||
*/
|
*/
|
||||||
public void waitUntilReleasedWithGpuSync() throws InterruptedException {
|
public void waitUntilReleasedWithGpuSync() throws InterruptedException {
|
||||||
|
GlSyncToken tokenToRelease = null;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
while (inUse && releaseSyncToken == null) {
|
while (inUse && releaseSyncToken == null) {
|
||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
if (releaseSyncToken != null) {
|
if (releaseSyncToken != null) {
|
||||||
releaseSyncToken.waitOnGpu();
|
tokenToRelease = releaseSyncToken;
|
||||||
releaseSyncToken.release();
|
|
||||||
inUse = false;
|
inUse = false;
|
||||||
releaseSyncToken = null;
|
releaseSyncToken = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (tokenToRelease != null) {
|
||||||
|
tokenToRelease.waitOnGpu();
|
||||||
|
tokenToRelease.release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user