[video_player] Build an empty view when the player is already disposed - #12405
Open
wilyan09007 wants to merge 1 commit into
Open
[video_player] Build an empty view when the player is already disposed#12405wilyan09007 wants to merge 1 commit into
wilyan09007 wants to merge 1 commit into
Conversation
buildViewWithOptions resolved the player through _playerWith, which throws a StateError when the id is no longer in _players. Disposal and the next frame are not synchronized, so a widget holding a disposed player can still be rebuilt -- an AnimatedSwitcher transition, or a rebuild triggered by a configuration change once the platform has reclaimed the player. Throwing from a build method leaves the video widget permanently broken rather than simply rendering nothing. Look the player up directly and build an empty view when it is gone, on both the Android and AVFoundation implementations.
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates both the Android and AVFoundation implementations of the video_player plugin to return an empty view (SizedBox.shrink()) instead of throwing a StateError when building a view for a disposed player. It also includes corresponding unit tests and version bumps for both packages. There are no review comments, and I have no feedback to provide.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
buildViewWithOptionsresolves the player through_playerWith, which throws aStateErrorwhen the id is no longer present in_players. Disposal and the next frame are not synchronized, so a widget still holding a disposed player can be rebuilt during anAnimatedSwitchertransition, or by a rebuild that a configuration change triggers once the platform has reclaimed the player. Because this runs insidebuild, the throw leaves the video view permanently broken rather than simply rendering nothing.Both platform implementations now look the player up directly and build an empty view when it is gone.
Fixes flutter/flutter#190739
Pre-Review Checklist
[shared_preferences]///).Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2