Skip to content

fix(android): call cleanup on view drop to prevent resource leaks#201

Open
Yoon-Hae-Min wants to merge 1 commit intoaws:mainfrom
Yoon-Hae-Min:fix/android-cleanup-on-drop-view
Open

fix(android): call cleanup on view drop to prevent resource leaks#201
Yoon-Hae-Min wants to merge 1 commit intoaws:mainfrom
Yoon-Hae-Min:fix/android-cleanup-on-drop-view

Conversation

@Yoon-Hae-Min
Copy link
Copy Markdown

Currently, AmazonIvsView.cleanup() is only called from onHostDestroy, which is tied to the Android Activity lifecycle. When a React component is unmounted (e.g. navigating away via React Navigation), the Activity remains alive — so onHostDestroy is never called, and player resources (IVS player instance, listeners, background service, preloaded sources, timers, broadcast receivers) are never released.

In our production app, we observed that player resources were not being released when the component was unmounted, causing resource leaks.

This adds an onDropViewInstance override in AmazonIvsViewManager to call cleanup() when React drops the native view.

`AmazonIvsView.cleanup()` was only called from `onHostDestroy`, meaning
that when the React view was removed (e.g. navigating away) without the
host being destroyed, player resources (listeners, observers, background
service, preloaded sources) were never released.

Override `onDropViewInstance` in `AmazonIvsViewManager` to ensure
`cleanup()` is called when the native view is dropped by React.
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.

1 participant