diff --git a/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java b/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java index db1b1a13f1..16a44aa016 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java @@ -762,12 +762,12 @@ public class SimpleExoPlayer implements ExoPlayer { } } if (this.surface != null && this.surface != surface) { - // If we created this surface, we are responsible for releasing it. + // We're replacing a surface. Block to ensure that it's not accessed after the method returns. + player.blockingSendMessages(messages); + // If we created the previous surface, we are responsible for releasing it. if (this.ownsSurface) { this.surface.release(); } - // We're replacing a surface. Block to ensure that it's not accessed after the method returns. - player.blockingSendMessages(messages); } else { player.sendMessages(messages); }