|
75 | 75 | import com.liskovsoft.smartyoutubetv2.tv.ui.common.LeanbackActivity; |
76 | 76 | import com.liskovsoft.smartyoutubetv2.tv.ui.common.UriBackgroundManager; |
77 | 77 | import com.liskovsoft.smartyoutubetv2.tv.ui.mod.leanback.misc.ProgressBarManager; |
| 78 | +import com.liskovsoft.smartyoutubetv2.tv.ui.mod.leanback.playerglue.tweaks.PlaybackTransportRowPresenter; |
78 | 79 | import com.liskovsoft.smartyoutubetv2.tv.ui.playback.mod.SeekModePlaybackFragment; |
79 | 80 | import com.liskovsoft.smartyoutubetv2.tv.ui.playback.mod.surface.SurfacePlaybackFragmentGlueHost; |
80 | 81 | import com.liskovsoft.smartyoutubetv2.tv.ui.playback.other.BackboneQueueNavigator; |
@@ -394,21 +395,46 @@ private void destroyPlayerObjects() { |
394 | 395 | mRowsAdapter.clear(); |
395 | 396 | mRowsAdapter = null; |
396 | 397 | } |
| 398 | + // pollution exo SegmentBase.SegmentTimelineElement 3 million allocation and grown after the player reinstantiation |
| 399 | + setPlaybackRow(null); |
| 400 | + setOnPlaybackItemViewClickedListener(null); |
| 401 | + setHostCallback(null); |
| 402 | + setPlaybackSeekUiClient(null); |
| 403 | + setPlaybackRowPresenter(null); |
| 404 | + setOnKeyInterceptListener(null); |
| 405 | + if (mRowsSupportFragment != null && mRowsSupportFragment.getVerticalGridView() != null) { |
| 406 | + mRowsSupportFragment.getVerticalGridView().setAdapter(null); |
| 407 | + mRowsSupportFragment.getBridgeAdapter().clear(); |
| 408 | + mRowsSupportFragment.getBridgeAdapter().getPresenterMapper().clear(); |
| 409 | + mRowsSupportFragment = null; |
| 410 | + } |
397 | 411 | if (mMediaSessionConnector != null) { |
398 | 412 | mMediaSessionConnector.setPlayer(null); |
| 413 | + mMediaSessionConnector.setControlDispatcher(null); |
| 414 | + mMediaSessionConnector.setMediaMetadataProvider(null); |
| 415 | + mMediaSessionConnector.setQueueNavigator(null); |
399 | 416 | mMediaSessionConnector = null; |
400 | 417 | } |
401 | 418 | if (mMediaSession != null) { |
402 | 419 | mMediaSession.setActive(false); |
403 | 420 | mMediaSession.release(); |
404 | 421 | mMediaSession = null; |
405 | 422 | } |
406 | | - mPlayerGlue = null; |
| 423 | + if (mPlayerGlue != null) { |
| 424 | + ((PlaybackTransportRowPresenter) mPlayerGlue.getPlaybackRowPresenter()).setOnActionLongClickedListener(null); |
| 425 | + ((PlaybackTransportRowPresenter) mPlayerGlue.getPlaybackRowPresenter()).setOnActionClickedListener(null); |
| 426 | + mPlayerGlue.getPlayerAdapter().onDetachedFromHost(); |
| 427 | + mPlayerGlue.setHost(null); |
| 428 | + mPlayerGlue = null; |
| 429 | + } |
| 430 | + if (mDebugInfoManager != null) { |
| 431 | + mDebugInfoManager.show(false); |
| 432 | + mDebugInfoManager = null; |
| 433 | + } |
407 | 434 | // Fix access calls when player isn't initialized |
408 | 435 | mExoPlayerController.release(); |
409 | 436 | mPlayer = null; |
410 | 437 | mSubtitleManager = null; |
411 | | - mDebugInfoManager = null; |
412 | 438 | if (mYouTubeOverlay != null) { |
413 | 439 | mYouTubeOverlay |
414 | 440 | .player(null) |
@@ -573,7 +599,7 @@ private void createMediaSession() { |
573 | 599 |
|
574 | 600 | // NOTE: No way to disable only a notifications. We need to disable the media session instead. |
575 | 601 | boolean disableNotifications = getPlayerTweaksData().isPlaybackNotificationsDisabled(); |
576 | | - mMediaSession = new MediaSessionCompat(getContext(), getContext().getPackageName()); |
| 602 | + mMediaSession = new MediaSessionCompat(getContext().getApplicationContext(), getContext().getPackageName()); // NOTE: mem leak fix (SegmentTimelineElement) |
577 | 603 | mMediaSession.setActive(!disableNotifications); |
578 | 604 | mMediaSessionConnector = new MediaSessionConnector(mMediaSession); |
579 | 605 |
|
|
0 commit comments