Skip to content

[video_player_android] Fix rendering freeze after full-screen transit…#11416

Open
moepanda wants to merge 1 commit intoflutter:mainfrom
moepanda:fix_184241_videoplayer_platformview
Open

[video_player_android] Fix rendering freeze after full-screen transit…#11416
moepanda wants to merge 1 commit intoflutter:mainfrom
moepanda:fix_184241_videoplayer_platformview

Conversation

@moepanda
Copy link
Copy Markdown

@moepanda moepanda commented Apr 2, 2026

Fixes flutter/flutter#184241

Description

When using PlatformView mode on Android, the video freezes (frozen on a specific frame) after returning from a full-screen dialog or route transition. This happens because the Surface is destroyed when the view is hidden, and ExoPlayer does not automatically re-attach to the new Surface when it becomes visible again.

Changes

  • Introduced a custom VideoSurfaceView subclass that overrides onVisibilityChanged to re-bind ExoPlayer to the current Surface whenever the view becomes visible again.
  • Extracted a bindPlayerToSurface helper to centralize surface binding and the Android 9 seek workaround.
  • Used clearVideoSurface(surface) in surfaceDestroyed to safely unbind only the current surface.
  • Updated PlatformVideoViewTest to use Robolectric's ShadowSurfaceView API for lifecycle simulation.

Pre-Review Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the AI contribution guidelines and understand my responsibilities, or I am not using AI tools.
  • I read the Tree Hygiene page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter.
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I linked to at least one issue that this PR fixes in the description above.
  • I followed the version and CHANGELOG instructions, using semantic versioning and the repository CHANGELOG style, or I have commented below to indicate which documented exception this PR falls under.
  • I updated/added any relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or I have commented below to indicate which test exemption this PR falls under.
  • All existing and new tests are passing.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@moepanda moepanda force-pushed the fix_184241_videoplayer_platformview branch from bb099a6 to a04a4f7 Compare April 2, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[video_player][android] Video player can't render video view but can play audio

1 participant