-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[video_player] [iOS] Fixed a memory leak in the video player plugin. #1660
[video_player] [iOS] Fixed a memory leak in the video player plugin. #1660
Conversation
cyanglaz
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.
Good catch! I have left some comments. Also, could you please update the pubspec and CHANGELOG.md with a new version?
| context:playbackBufferFullContext]; | ||
|
|
||
| [[NSNotificationCenter defaultCenter] addObserverForName:AVPlayerItemDidPlayToEndTimeNotification | ||
| _notificationObserverId = [[NSNotificationCenter defaultCenter] addObserverForName:AVPlayerItemDidPlayToEndTimeNotification |
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.
It might be cleaner to just use the addObserver:self here since we are just using mainQueue. This way we can separate the observing implementation out of the addObservers method.
| context:playbackBufferFullContext]; | ||
| [_player replaceCurrentItemWithPlayerItem:nil]; | ||
| [[NSNotificationCenter defaultCenter] removeObserver:self]; | ||
| [[NSNotificationCenter defaultCenter] removeObserver:_notificationObserverId]; |
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.
This can be unchanged if we use the addObserver: method as I mentioned in the other comment.
| AVPlayerItem* p = [note object]; | ||
| [p seekToTime:kCMTimeZero | ||
| completionHandler:nil]; | ||
| [p seekToTime:kCMTimeZero]; |
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.
It seems not related.
|
@cyanglaz Thanks for the feedback. We will update the PR. |
cyanglaz
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 the quick turn around. LGTM overall.
| object:item]; | ||
| } | ||
|
|
||
| - (void)itemDidPlayToEndTime:(NSNotification*)note { |
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.
nits: renaming note -> notification
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.
Sure.
|
|
||
| - (void)itemDidPlayToEndTime:(NSNotification*)note { | ||
| AVPlayerItem* p = [note object]; | ||
| if (self->_isLooping) { |
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.
nits: Same as below for _eventSink
| if (self->_isLooping) { | |
| if (_isLooping) { |
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.
Will update. Thanks for the feedback!
packages/video_player/CHANGELOG.md
Outdated
| @@ -1,3 +1,7 @@ | |||
| ## 0.10.1+5 | |||
|
|
|||
| * [iOS] Fixed a memory leak in the video player plugin. | |||
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.
| * [iOS] Fixed a memory leak in the video player plugin. | |
| * [iOS] Fixed a memory leak with notification observing. |
Description
This fixes a memory leak in iOS.
Related Issues
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?