Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): fix leak caused by removing lifecycle listener too early #3380

Merged
merged 2 commits into from
Nov 23, 2023

Conversation

BasixKOR
Copy link
Contributor

This PR fixes some cases where the lifecycle event listeners are removed before it receives onHostDestroy, causing the app to not release the resource when some other methods such as setBufferConfig.

Possible leak scenario

  1. <Video /> mounts. ReactExoplayerView is created.
  2. bufferConfig prop is changed, calling the ReactExoplayerViewManager.setBufferConfig, ReactExoplayerView.setBufferConfig, ReactExoplayerView.releasePlayer in order.
  3. releasePlayer removes the activity lifecycle listener, causing it to not receive onHostDestroy properly.
  4. After activity is destroyed, the view doesn't know it's destroyed due to the listener removal, causing it to hold the resources that should be handled by releasePlayer.

@BasixKOR BasixKOR changed the title Fix lifecycle listener being removed too early android: fix leak caused by removing lifecycle listener too early Nov 23, 2023
@BasixKOR BasixKOR changed the title android: fix leak caused by removing lifecycle listener too early fix(android): fix leak caused by removing lifecycle listener too early Nov 23, 2023
@freeboub
Copy link
Collaborator

It make sense, looks like it will fix a lot of strange behavior !
Thank you

@freeboub freeboub merged commit 0c0f317 into TheWidlarzGroup:master Nov 23, 2023
1 check passed
@BasixKOR BasixKOR deleted the fix/onhostdestory-leak branch November 24, 2023 18:14
@YangJonghun
Copy link
Collaborator

YangJonghun commented Jan 19, 2024

@BasixKOR
안녕하세요!
I made simple PR because there is a bug that doesn't do lifecycle unsubscribe when component unmount.
It would be nice if you could review it together to see if there is a problem. :)

PR #3489

JasonZhuSky pushed a commit to skytvnz/react-native-video that referenced this pull request Apr 25, 2024
JasonZhuSky added a commit to skytvnz/react-native-video that referenced this pull request Apr 25, 2024
JasonZhuSky pushed a commit to skytvnz/react-native-video that referenced this pull request Apr 25, 2024
JasonZhuSky added a commit to skytvnz/react-native-video that referenced this pull request Apr 25, 2024
TheWidlarzGroup#3380) (#95)

* Fix lifecycle listener being removed too early

Co-authored-by: Sung Jeon <basix@basix.tech>
JasonZhuSky pushed a commit to skytvnz/react-native-video that referenced this pull request May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants