diff --git a/library/core/src/main/java/com/google/android/exoplayer2/video/VideoFrameReleaseHelper.java b/library/core/src/main/java/com/google/android/exoplayer2/video/VideoFrameReleaseHelper.java index ca6c32270d..b255fdca71 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/video/VideoFrameReleaseHelper.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/video/VideoFrameReleaseHelper.java @@ -620,21 +620,30 @@ public final class VideoFrameReleaseHelper { } private void createChoreographerInstanceInternal() { - choreographer = Choreographer.getInstance(); + 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() { - observerCount++; - if (observerCount == 1) { - checkNotNull(choreographer).postFrameCallback(this); + if (choreographer != null) { + observerCount++; + if (observerCount == 1) { + choreographer.postFrameCallback(this); + } } } private void removeObserverInternal() { - observerCount--; - if (observerCount == 0) { - checkNotNull(choreographer).removeFrameCallback(this); - sampledVsyncTimeNs = C.TIME_UNSET; + if (choreographer != null) { + observerCount--; + if (observerCount == 0) { + choreographer.removeFrameCallback(this); + sampledVsyncTimeNs = C.TIME_UNSET; + } } } }