Handle Choreographer.getInstance throwing RuntimeException
#minor-release PiperOrigin-RevId: 427439588
This commit is contained in:
parent
dc0a293c3f
commit
eb6e25b6fc
@ -622,22 +622,31 @@ public final class VideoFrameReleaseHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createChoreographerInstanceInternal() {
|
private void createChoreographerInstanceInternal() {
|
||||||
|
try {
|
||||||
choreographer = Choreographer.getInstance();
|
choreographer = Choreographer.getInstance();
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
// See [Internal: b/213926330].
|
||||||
|
Log.w(TAG, "Vsync sampling disabled due to platform error", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addObserverInternal() {
|
private void addObserverInternal() {
|
||||||
|
if (choreographer != null) {
|
||||||
observerCount++;
|
observerCount++;
|
||||||
if (observerCount == 1) {
|
if (observerCount == 1) {
|
||||||
checkNotNull(choreographer).postFrameCallback(this);
|
choreographer.postFrameCallback(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeObserverInternal() {
|
private void removeObserverInternal() {
|
||||||
|
if (choreographer != null) {
|
||||||
observerCount--;
|
observerCount--;
|
||||||
if (observerCount == 0) {
|
if (observerCount == 0) {
|
||||||
checkNotNull(choreographer).removeFrameCallback(this);
|
choreographer.removeFrameCallback(this);
|
||||||
sampledVsyncTimeNs = C.TIME_UNSET;
|
sampledVsyncTimeNs = C.TIME_UNSET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user