From e229e5355d60991721626c4cbbaff1a3d9fb817a Mon Sep 17 00:00:00 2001 From: Stypox Date: Sun, 28 Mar 2021 23:05:31 +0200 Subject: [PATCH] Always create new bitmap when resizing thumbnail This prevents strange crashes on some devices, fixes #4638 --- .../java/org/schabi/newpipe/player/Player.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index 72540453d..403132116 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -1243,10 +1243,21 @@ public final class Player implements / (source.getWidth() / notificationThumbnailWidth)), true); - if (result != source) { + if (result == source) { + // create a new mutable bitmap to prevent strange crashes on some + // devices (see #4638) + final Bitmap copied = Bitmap.createScaledBitmap( + source, + (int) notificationThumbnailWidth - 1, + (int) (source.getHeight() / (source.getWidth() + / (notificationThumbnailWidth - 1))), + true); source.recycle(); + return copied; + } else { + source.recycle(); + return result; } - return result; } @Override