From b1dda6a02a646967c2fc82fbee2a2a52f0cfb5fc Mon Sep 17 00:00:00 2001 From: olly Date: Mon, 21 Jun 2021 23:31:22 +0100 Subject: [PATCH] Fix DefaultTimeBar glitches The glitches were introduced in: https://github.com/google/ExoPlayer/commit/6c31e34528 The problem is that Listener.onEvents is called in a later looper iteration than the listener methods that were previously used. This created a gap on the main thread between the UI component dispatching a seek operation to the player, and onEvents being called to update the progress bar's position. At the start of this gap the progress bar is rendering the new position, but its position member variable is still set to the old position. If the progress bar is re-drawn by another message on the main thread within the gap, it will briefly show the old position until onEvents is called. There are multiple possible fixes to this, and the best one is probably to modify ListenerSet to remove the gap. That's high risk though, so for now we fix the flicker by always updating the progress immediately after the seek is dispatched, in addition to when onEvents is called. Issue: #9049 #minor-release PiperOrigin-RevId: 380678388 --- RELEASENOTES.md | 2 ++ .../google/android/exoplayer2/ui/PlayerControlView.java | 8 ++------ .../android/exoplayer2/ui/StyledPlayerControlView.java | 8 ++------ 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 7f67596288..1fbce913e7 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -45,6 +45,8 @@ * Fix focusability of `StyledPlayerView` and `StyledPlayerControlView` popup menus on API levels prior to 26 ([#9061](https://github.com/google/ExoPlayer/issues/9061)). + * Fix progress bar flickering immediately after the user seeks + ([#9049](https://github.com/google/ExoPlayer/pull/9049)). * Video: * Fix `IncorrectContextUseViolation` strict mode warning on Android 11 ([#8246](https://github.com/google/ExoPlayer/pull/8246)). diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java index 211dfffc44..cf0b381805 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java @@ -1114,12 +1114,8 @@ public class PlayerControlView extends FrameLayout { } else { windowIndex = player.getCurrentWindowIndex(); } - boolean dispatched = seekTo(player, windowIndex, positionMs); - if (!dispatched) { - // The seek wasn't dispatched then the progress bar scrubber will be in the wrong position. - // Trigger a progress update to snap it back. - updateProgress(); - } + seekTo(player, windowIndex, positionMs); + updateProgress(); } private boolean seekTo(Player player, int windowIndex, long positionMs) { diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java index 389ddd0f97..cc6affa43a 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java @@ -1519,12 +1519,8 @@ public class StyledPlayerControlView extends FrameLayout { } else { windowIndex = player.getCurrentWindowIndex(); } - boolean dispatched = seekTo(player, windowIndex, positionMs); - if (!dispatched) { - // The seek wasn't dispatched then the progress bar scrubber will be in the wrong position. - // Trigger a progress update to snap it back. - updateProgress(); - } + seekTo(player, windowIndex, positionMs); + updateProgress(); } private boolean seekTo(Player player, int windowIndex, long positionMs) {