Skip to content

Commit

Permalink
Remove additional (harmless but annoying) native stack traces. (#7837)
Browse files Browse the repository at this point in the history
  • Loading branch information
matanlurey authored Oct 9, 2024
1 parent 0a3d9fc commit f1a3da2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
8 changes: 8 additions & 0 deletions packages/video_player/video_player_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 2.7.12

* Fixes a [bug](https://github.com/flutter/flutter/issues/156451) where
additional harmless but annoying warnings in the form of native stack traces
would be printed when the app was backgrounded. There may be additional
warnings that are not yet fixed, but this should address the
most common case.

## 2.7.11

* Fixes a [bug](https://github.com/flutter/flutter/issues/156158) where a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ public void onSurfaceCreated() {

@RestrictTo(RestrictTo.Scope.LIBRARY)
public void onSurfaceDestroyed() {
exoPlayer.stop();
// Intentionally do not call pause/stop here, because the surface has already been released
// at this point (see https://github.com/flutter/flutter/issues/156451).
savedStateDuring = ExoPlayerState.save(exoPlayer);
exoPlayer.release();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,21 @@ public void onSurfaceProducerDestroyedAndRecreatedReleasesAndThenRecreatesAndRes
videoPlayer.dispose();
}

@Test
public void onSurfaceProducerDestroyedDoesNotStopOrPauseVideo() {
VideoPlayer videoPlayer = createVideoPlayer();

verify(mockProducer).setCallback(callbackCaptor.capture());
TextureRegistry.SurfaceProducer.Callback producerLifecycle = callbackCaptor.getValue();
producerLifecycle.onSurfaceDestroyed();

verify(mockExoPlayer, never()).stop();
verify(mockExoPlayer, never()).pause();
verify(mockExoPlayer, never()).setPlayWhenReady(anyBoolean());

videoPlayer.dispose();
}

@Test
public void onDisposeSurfaceProducerCallbackIsDisconnected() {
// Regression test for https://github.com/flutter/flutter/issues/156158.
Expand Down Expand Up @@ -289,7 +304,7 @@ public void disposeReleasesExoPlayerBeforeTexture() {

// TODO(matanlurey): Replace with inline calls to onSurfaceAvailable once
// available on stable; see https://github.com/flutter/flutter/issues/155131.
// This seperate method only exists to scope the suppression.
// This separate method only exists to scope the suppression.
@SuppressWarnings({"deprecation", "removal"})
void simulateSurfaceCreation(TextureRegistry.SurfaceProducer.Callback producerLifecycle) {
producerLifecycle.onSurfaceCreated();
Expand Down
2 changes: 1 addition & 1 deletion packages/video_player/video_player_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: video_player_android
description: Android implementation of the video_player plugin.
repository: https://github.com/flutter/packages/tree/main/packages/video_player/video_player_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
version: 2.7.11
version: 2.7.12

environment:
sdk: ^3.5.0
Expand Down

0 comments on commit f1a3da2

Please sign in to comment.