[webkit-changes] [WebKit/WebKit] 33be0a: Crash under NetworkCache::SpeculativeLoadManager::...
Chris Dumez
noreply at github.com
Tue Oct 29 22:34:54 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 33be0a4c0f11a4b4f19ada2a91d0d1ec1cc350e3
https://github.com/WebKit/WebKit/commit/33be0a4c0f11a4b4f19ada2a91d0d1ec1cc350e3
Author: Chris Dumez <cdumez at apple.com>
Date: 2024-10-29 (Tue, 29 Oct 2024)
Changed paths:
M Source/WebCore/platform/LowPowerModeNotifier.h
M Source/WebCore/platform/cocoa/LowPowerModeNotifier.mm
M Source/WebKit/NetworkProcess/cache/NetworkCache.cpp
M Source/WebKit/NetworkProcess/cache/NetworkCache.h
M Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp
M Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.h
M Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h
Log Message:
-----------
Crash under NetworkCache::SpeculativeLoadManager::~SpeculativeLoadManager()
https://bugs.webkit.org/show_bug.cgi?id=282297
rdar://138800566
Reviewed by Ryosuke Niwa.
Made several fixes / hardening to hopefully resolve the crash:
1. The LowPowerModeNotifier destructor now makes sure to unregister the
notification handler from NSNotificationCenter in addition to clear
the notifier pointer. This guards against potential races.
2. Made WebLowPowerModeObserver.notifier a CheckedPtr instead of a raw
pointer for extra safety.
3. In the NetworkCache constructor, capture `weakThis` instead of `this`
in the lambda we pass to the LowPowerModeNotifier. We also convert
`weakThis` to a `protectedThis` inside the lambda to guarantee
lifetime.
4. Update SpeculativeLoadManager::m_storage to be a ThreadSafeWeakPtr
instead of a CheckedRef since m_storage is already ThreadSafeRefCounted.
5. Add some threading assertions to help catch potential multi-threading
issues.
* Source/WebCore/platform/LowPowerModeNotifier.h:
* Source/WebCore/platform/cocoa/LowPowerModeNotifier.mm:
(-[WebLowPowerModeObserver dealloc]):
(-[WebLowPowerModeObserver detach]):
(-[WebLowPowerModeObserver _didReceiveLowPowerModeChange]):
(WebCore::LowPowerModeNotifier::LowPowerModeNotifier):
(WebCore::LowPowerModeNotifier::~LowPowerModeNotifier):
* Source/WebKit/NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::Cache::Cache):
* Source/WebKit/NetworkProcess/cache/NetworkCache.h:
(WebKit::NetworkCache::Cache::protectedStorage const):
* Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
(WebKit::NetworkCache::SpeculativeLoadManager::protectedStorage const):
(WebKit::NetworkCache::SpeculativeLoadManager::retrieveSubresourcesEntry):
(WebKit::NetworkCache::SpeculativeLoadManager::~SpeculativeLoadManager): Deleted.
* Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.h:
* Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h:
Canonical link: https://commits.webkit.org/285883@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list