Skip to content

Commit a0a77b5

Browse files
danielroekadsonpleal
authored andcommitted
[camera] Fixed stale images in imageStream subscriptions (flutter#3344)
* Fixed stale images in imageStream subscriptions * Implemented feedback * Fixed format exception * added null-check for imageStreamReader * Removed setOnImageAvailableListener from onCancel * fixed formatting
1 parent bf36fc8 commit a0a77b5

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

packages/camera/camera/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.6.4+2
2+
3+
* Set ImageStreamReader listener to null to prevent stale images when streaming images.
4+
15
## 0.6.4+1
26

37
* Added closeCaptureSession() to stopVideoRecording in Camera.java to fix an Android 6 crash

packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/Camera.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,13 @@ public void setZoomLevel(@NonNull final Result result, float zoom) throws Camera
943943
result.success(null);
944944
}
945945

946+
public void stopImageStream() throws CameraAccessException {
947+
if (imageStreamReader != null) {
948+
imageStreamReader.setOnImageAvailableListener(null, null);
949+
}
950+
startPreview();
951+
}
952+
946953
private void closeCaptureSession() {
947954
if (cameraCaptureSession != null) {
948955
cameraCaptureSession.close();

packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/MethodCallHandlerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull final Result result)
219219
case "stopImageStream":
220220
{
221221
try {
222-
camera.startPreview();
222+
camera.stopImageStream();
223223
result.success(null);
224224
} catch (Exception e) {
225225
handleException(e, result);

packages/camera/camera/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera
22
description: A Flutter plugin for getting information about and controlling the
33
camera on Android and iOS. Supports previewing the camera feed, capturing images, capturing video,
44
and streaming image buffers to dart.
5-
version: 0.6.4+1
5+
version: 0.6.4+2
66
homepage: https://github.com/flutter/plugins/tree/master/packages/camera/camera
77

88
dependencies:

0 commit comments

Comments
 (0)