Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 30ae065f0e43e2a0f52667ffc1520bb74cec19c7
https://github.com/WebKit/WebKit/commit/30ae065f0e43e2a0f52667ffc1520bb74cec19c7
Author: David Kilzer <[email protected]>
Date: 2026-01-24 (Sat, 24 Jan 2026)
Changed paths:
M Source/WebCore/platform/ios/WebAVPlayerController.h
M Source/WebCore/platform/ios/WebAVPlayerController.mm
M Tools/TestWebKitAPI/SourcesCocoa.txt
M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
A Tools/TestWebKitAPI/Tests/WebCore/cocoa/WebAVPlayerControllerLeakTests.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/EnhancedSecurity.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteWebArchive.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/ScreenTime.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/TextExtractionTests.mm
Log Message:
-----------
[visionOS] WebAVPlayerController leaks when playing a video in Safari one
window and entering tab overview in another window
<https://bugs.webkit.org/show_bug.cgi?id=305752>
<rdar://121550335>
Reviewed by Geoffrey Garen.
Tests: Tools/TestWebKitAPI/Tests/WebCore/cocoa/WebAVPlayerControllerLeakTests.mm
Fix the following bugs:
1. Fix leak of WebAVPlayerController object by adding
-[WebAVPlayerControllerForwarder dealloc] method that clears the
_playerController instance variable. When using RetainPtr<> as an
ivar, the ObjC runtime does not auto-generate -.cxx_construct or
-.cxx_destruct methods, which caused the leak.
2. Fix addition of the _playerController instance variable to dynamic
WebAVPlayerControllerForwarder_AVKitCompatible class by calling
class_addIvar() before objc_registerClassPair().
3. Simplify WebAVPlayerControllerForwarder by replacing RetainPtr with a
direct instance variable for _playerController, implementing
getter/setter methods for _playerController that work for both the
original and dynamic classes by computing the ivar location at
runtime, then using a getter/setter in all other instance methods
instead of direct instance variable access. Using direct instance
variable access would read from/write to the wrong location in the
WebAVPlayerControllerForwarder_AVKitCompatible object since
_playerController was in a different location. This removes the need
for custom methods in the dynamic class.
* Source/WebCore/platform/ios/WebAVPlayerController.h:
(WebCore::createWebAVPlayerController):
(WebCore::webAVPlayerControllerClassSingleton):
- Move into WebCore namespace.
- Export webAVPlayerControllerClassSingleton() for testing.
* Source/WebCore/platform/ios/WebAVPlayerController.mm:
(-[WebAVPlayerControllerForwarder playerController]):
(-[WebAVPlayerControllerForwarder setPlayerController:]):
- Add @property definition to document playerController instance
variable with getter and setter.
- Change _playerController ivar from RetainPtr<> to raw pointer for
simplicity and avoid pointer math in getter and setter.
- Implement getter and setter so that they work for both
WebAVPlayerControllerForwarder and the dynamically constructed class.
(-[WebAVPlayerControllerForwarder init]):
- Update to use setter instead of direct ivar access.
(-[WebAVPlayerControllerForwarder dealloc]): Add.
- Use setter to clear _playerController ivar.
(-[WebAVPlayerControllerForwarder respondsToSelector:]):
- Update to use getter.
(-[WebAVPlayerControllerForwarder forwardingTargetForSelector:]):
- Update to use getter.
(-[WebAVPlayerControllerForwarder _forwardingTargetForKeyPath:]):
- Update to use getter.
- Use RetainPtr<> for local variables and optimize with autorelease()
and WTF::move().
(createWebAVPlayerControllerForwarderClassSingleton):
- Call class_addIvar() before objc_registerClassPair() to make sure
_playerController ivar is created properly.
- Ignore "." methods when overriding AVPlayerController methods.
(WebCore::createWebAVPlayerController):
(WebCore::webAVPlayerControllerClassSingleton):
- Move into WebCore namespace.
* Tools/TestWebKitAPI/SourcesCocoa.txt:
- Add Tests/WebCore/cocoa/WebAVPlayerControllerLeakTests.mm.
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
- Add Tests/WebCore/cocoa/WebAVPlayerControllerLeakTests.mm.
* Tools/TestWebKitAPI/Tests/WebCore/cocoa/WebAVPlayerControllerLeakTests.mm:
Add.
(TestWebKitAPI::TEST(WebAVPlayerControllerLeak,
NormalForwarderClassReleasesIvar)): Add.
(TestWebKitAPI::TEST(WebAVPlayerControllerLeak,
DynamicForwarderClassReleasesIvar)): Add.
- Add tests to verify correct instance object behavior.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/EnhancedSecurity.mm:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteWebArchive.mm:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/ScreenTime.mm:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/TextExtractionTests.mm:
- Add missing headers after UnifiedSources reshuffle.
Canonical link: https://commits.webkit.org/306145@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications