Skip to content

Commit 4528a65

Browse files
greggor01Michael Klimushyn
authored andcommitted
[camera] Fix camera memory leak on IOS (flutter#1745)
Needed to unregister the stream handler when disposing of the camera Per the flutter documentation, the stream handler should be unregistered using setStreamHandler with nil. https://api.flutter.dev/objcdoc/Classes/FlutterEventChannel.html#/c:objc(cs)FlutterEventChannel(im)setStreamHandler:
1 parent 2d9cd26 commit 4528a65

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎packages/camera/CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.2+2
2+
3+
* Fix memory leak related to not unregistering stream handler in FlutterEventChannel when disposing camera.
4+
15
## 0.5.2+1
26

37
* Fix bug that prevented video recording with audio.

‎packages/camera/ios/Classes/CameraPlugin.m‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,8 @@ - (CVPixelBufferRef)copyPixelBuffer {
456456

457457
- (FlutterError *_Nullable)onCancelWithArguments:(id _Nullable)arguments {
458458
_eventSink = nil;
459+
// need to unregister stream handler when disposing the camera
460+
[_eventChannel setStreamHandler:nil];
459461
return nil;
460462
}
461463

‎packages/camera/pubspec.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ 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.5.2+1
6-
publish_to: none
5+
version: 0.5.2+2
6+
77
authors:
88
- Flutter Team <[email protected]>
99
- Luigi Agosti <[email protected]>

0 commit comments

Comments
 (0)