-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[camera] Fix camera memory leak on IOS #1745
Conversation
Needed to unregister the stream handler when disposing of the camera
|
Any news on when this might be incorporated? We have an app that will be posted in the app store very soon and it would be nice to have this fix included since it does indeed cause a crash on some IOS devices if the camera is opened and closed multiple times. |
mklim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patience and the contribution! I have some feedback on the approach.
Per @mklim the release of the event channel was moved to onCancel vs. dispose.
mklim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one nit. Thanks again!
|
Just tested the camera plugin version 0.5.2+2 on an iphone 5S running OS 12.3 and after every time the camera opens and closes the memory usage keeps on increasing quickly (took about 10 times for the camera to open and close to terminate the app) |
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:
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:
Needed to unregister the stream handler when disposing of the camera
Description
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:
Related Issues
Possibly fixes:
flutter/flutter#29586
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?