[video_player_android] Fix rendering freeze after full-screen transit…#11416
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the video_player_android package to version 2.9.6 and addresses a bug where videos freeze after returning from full-screen transitions. The changes introduce a custom VideoSurfaceView that re-binds the ExoPlayer to the surface upon visibility changes and refactors surface management to use a manual binding process with a seek-based workaround for Android 9 rendering issues. Review feedback suggests optimizing the seek operation by checking if the player is already playing to avoid performance stutters and refining the visibility check in onVisibilityChanged with isShown() to prevent redundant surface bindings.
bb099a6 to
a04a4f7
Compare
| // Workaround for a rendering bug on Android 9 (API 28) where the decoder does not | ||
| // flush its output buffer when a new surface is attached while the player is paused, | ||
| // resulting in a black frame. A seek forces the codec to produce and display a frame. | ||
| if (!exoPlayer.getPlayWhenReady()) { |
There was a problem hiding this comment.
This changes the seekTo triggering - how sure are you that we want to do that?
There was a problem hiding this comment.
This changes the seekTo triggering - how sure are you that we want to do that?
Thanks, that’s a good callout.
I’ve narrowed this back down so that the Android 9 seekTo(...) workaround remains only in surfaceCreated, where that compatibility logic originally existed. onVisibilityChanged(...) now only rebinds the player to the current surface and does not trigger any extra seek.
The goal here is to fix the fullscreen-return case without broadening seekTo(...) behavior across other devices. In my testing, the surface rebind was sufficient on non-Android 9 devices, so I removed the extra seek from that path.
7b08be3 to
ae174bf
Compare
mboetger
left a comment
There was a problem hiding this comment.
Sorry I didn't get to this sooner - thank you for the PR
|
Looks like some formatting issues with the code. |
Please take a look. |
|
@mboetger Could you add a secondary reviewer from the Android team, since this only involves the Android implementation internals? |
camsim99
left a comment
There was a problem hiding this comment.
LGTM, thanks for the fixes! I think a versioning bump is needed, though.
6aff617 to
86fe0b8
Compare
86fe0b8 to
46bc007
Compare
…#188565) flutter/packages@af136cc...7ff3e1f 2026-06-24 14008334+moepanda@users.noreply.github.com [video_player_android] Fix rendering freeze after full-screen transit… (flutter/packages#11416) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Resolves video_player conflicts between the fork's custom work and upstream: - Pigeon API (video_player_instance_messages): union of the fork's ABR control (PlatformVideoQuality, getAvailableQualities/getCurrentQuality/ setMaxBitrate/setMaxResolution) and upstream's video track selection (flutter#11476: MediaSelection/Asset/NativeVideoTrackData, getVideoTracks/ selectVideoTrack). Generated .g.dart/.g.m/.g.h regenerated via pigeon. - avfoundation_video_player.dart: kept both override sets. - PlatformVideoView.java: took upstream's VideoSurfaceView fix (flutter#11416) and kept the fork's exoPlayer field used by dispose(). - pubspec.yaml (avf/web/example): kept path: dependency on the local video_player_platform_interface (fork has unpublished interface methods); took upstream version bump 2.10.0 and web: ^1.0.0. - CHANGELOG: folded the fork's backgrounding-crash fix into 2.10.0. - pkg_web_tweaks.dart: aligned with upstream (flutter#11820) to reduce divergence. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Fixes flutter/flutter#184241
Description
When using
PlatformViewmode on Android, the video freezes (frozen on a specific frame) after returning from a full-screen dialog or route transition. This happens because theSurfaceis destroyed when the view is hidden, andExoPlayerdoes not automatically re-attach to the newSurfacewhen it becomes visible again.Changes
VideoSurfaceViewsubclass that overridesonVisibilityChangedto re-bindExoPlayerto the currentSurfacewhenever the view becomes visible again.bindPlayerToSurfacehelper to centralize surface binding and the Android 9 seek workaround.clearVideoSurface(surface)insurfaceDestroyedto safely unbind only the current surface.PlatformVideoViewTestto use Robolectric'sShadowSurfaceViewAPI for lifecycle simulation.Pre-Review Checklist
[shared_preferences]///).