From 0c0f3174cb37d3c664a345ea00fcbaafffcd4b10 Mon Sep 17 00:00:00 2001 From: Sung Jeon Date: Fri, 24 Nov 2023 07:23:44 +0900 Subject: [PATCH] fix(android): fix leak caused by removing lifecycle listener too early (#3380) * Fix lifecycle listener being removed too early --- CHANGELOG.md | 6 ++++-- .../java/com/brentvatne/exoplayer/ReactExoplayerView.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2118fbd0..73a623cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ +# [6.0.0-beta.1](https://github.com/react-native-video/react-native-video/compare/v6.0.0-beta.0...v6.0.0-beta.1) (WIP) +* **android:** fix leak caused by removing lifecycle listener too early ([#3380](https://github.com/react-native-video/react-native-video/pull/3380)) # [6.0.0-beta.0](https://github.com/react-native-video/react-native-video/compare/v6.0.0-alpha.11...v6.0.0-beta.0) (2023-11-18) @@ -56,7 +58,7 @@ - iOS: Fix audio session category when not using the audioOutput prop - iOS: implement onPlaybackStateChanged callback [#3307](https://github.com/react-native-video/react-native-video/pull/3307) - iOS: remove false calls at onPlaybackRateChange [#3306](https://github.com/react-native-video/react-native-video/pull/3306) -- iOS: audio does not work with headphones [#3284](https://github.com/react-native-video/react-native-video/pull/3284) +- iOS: audio does not work with headphones [#3284](https://github.com/react-native-video/react-native-video/pull/3284) - iOS: Resuming video ad after closing the in-app browser on iOS [#3275](https://github.com/react-native-video/react-native-video/pull/3275) - iOS, Android: expose playback functions to ref [#3245](https://github.com/react-native-video/react-native-video/pull/3245) - tvOS: fix build: [#3276](https://github.com/react-native-video/react-native-video/pull/3276) @@ -387,4 +389,4 @@ - Add cookie support for ExoPlayer [#922](https://github.com/react-native-community/react-native-video/pull/922) - Remove ExoPlayer onMetadata that wasn't being used [#1040](https://github.com/react-native-community/react-native-video/pull/1040) - Fix bug where setting the progress interval on iOS didn't work [#800](https://github.com/react-native-community/react-native-video/pull/800) -- Support setting the poster resize mode [#595](https://github.com/react-native-community/react-native-video/pull/595) \ No newline at end of file +- Support setting the poster resize mode [#595](https://github.com/react-native-community/react-native-video/pull/595) diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 903705ca..ab11643c 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -349,6 +349,7 @@ public class ReactExoplayerView extends FrameLayout implements @Override public void onHostDestroy() { stopPlayback(); + themedReactContext.removeLifecycleEventListener(this); } public void cleanUpResources() { @@ -881,7 +882,6 @@ public class ReactExoplayerView extends FrameLayout implements } adsLoader = null; progressHandler.removeMessages(SHOW_PROGRESS); - themedReactContext.removeLifecycleEventListener(this); audioBecomingNoisyReceiver.removeListener(); bandwidthMeter.removeEventListener(this);