[webkit-changes] [WebKit/WebKit] fe2cfb: [iOS] Memory management of WebAVPictureInPicturePl...
aestes
noreply at github.com
Mon Oct 30 19:15:35 PDT 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: fe2cfbc719090ccedd59a6286cd3523ab7bf5cd3
https://github.com/WebKit/WebKit/commit/fe2cfbc719090ccedd59a6286cd3523ab7bf5cd3
Author: Andy Estes <aestes at apple.com>
Date: 2023-10-30 (Mon, 30 Oct 2023)
Changed paths:
M Source/WebCore/platform/cocoa/WebAVPlayerLayerView.mm
Log Message:
-----------
[iOS] Memory management of WebAVPictureInPicturePlayerLayerView instances in WebAVPlayerLayerView is confusing
https://bugs.webkit.org/show_bug.cgi?id=263916
rdar://117364434
Reviewed by Tim Horton and Simon Fraser.
WebAVPlayerLayerView_pictureInPicturePlayerLayerView creates an instance of
WebAVPictureInPicturePlayerLayerView but does not adopt it, leaking its +1 retain count. It is then
stored in WebAVPlayerLayerView's _pictureInPicturePlayerLayerView ivar, which retains it. Later,
WebAVPlayerLayerView_dealloc adopts the leaked instance stored in _pictureInPicturePlayerLayerView
and sets the ivar to nil. This releases the instance twice, balancing the +2 retain count from
earlier. This is correct but confusing, as it isn't the conventional way we manage an instance's
retain count.
Addressed the confusion by adopting the new WebAVPictureInPicturePlayerLayerView instance in
WebAVPlayerLayerView_pictureInPicturePlayerLayerView rather than leaking it until
WebAVPlayerLayerView_dealloc is called. Fixed a few formatting issues while here.
* Source/WebCore/platform/cocoa/WebAVPlayerLayerView.mm:
(WebCore::WebAVPlayerLayerView_setPlayerController):
(WebCore::WebAVPlayerLayerView_playerLayer):
(WebCore::WebAVPlayerLayerView_startRoutingVideoToPictureInPicturePlayerLayerView):
(WebCore::WebAVPlayerLayerView_pictureInPicturePlayerLayerView):
(WebCore::WebAVPlayerLayerView_dealloc):
(WebCore::allocWebAVPlayerLayerViewInstance):
(WebCore::allocWebAVPictureInPicturePlayerLayerViewInstance):
Canonical link: https://commits.webkit.org/269989@main
More information about the webkit-changes
mailing list