[video_player] Improve seek performance on Android#11810
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds the backBufferDurationMs option to VideoPlayerOptions to configure the ExoPlayer back buffer duration on Android, updating the platform interface, Android implementation, and adding no-op stubs for AVFoundation and Web. Feedback on the changes highlights that passing backBufferDurationMs via a global setter on Android can cause state persistence and race conditions during concurrent player initialization, and recommends passing this option directly through CreationOptions instead.
b94d8e4 to
624afd5
Compare
624afd5 to
b75044f
Compare
There was a problem hiding this comment.
Code Review
This pull request adds support for configuring ExoPlayer's back buffer duration on Android by introducing backBufferDurationMs to VideoPlayerOptions and forwarding it through the platform interface to the Android implementation. The Android plugin updates PlatformViewVideoPlayer and TextureVideoPlayer to configure ExoPlayer's DefaultLoadControl using this value, supported by new unit tests. Feedback suggests correcting an inaccurate comment regarding how backBufferDurationMs is passed and adding an assertion to ensure the duration is positive if provided.
54e8d1e to
2f8c779
Compare
2f8c779 to
178a8e1
Compare
178a8e1 to
959dbb3
Compare
mboetger
left a comment
There was a problem hiding this comment.
There's multiple formatting issues with this PR.
| /** | ||
| * The duration of the back buffer in milliseconds, used to configure ExoPlayer's load control. | ||
| */ | ||
| public Long backBufferDurationMs; |
There was a problem hiding this comment.
Why a long? Seems like it's an int everywhere else.
There was a problem hiding this comment.
This is to handle the conversion from dart to java.
We keep as a Long in VideoPlayerOptions.java to maintain alignment with Pigeon's generated CreationOptions object.
We then safely clamp the Long into a int at PlatformViewVideoPlayer.java and TextureVideoPlayer.java to match DefaultLoadControl's expected int parameter.
|
You have a bunch of test failures - both formatting and issues stemming from the versioning. You need to follow the instructions here: https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins if you want the tests to pass and get a proper review |
|
@mboetger Please make sure a PR has all the necessary approvals before requesting that it be split up, as the goal is for the sub-PRs to be trivially approved due to already having all the necessary reviews. This still needs an ecosystem-team-level review for the general API changes. |
tarrinneal
left a comment
There was a problem hiding this comment.
Looks solid to me, feel free to re-break out the sub pr's
649e266 to
3ec63ed
Compare
…#11932) Adds `backBufferDurationMs` to `video_player_platform_interface` This PR has only the platform interface package changes from the main PR: #11810. Following PR split as per [Changing federated plugins](https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins) ## Pre-Review Checklist
|
@stuartmorgan-g @mboetger created another sub PR for android changes: #12124. PTAL |
…flutter#11932) Adds `backBufferDurationMs` to `video_player_platform_interface` This PR has only the platform interface package changes from the main PR: flutter#11810. Following PR split as per [Changing federated plugins](https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins) ## Pre-Review Checklist
…12124) Adds `backBufferDurationMs` to `video_player_android` This PR has only the android package changes from the main PR: #11810. Following PR split as per [Changing federated plugins](https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins) ## Pre-Review Checklist
Adds `backBufferDurationMs` to `VideoPlayerOptions` and configures ExoPlayer's `DefaultLoadControl` to retain the back buffer from keyframes. This significantly improves seek performance and responsiveness during video playback on Android.
1b586ed to
d89834a
Compare
|
I synced to main, dropped the dependency override commits and pushed the commits. |
| version: 2.12.0 | ||
|
|
||
| environment: | ||
| sdk: ^3.10.0 |
There was a problem hiding this comment.
versioning says this will need to be 3.12.0 to merge, I'm not sure that's what we want though @stuartmorgan-g can you weigh in on that?
There was a problem hiding this comment.
Yes, this is expected, and is a common case for our federated plugins. The way it generally plays out is:
- One of the platform implementations has a platform-specific reason to drop N-1/2, often related to some OS or platform tooling change (in this case it looks like it was supporting AGP 9, which required some functionality that's only in current
stable). Our policy is that support forstableis required, but support for N-1/2 is entirely discretionary; packages authors are free to drop them when there's any reason to do so. - That doesn't immediately affect the app-facing package, because the app-facing package is still compatible with older versions of the platform implementation package, and the resolver will do the right thing for people on N-1/2.
- Some later PR that adds a new feature needs to update the min version of the platform implementation to ensure that feature support is present when people try to use it (e.g., this PR). Because there's no longer a compatible platform implementation that supports N-1/2, the app-facing package needs to drop N-1/2 as well.
As a general rule of thumb: if the only thing failing is analyze_legacy, the right thing to do is raise the min SDK version unless the package owner has a compelling reason that they want to support N-1/2.
|
(We'll see if this picks up any new analyzer or formatter behavior that requires other minor changes.) |
Adds
backBufferDurationMstoVideoPlayerOptionsand configures ExoPlayer'sDefaultLoadControlto retain the back buffer from keyframes. This significantly improves seek performance and responsiveness during video playback on Android.iOS already has some kind of back buffering implemented in AVPlayer because the replays and seeks are instantaneous for small videos.
Before:
Replays and seeks on Android for network based video assets involve a network call to fetch the video content. This significantly hampers the user experience.
After:
Replays and seeks on Android (within the back buffer duration) are instant just like in iOS. Improving user experience
This PR partly addresses flutter/flutter#97428. Not enabling back buffering by default and instead allowing the app to configure as per need. The default behavior will be same as the existing implementation to avoid any regressions.
Pre-Review Checklist
[shared_preferences]///).