Skip to content

Commit 61ed839

Browse files
[video_player] Try to address test flake (#6899)
This attempts to address two sources of flake: - A test that playing doesn't continue past the duration flakily fails, at least on Android, with a position a small amount past the duration. This seems like an unexpected library behavior that we wouldn't want to expose to clients, so rather than change the test, this makes the logic that updates the `Value` clamp the position to the duration. - A test that asset videos play has been restructured to actually wait for the future that should start playing to complete before checking whether it's playing. The test was previously not actually waiting for anything other than animations to complete, and there's no reason the placeholder layout couldn't have completed before the asset loaded. The fact that the test was already disabled for iOS is strong evidence that the flake we are seeing on Android is a problem with the test itself, so hopefully this addresses both platforms. Fixes flutter/flutter#86915
1 parent 80f0e16 commit 61ed839

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

packages/video_player/video_player/CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 2.8.7
22

3+
* Ensures that `value.position` never reports a value larger than `value.duration`.
34
* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.
45

56
## 2.8.6

packages/video_player/video_player/example/integration_test/video_player_test.dart

+5-3
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,11 @@ void main() {
194194

195195
testWidgets('test video player view with local asset',
196196
(WidgetTester tester) async {
197+
final Completer<void> loaded = Completer<void>();
197198
Future<bool> started() async {
198199
await controller.initialize();
199200
await controller.play();
201+
loaded.complete();
200202
return true;
201203
}
202204

@@ -221,12 +223,12 @@ void main() {
221223
),
222224
));
223225

226+
await loaded.future;
224227
await tester.pumpAndSettle();
225228
expect(controller.value.isPlaying, true);
226229
},
227-
skip: kIsWeb || // Web does not support local assets.
228-
// Extremely flaky on iOS: https://github.com/flutter/flutter/issues/86915
229-
defaultTargetPlatform == TargetPlatform.iOS);
230+
// Web does not support local assets.
231+
skip: kIsWeb);
230232
});
231233

232234
group('file-based videos', () {

packages/video_player/video_player/lib/video_player.dart

+6
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,12 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
743743
}
744744

745745
void _updatePosition(Duration position) {
746+
// The underlying native implementation on some platforms sometimes reports
747+
// a position slightly past the reported max duration. Clamp to the duration
748+
// to insulate clients from this behavior.
749+
if (position > value.duration) {
750+
position = value.duration;
751+
}
746752
value = value.copyWith(
747753
position: position,
748754
caption: _getCaptionAt(position),

packages/video_player/video_player/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for displaying inline video with other Flutter
33
widgets on Android, iOS, and web.
44
repository: https://github.com/flutter/packages/tree/main/packages/video_player/video_player
55
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
6-
version: 2.8.6
6+
version: 2.8.7
77

88
environment:
99
sdk: ">=3.2.3 <4.0.0"

0 commit comments

Comments
 (0)