Bug 272212 - Some raw pointers are named 'protectedThis' which is probably unintentional
Summary: Some raw pointers are named 'protectedThis' which is probably unintentional
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2024-04-04 23:21 PDT by Mike Wyrzykowski
Modified: 2024-04-08 12:33 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Wyrzykowski 2024-04-04 23:21:11 PDT
There are a few instances where we make a variable 'auto protectedThis' and assign it directly to 'weakThis.get()', which seems wrong.

In some cases I think it doesn't matter but in others, it could be problematic:


SystemPreviewControllerCocoa.mm:403
WeakPtr weakThis { *this };
    bool shouldRunAtForegroundPriority = false;
    m_webPageProxy.dataTaskWithRequest(WTFMove(request), topOrigin, shouldRunAtForegroundPriority, [weakThis, completionHandler = WTFMove(completionHandler)] (Ref<API::DataTask>&& task) mutable {
        if (!weakThis)
            return completionHandler();

        auto protectedThis = weakThis.get();

Page.cpp:4058
[weakThis = WeakPtr { *this }, paymentHandlerPtr = &paymentHandler] (std::optional<bool>&& result) {
        auto protectedThis = weakThis.get();



PlatformXRSystem.cpp:129:
xrCoordinator->requestPermissionOnSessionFeatures(m_page, securityOriginData, mode, granted, consentRequired, consentOptional, requiredFeaturesRequested, optionalFeaturesRequested, [weakThis = WeakPtr { *this }, mode, securityOriginData, consentRequired, completionHandler = WTFMove(completionHandler)](std::optional<PlatformXR::Device::FeatureList>&& grantedFeatures) mutable {
        ASSERT(RunLoop::isMain());
        auto protectedThis = weakThis.get();

PlatformXRSystem.cpp:192 (non-issue)
ensureOnMainRunLoop([weakThis = WeakPtr { *this }, deviceIdentifier]() mutable {
        auto protectedThis = weakThis.get();

PlatformXRSystem.cpp:206 (non-issue)
PlatformXRSystem::sessionDidUpdateVisibilityState(XRDeviceIdentifier deviceIdentifier, PlatformXR::VisibilityState visibilityState)
{
    ensureOnMainRunLoop([weakThis = WeakPtr { *this }, deviceIdentifier, visibilityState]() mutable {
        auto protectedThis = weakThis.get();
Comment 1 Radar WebKit Bug Importer 2024-04-04 23:26:29 PDT
<rdar://problem/125952102>