From 693c9d97d49e8745fe46f954854d53622d74ca6d Mon Sep 17 00:00:00 2001 From: TechQI Date: Mon, 8 Aug 2022 12:20:19 +0800 Subject: [PATCH 1/3] Fix ImageAssetManager.bitmapForId NPE crash --- .../java/com/airbnb/lottie/manager/ImageAssetManager.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lottie/src/main/java/com/airbnb/lottie/manager/ImageAssetManager.java b/lottie/src/main/java/com/airbnb/lottie/manager/ImageAssetManager.java index 0634357045..33268ac731 100644 --- a/lottie/src/main/java/com/airbnb/lottie/manager/ImageAssetManager.java +++ b/lottie/src/main/java/com/airbnb/lottie/manager/ImageAssetManager.java @@ -121,6 +121,10 @@ public void setDelegate(@Nullable ImageAssetDelegate assetDelegate) { Logger.warning("Unable to decode image.", e); return null; } + if (bitmap == null) { + Logger.warning("Decoded image is NULL."); + return null; + } bitmap = Utils.resizeBitmapIfNeeded(bitmap, asset.getWidth(), asset.getHeight()); return putBitmap(id, bitmap); } From 5aca68a161b33b89ccb0d0d31d24c5a09d77435b Mon Sep 17 00:00:00 2001 From: TechQI Date: Tue, 9 Aug 2022 09:42:03 +0800 Subject: [PATCH 2/3] Fix ImageAssetManager.bitmapForId NPE crash, add id in Logger output --- .../java/com/airbnb/lottie/manager/ImageAssetManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lottie/src/main/java/com/airbnb/lottie/manager/ImageAssetManager.java b/lottie/src/main/java/com/airbnb/lottie/manager/ImageAssetManager.java index 33268ac731..fabd1f0cb5 100644 --- a/lottie/src/main/java/com/airbnb/lottie/manager/ImageAssetManager.java +++ b/lottie/src/main/java/com/airbnb/lottie/manager/ImageAssetManager.java @@ -122,8 +122,8 @@ public void setDelegate(@Nullable ImageAssetDelegate assetDelegate) { return null; } if (bitmap == null) { - Logger.warning("Decoded image is NULL."); - return null; + Logger.warning("Decoded image `" + id + "` is null."); + return null; } bitmap = Utils.resizeBitmapIfNeeded(bitmap, asset.getWidth(), asset.getHeight()); return putBitmap(id, bitmap); From 9e145104a1b4c9d940f37f850b82735d08798234 Mon Sep 17 00:00:00 2001 From: TechQI Date: Wed, 10 Aug 2022 09:51:55 +0800 Subject: [PATCH 3/3] Add id in Logger output for ImageAssetManager.bitmapForId if decodeStream is failed. --- .../main/java/com/airbnb/lottie/manager/ImageAssetManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lottie/src/main/java/com/airbnb/lottie/manager/ImageAssetManager.java b/lottie/src/main/java/com/airbnb/lottie/manager/ImageAssetManager.java index fabd1f0cb5..afda3b5304 100644 --- a/lottie/src/main/java/com/airbnb/lottie/manager/ImageAssetManager.java +++ b/lottie/src/main/java/com/airbnb/lottie/manager/ImageAssetManager.java @@ -118,7 +118,7 @@ public void setDelegate(@Nullable ImageAssetDelegate assetDelegate) { try { bitmap = BitmapFactory.decodeStream(is, null, opts); } catch (IllegalArgumentException e) { - Logger.warning("Unable to decode image.", e); + Logger.warning("Unable to decode image `" + id + "`.", e); return null; } if (bitmap == null) {