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() {
|
||||
try {
|
||||
choreographer = Choreographer.getInstance();
|
||||
} catch (RuntimeException e) {
|
||||
// See [Internal: b/213926330].
|
||||
Log.w(TAG, "Vsync sampling disabled due to platform error", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void addObserverInternal() {
|
||||
if (choreographer != null) {
|
||||
observerCount++;
|
||||
if (observerCount == 1) {
|
||||
checkNotNull(choreographer).postFrameCallback(this);
|
||||
choreographer.postFrameCallback(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeObserverInternal() {
|
||||
if (choreographer != null) {
|
||||
observerCount--;
|
||||
if (observerCount == 0) {
|
||||
checkNotNull(choreographer).removeFrameCallback(this);
|
||||
choreographer.removeFrameCallback(this);
|
||||
sampledVsyncTimeNs = C.TIME_UNSET;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user