Make sure calling GraphTextureFrame::getTextureName()+::release() on a non-GL thread doesn't result in a crash.
PiperOrigin-RevId: 518359778
This commit is contained in:
parent
88effb19e5
commit
7d26daf723
|
@ -66,7 +66,8 @@ public class GraphTextureFrame implements TextureFrame {
|
||||||
if (nativeBufferHandle == 0) {
|
if (nativeBufferHandle == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (activeConsumerContextHandleSet.add(nativeGetCurrentExternalContextHandle())) {
|
long contextHandle = nativeGetCurrentExternalContextHandle();
|
||||||
|
if (contextHandle != 0 && activeConsumerContextHandleSet.add(contextHandle)) {
|
||||||
// Gpu wait only if deferredSync is true, such as when this GraphTextureFrame is created using
|
// Gpu wait only if deferredSync is true, such as when this GraphTextureFrame is created using
|
||||||
// PacketGetter.getTextureFrameDeferredSync().
|
// PacketGetter.getTextureFrameDeferredSync().
|
||||||
if (deferredSync) {
|
if (deferredSync) {
|
||||||
|
@ -116,7 +117,14 @@ public class GraphTextureFrame implements TextureFrame {
|
||||||
GlSyncToken consumerToken = null;
|
GlSyncToken consumerToken = null;
|
||||||
// Note that this remove should be moved to the other overload of release when b/68808951 is
|
// Note that this remove should be moved to the other overload of release when b/68808951 is
|
||||||
// addressed.
|
// addressed.
|
||||||
if (activeConsumerContextHandleSet.remove(nativeGetCurrentExternalContextHandle())) {
|
final long contextHandle = nativeGetCurrentExternalContextHandle();
|
||||||
|
if (contextHandle == 0 && !activeConsumerContextHandleSet.isEmpty()) {
|
||||||
|
logger.atWarning().log(
|
||||||
|
"GraphTextureFrame is being released on non GL thread while having active consumers,"
|
||||||
|
+ " which may lead to external / internal GL contexts synchronization issues.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contextHandle != 0 && activeConsumerContextHandleSet.remove(contextHandle)) {
|
||||||
consumerToken =
|
consumerToken =
|
||||||
new GraphGlSyncToken(nativeCreateSyncTokenForCurrentExternalContext(nativeBufferHandle));
|
new GraphGlSyncToken(nativeCreateSyncTokenForCurrentExternalContext(nativeBufferHandle));
|
||||||
}
|
}
|
||||||
|
@ -169,7 +177,9 @@ public class GraphTextureFrame implements TextureFrame {
|
||||||
private native void nativeReleaseBuffer(long nativeHandle);
|
private native void nativeReleaseBuffer(long nativeHandle);
|
||||||
|
|
||||||
private native int nativeGetTextureName(long nativeHandle);
|
private native int nativeGetTextureName(long nativeHandle);
|
||||||
|
|
||||||
private native int nativeGetWidth(long nativeHandle);
|
private native int nativeGetWidth(long nativeHandle);
|
||||||
|
|
||||||
private native int nativeGetHeight(long nativeHandle);
|
private native int nativeGetHeight(long nativeHandle);
|
||||||
|
|
||||||
private native void nativeGpuWait(long nativeHandle);
|
private native void nativeGpuWait(long nativeHandle);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user