From d76ddbc213b1f83200a6e1b65dae96062de96f39 Mon Sep 17 00:00:00 2001 From: Daniel Kao Date: Thu, 13 Aug 2020 18:48:47 +0800 Subject: [PATCH] fix acquireLatestImage exceeds maxImage and cause IllegalStateException. --- .../io/flutter/embedding/android/FlutterImageView.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterImageView.java b/shell/platform/android/io/flutter/embedding/android/FlutterImageView.java index 46079d429f56c..7f48e4edf157b 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterImageView.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterImageView.java @@ -183,9 +183,13 @@ public boolean acquireLatestImage() { // // To avoid exceptions, check if a new image can be acquired. if (pendingImages < imageReader.getMaxImages()) { - nextImage = imageReader.acquireLatestImage(); - if (nextImage != null) { - pendingImages++; + try { + nextImage = imageReader.acquireLatestImage(); + if (nextImage != null) { + pendingImages++; + } + } catch (IllegalStateException exception) { + // just bypass } } invalidate();