-
Notifications
You must be signed in to change notification settings - Fork 6k
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
ExoPlayer set up with Rtmp extension leaks memory when closing the activity with playerView #4249
Comments
There are two parts to this issue:
|
As highlighted by the ref'd issue, we can end up with memory leaks if Loadable.load implementations take a long time to return upon cancelation. This change cuts off one of the two problematic reference chains. This doesn't do much about the ref'd issue, since there's a second reference chain that's much harder to deal with: Thread->LoadTask->loadable. But since it's easy just to cut this one off, I figure it makes sense to do so. Issue: #4249 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=198735386
The bug here was that we'd create a VideoFrameReleaseTimeHelper using whatever context DefaultRenderersFactory has, and it would then hold a reference to that context via DisplayManager. A leak could then occur if the player outlived the life of the context used to create it (which would be strange/unusual, but not impossible). Issue: #4249 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=198747599
If a MediaPeriod uses a Loadable, then there are typically reference chains of the form: LoadingThread[GCroot]->Loadable->MediaPeriod->Player Where the player is the MediaPeriod callback. When the player is released, this reference chain prevents the player from being GC'd until Loadable cancellation completes, which may not always be fast. This in turn will typically prevent the application's activity from being GC'd, since it'll normally be registered as a listener on the player (directly or indirectly via something like a view). This change mitigates the issue by removing references that the MediaPeriod holds back to the player. The MediaPeriod will still not be eligible for GC, but the player and application activity will be, which in most cases will be most of the leak (in terms of size). Issue: #4249 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=199143646
We've made some changes to ExoPlayer that will mitigate the leak. The Leaving the issue open to track picking up a newer version of LibRtmp when the root cause is addressed. |
Great @ojw28 thanks :) |
As highlighted by the ref'd issue, we can end up with memory leaks if Loadable.load implementations take a long time to return upon cancelation. This change cuts off one of the two problematic reference chains. This doesn't do much about the ref'd issue, since there's a second reference chain that's much harder to deal with: Thread->LoadTask->loadable. But since it's easy just to cut this one off, I figure it makes sense to do so. Issue: #4249 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=198735386
The bug here was that we'd create a VideoFrameReleaseTimeHelper using whatever context DefaultRenderersFactory has, and it would then hold a reference to that context via DisplayManager. A leak could then occur if the player outlived the life of the context used to create it (which would be strange/unusual, but not impossible). Issue: #4249 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=198747599
If a MediaPeriod uses a Loadable, then there are typically reference chains of the form: LoadingThread[GCroot]->Loadable->MediaPeriod->Player Where the player is the MediaPeriod callback. When the player is released, this reference chain prevents the player from being GC'd until Loadable cancellation completes, which may not always be fast. This in turn will typically prevent the application's activity from being GC'd, since it'll normally be registered as a listener on the player (directly or indirectly via something like a view). This change mitigates the issue by removing references that the MediaPeriod holds back to the player. The MediaPeriod will still not be eligible for GC, but the player and application activity will be, which in most cases will be most of the leak (in terms of size). Issue: #4249 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=199143646
Issue description
LeakCanary detects a leak when closing activity with PlayerView.
I'm using the ExoPlayer with Rtmp extensions to display the live stream. When the url is invalid (there is no live stream there) the leak occurs.
This is how the releasePlayer method looks like
Version of ExoPlayer being used
2.8.0
The text was updated successfully, but these errors were encountered: