Skip to content

Commit

Permalink
[camera] Fixed stale images in imageStream subscriptions (flutter#3344)
Browse files Browse the repository at this point in the history
* Fixed stale images in imageStream subscriptions

* Implemented feedback

* Fixed format exception

* added null-check for imageStreamReader

* Removed setOnImageAvailableListener from onCancel

* fixed formatting
  • Loading branch information
danielroek authored and Minyewoo committed Jan 12, 2021
1 parent 7b07f0f commit b9770d8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/camera/camera/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.4+2

* Set ImageStreamReader listener to null to prevent stale images when streaming images.

## 0.6.4+1

* Added closeCaptureSession() to stopVideoRecording in Camera.java to fix an Android 6 crash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,13 @@ public void setZoomLevel(@NonNull final Result result, float zoom) throws Camera
result.success(null);
}

public void stopImageStream() throws CameraAccessException {
if (imageStreamReader != null) {
imageStreamReader.setOnImageAvailableListener(null, null);
}
startPreview();
}

private void closeCaptureSession() {
if (cameraCaptureSession != null) {
cameraCaptureSession.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull final Result result)
case "stopImageStream":
{
try {
camera.startPreview();
camera.stopImageStream();
result.success(null);
} catch (Exception e) {
handleException(e, result);
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: A Flutter plugin for getting information about and controlling the



version: 0.6.4+1
version: 0.6.4+2
homepage: https://github.com/flutter/plugins/tree/master/packages/camera/camera
dependencies:
flutter:
Expand Down

0 comments on commit b9770d8

Please sign in to comment.