Title: [282703] trunk
- Revision
- 282703
- Author
- [email protected]
- Date
- 2021-09-17 16:08:52 -0700 (Fri, 17 Sep 2021)
Log Message
WebKit::WebProcessPool should use a weak observer with CFNotificationCenter
<https://webkit.org/b/230227>
<rdar://problem/83067708>
Reviewed by Darin Adler.
Source/WebKit:
To fix the bug, implement an Objective-C class named
WKProcessPoolWeakObserver which contains an instance variable
holding a WeakPtr<WebProcessPool>, and tell CFNotificationCenter
to hold a weak reference to WKProcessPoolWeakObserver.
Since WKProcessPoolWeakObserver is self-contained within the
source file, it uses the NS_DIRECT_MEMBERS attribute since it
does not require the overhead of dynamic Objective-C method
dispatch.
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(-[WKProcessPoolWeakObserver initWithWeakPtr:]): Add.
(-[WKProcessPoolWeakObserver pool]): Add.
- Implement WKProcessPoolWeakObserver class.
- Note that init methods can never be marked as NS_DIRECT, and
@property statements can't use NS_DIRECT in their declaration,
so the @property is declared in a category which uses
NS_DIRECT_MEMBERS.
(WebKit::extractWebProcessPool): Add.
- Static helper method for extracting RefPtr<WebProcessPool>
from type-punned WKProcessPoolWeakObserver.
(WebKit::WebProcessPool::backlightLevelDidChangeCallback):
(WebKit::WebProcessPool::accessibilityPreferencesChangedCallback):
(WebKit::WebProcessPool::mediaAccessibilityPreferencesChangedCallback):
(WebKit::WebProcessPool::colorPreferencesDidChangeCallback):
(WebKit::WebProcessPool::remoteWebInspectorEnabledCallback):
- Clean up function parameter list.
- Use extractWebProcessPool() helper method to get a
RefPtr<WebProcessPool> from `observer`.
(WebKit::WebProcessPool::addCFNotificationObserver): Add.
(WebKit::WebProcessPool::removeCFNotificationObserver): Add.
- Private helper methods to reduce duplicate code.
- Use m_weakObserver for CFNotificationCenter observer and
include _CFNotificationObserverIsObjC to fix the bug.
(WebKit::WebProcessPool::registerNotificationObservers):
- Make use of new addCFNotificationObserver() helper method.
- Fixes use of static_cast<CFStringRef> to make code ready for
ARC by using a __bridge cast or removing the static_cast when
CFSTR() is used.
(WebKit::WebProcessPool::unregisterNotificationObservers):
- Make use of new removeCFNotificationObserver() helper method.
* UIProcess/WebProcessPool.h:
- Add m_weakObserver instance variable to hold the
WKProcessPoolWeakObserver object.
(WebKit::WebProcessPool::addCFNotificationObserver): Add.
(WebKit::WebProcessPool::removeCFNotificationObserver): Add.
- Add declarations for new helper methods.
(WebKit::WebProcessPool::backlightLevelDidChangeCallback):
(WebKit::WebProcessPool::accessibilityPreferencesChangedCallback):
(WebKit::WebProcessPool::mediaAccessibilityPreferencesChangedCallback):
(WebKit::WebProcessPool::colorPreferencesDidChangeCallback):
(WebKit::WebProcessPool::remoteWebInspectorEnabledCallback):
- Clean up function parameter list.
Source/WTF:
Tests (API):
TestWTF.TypeCastsNS.checked_ns_cast
TestWTF.TypeCastsNS.dynamic_ns_cast
TestWTF.TypeCastsNS.dynamic_ns_cast_RetainPtr
* WTF.xcodeproj/project.pbxproj:
* wtf/PlatformMac.cmake:
- Add new header files to the project.
* wtf/cocoa/TypeCastsNS.h: Add.
(WTF::checked_ns_cast):
(WTF::dynamic_ns_cast):
- Add casts for NS objects similar to TypeCastsCF.h.
* wtf/PlatformHave.h:
(HAVE_NS_DIRECT_SUPPORT): Add.
- Note that clang for macOS 11 Big Sur claims to know about the
attributes, but will fail to compile if they are actually
used.
* wtf/spi/cocoa/NSObjCRuntimeSPI.h: Add.
(NS_DIRECT):
(NS_DIRECT_MEMBERS):
- Define compiler attributes for direct dispatch of Objective-C
methods.
Tools:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
- Add TypeCastsNS.mm to the project.
* TestWebKitAPI/Tests/WTF/cocoa/TypeCastsNS.mm: Add.
(TestWebKitAPI::TEST): Add tests for <wtf/TypeCastsNS.h>.
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (282702 => 282703)
--- trunk/Source/WTF/ChangeLog 2021-09-17 23:02:17 UTC (rev 282702)
+++ trunk/Source/WTF/ChangeLog 2021-09-17 23:08:52 UTC (rev 282703)
@@ -1,3 +1,37 @@
+2021-09-16 David Kilzer <[email protected]>
+
+ WebKit::WebProcessPool should use a weak observer with CFNotificationCenter
+ <https://webkit.org/b/230227>
+ <rdar://problem/83067708>
+
+ Reviewed by Darin Adler.
+
+ Tests (API):
+ TestWTF.TypeCastsNS.checked_ns_cast
+ TestWTF.TypeCastsNS.dynamic_ns_cast
+ TestWTF.TypeCastsNS.dynamic_ns_cast_RetainPtr
+
+ * WTF.xcodeproj/project.pbxproj:
+ * wtf/PlatformMac.cmake:
+ - Add new header files to the project.
+
+ * wtf/cocoa/TypeCastsNS.h: Add.
+ (WTF::checked_ns_cast):
+ (WTF::dynamic_ns_cast):
+ - Add casts for NS objects similar to TypeCastsCF.h.
+
+ * wtf/PlatformHave.h:
+ (HAVE_NS_DIRECT_SUPPORT): Add.
+ - Note that clang for macOS 11 Big Sur claims to know about the
+ attributes, but will fail to compile if they are actually
+ used.
+
+ * wtf/spi/cocoa/NSObjCRuntimeSPI.h: Add.
+ (NS_DIRECT):
+ (NS_DIRECT_MEMBERS):
+ - Define compiler attributes for direct dispatch of Objective-C
+ methods.
+
2021-09-17 Tim Horton <[email protected]>
Enable UseCGDisplayListsForDOMRendering by default where it is available
Modified: trunk/Source/WebKit/ChangeLog (282702 => 282703)
--- trunk/Source/WebKit/ChangeLog 2021-09-17 23:02:17 UTC (rev 282702)
+++ trunk/Source/WebKit/ChangeLog 2021-09-17 23:08:52 UTC (rev 282703)
@@ -1,3 +1,66 @@
+2021-09-16 David Kilzer <[email protected]>
+
+ WebKit::WebProcessPool should use a weak observer with CFNotificationCenter
+ <https://webkit.org/b/230227>
+ <rdar://problem/83067708>
+
+ Reviewed by Darin Adler.
+
+ To fix the bug, implement an Objective-C class named
+ WKProcessPoolWeakObserver which contains an instance variable
+ holding a WeakPtr<WebProcessPool>, and tell CFNotificationCenter
+ to hold a weak reference to WKProcessPoolWeakObserver.
+
+ Since WKProcessPoolWeakObserver is self-contained within the
+ source file, it uses the NS_DIRECT_MEMBERS attribute since it
+ does not require the overhead of dynamic Objective-C method
+ dispatch.
+
+ * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+ (-[WKProcessPoolWeakObserver initWithWeakPtr:]): Add.
+ (-[WKProcessPoolWeakObserver pool]): Add.
+ - Implement WKProcessPoolWeakObserver class.
+ - Note that init methods can never be marked as NS_DIRECT, and
+ @property statements can't use NS_DIRECT in their declaration,
+ so the @property is declared in a category which uses
+ NS_DIRECT_MEMBERS.
+ (WebKit::extractWebProcessPool): Add.
+ - Static helper method for extracting RefPtr<WebProcessPool>
+ from type-punned WKProcessPoolWeakObserver.
+ (WebKit::WebProcessPool::backlightLevelDidChangeCallback):
+ (WebKit::WebProcessPool::accessibilityPreferencesChangedCallback):
+ (WebKit::WebProcessPool::mediaAccessibilityPreferencesChangedCallback):
+ (WebKit::WebProcessPool::colorPreferencesDidChangeCallback):
+ (WebKit::WebProcessPool::remoteWebInspectorEnabledCallback):
+ - Clean up function parameter list.
+ - Use extractWebProcessPool() helper method to get a
+ RefPtr<WebProcessPool> from `observer`.
+ (WebKit::WebProcessPool::addCFNotificationObserver): Add.
+ (WebKit::WebProcessPool::removeCFNotificationObserver): Add.
+ - Private helper methods to reduce duplicate code.
+ - Use m_weakObserver for CFNotificationCenter observer and
+ include _CFNotificationObserverIsObjC to fix the bug.
+ (WebKit::WebProcessPool::registerNotificationObservers):
+ - Make use of new addCFNotificationObserver() helper method.
+ - Fixes use of static_cast<CFStringRef> to make code ready for
+ ARC by using a __bridge cast or removing the static_cast when
+ CFSTR() is used.
+ (WebKit::WebProcessPool::unregisterNotificationObservers):
+ - Make use of new removeCFNotificationObserver() helper method.
+
+ * UIProcess/WebProcessPool.h:
+ - Add m_weakObserver instance variable to hold the
+ WKProcessPoolWeakObserver object.
+ (WebKit::WebProcessPool::addCFNotificationObserver): Add.
+ (WebKit::WebProcessPool::removeCFNotificationObserver): Add.
+ - Add declarations for new helper methods.
+ (WebKit::WebProcessPool::backlightLevelDidChangeCallback):
+ (WebKit::WebProcessPool::accessibilityPreferencesChangedCallback):
+ (WebKit::WebProcessPool::mediaAccessibilityPreferencesChangedCallback):
+ (WebKit::WebProcessPool::colorPreferencesDidChangeCallback):
+ (WebKit::WebProcessPool::remoteWebInspectorEnabledCallback):
+ - Clean up function parameter list.
+
2021-09-17 Chris Dumez <[email protected]>
Unreviewed build fix.
Modified: trunk/Tools/ChangeLog (282702 => 282703)
--- trunk/Tools/ChangeLog 2021-09-17 23:02:17 UTC (rev 282702)
+++ trunk/Tools/ChangeLog 2021-09-17 23:08:52 UTC (rev 282703)
@@ -1,3 +1,16 @@
+2021-09-16 David Kilzer <[email protected]>
+
+ WebKit::WebProcessPool should use a weak observer with CFNotificationCenter
+ <https://webkit.org/b/230227>
+ <rdar://problem/83067708>
+
+ Reviewed by Darin Adler.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ - Add TypeCastsNS.mm to the project.
+ * TestWebKitAPI/Tests/WTF/cocoa/TypeCastsNS.mm: Add.
+ (TestWebKitAPI::TEST): Add tests for <wtf/TypeCastsNS.h>.
+
2021-09-17 Alex Christensen <[email protected]>
REGRESSION: [ iOS ] 5 TestWebKitAPI.WebpagePreferences.* api tests are flaky timing out
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes