From 762f374f9330c054a5cbf37726a7af267d9e446a Mon Sep 17 00:00:00 2001 From: John Zhen Mo Date: Sun, 18 Feb 2018 00:26:53 -0800 Subject: [PATCH] -Fixed media source manager sync identical item multiple times, causing OOM. -Removed deprecated translated leak canary string from other languages. --- .../player/playback/MediaSourceManager.java | 21 +++++++++++-------- app/src/main/res/values-de/strings.xml | 1 - app/src/main/res/values-it/strings.xml | 1 - app/src/main/res/values-nb-rNO/strings.xml | 1 - app/src/main/res/values-nl/strings.xml | 1 - app/src/main/res/values-pt-rBR/strings.xml | 1 - app/src/main/res/values-tr/strings.xml | 1 - 7 files changed, 12 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/playback/MediaSourceManager.java b/app/src/main/java/org/schabi/newpipe/player/playback/MediaSourceManager.java index baf2b9c29..a4438af70 100644 --- a/app/src/main/java/org/schabi/newpipe/player/playback/MediaSourceManager.java +++ b/app/src/main/java/org/schabi/newpipe/player/playback/MediaSourceManager.java @@ -105,6 +105,7 @@ public class MediaSourceManager { playQueueReactor = null; syncReactor = null; + syncedItem = null; sources = null; } @@ -124,6 +125,8 @@ public class MediaSourceManager { * */ public void reset() { tryBlock(); + + syncedItem = null; populateSources(); } /*////////////////////////////////////////////////////////////////////////// @@ -243,20 +246,20 @@ public class MediaSourceManager { syncInternal(currentItem, null); }; - final Disposable sync = currentItem.getStream() - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(onSuccess, onError); - syncReactor.add(sync); + if (syncedItem != currentItem) { + syncedItem = currentItem; + final Disposable sync = currentItem.getStream() + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(onSuccess, onError); + syncReactor.add(sync); + } } private void syncInternal(@android.support.annotation.NonNull final PlayQueueItem item, @Nullable final StreamInfo info) { if (playQueue == null || playbackListener == null) return; - - // Sync each new item once only and ensure the current item is up to date - // with the play queue - if (playQueue.getItem() != syncedItem && playQueue.getItem() == item) { - syncedItem = item; + // Ensure the current item is up to date with the play queue + if (playQueue.getItem() == item && playQueue.getItem() == syncedItem) { playbackListener.sync(syncedItem,info); } } diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 8e9821b10..171cc5ee0 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -373,5 +373,4 @@ Keine Untertitel Schriftgröße der Untertitel - "Speicherlecks nachverfolgen " diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 4d2f8a10e..afdb6efd0 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -395,7 +395,6 @@ Carattere normale Carattere più grande - Controllo delle perdite Controllo delle perdite di memoria abilitato, l\'applicazione può non rispondere mentre effettua il dumping dell\'heap Controllo delle perdite di memoria disabilitato A breve qualcosa si troverà qui ;D diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index 9c1e21a36..9f8762827 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -383,7 +383,6 @@ Normal skrift Større skrift - Hold oppsyn med lekkasjer Oppsyn med minnelekasjer påslått, programmet kan slutte å svare under haug-dumping Oppsyn med minnelekasjer slått av diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 6ab9a5b41..bb9e07f2c 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -391,7 +391,6 @@ te openen in pop-upmodus Normaal lettertype Groter lettertype - Controleren op lekken Controleren op geheugenlekken ingeschakeld, tijdens heapdumping kan de app tijdelijk niet reageren Controleren op geheugenlekken uitgeschakeld Hier zal binnenkort iets verschijnen ;D diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 83f6ee085..81a7456a9 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -369,7 +369,6 @@ abrir em modo popup Fonte normal Maior fonte - Monitorar vazamentos de memória Monitoramento de vazamentos de memória habilitado, o aplicativo pode ficar sem responder quando estiver descarregando pilha de memória Monitoramento de vazamentos de memória desabilitado diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 19d47f880..37542a332 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -385,7 +385,6 @@ Olağan Yazı Tipi Büyük Yazı Tipi - Sızıntıları Gözlemle Bellek sızıntısı gözlemleme etkinleştirildi, uygulama yığın atımı sırasında yanıtsız kalabilir Bellek sızıntısı gözlemleme devre dışı