Bug 237983 - Remove push subscriptions when associated service worker registrations are removed
Summary: Remove push subscriptions when associated service worker registrations are re...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ben Nham
URL:
Keywords: InRadar
Depends on:
Blocks: 238068
  Show dependency treegraph
 
Reported: 2022-03-16 14:48 PDT by Ben Nham
Modified: 2022-03-18 12:20 PDT (History)
4 users (show)

See Also:


Attachments
Patch (43.92 KB, patch)
2022-03-16 15:01 PDT, Ben Nham
no flags Details | Formatted Diff | Diff
Patch for landing (43.75 KB, patch)
2022-03-18 10:00 PDT, Ben Nham
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Nham 2022-03-16 14:48:47 PDT
Remove push subscriptions when associated service worker registrations are removed
Comment 1 Ben Nham 2022-03-16 15:01:35 PDT
Created attachment 454899 [details]
Patch
Comment 2 Radar WebKit Bug Importer 2022-03-16 15:02:42 PDT
<rdar://problem/90394173>
Comment 3 youenn fablet 2022-03-18 01:16:17 PDT
Comment on attachment 454899 [details]
Patch

LGTM.
I am wondering whether there is a chance that things get dysinchronized, say the SQL service worker is damaged so now we loose all registrations but keep some push subscriptions. Maybe there should be something ensuring everything is fine.
For instance, if we push a message and there is no corresponding service worker registration, we should probably remove the corresponding push subscription.

View in context: https://bugs.webkit.org/attachment.cgi?id=454899&action=review

> Source/WebKit/NetworkProcess/NetworkProcess.cpp:2335
> +        session->notificationManager().getPushSubscription(WTFMove(scopeURL), [callback = WTFMove(callback)](auto &&result) mutable {

Preexisting but I would not expect getPushSubscription to require a URL&&.

> Source/WebKit/NetworkProcess/NetworkProcess.cpp:2341
> +            callback(true);

Could be written as callback(result && !!result.value()) ?

> Source/WebKit/webpushd/PushService.mm:394
> +                    RELEASE_LOG(Push, "PushSubscription.unsubscribe(bundleID: %{public}s, scope: %{sensitive}s) failed with domain: %{public}s code: %lld)", m_bundleIdentifier.utf8().data(), m_scope.utf8().data(), error.domain.UTF8String ?: "none", static_cast<int64_t>(error.code));

RELEASE_LOG_IF which will not require the RELEASE_LOG_DISABLED around the if.
Comment 4 Ben Nham 2022-03-18 10:00:09 PDT
Created attachment 455104 [details]
Patch for landing
Comment 5 EWS 2022-03-18 12:20:46 PDT
Committed r291492 (248604@main): <https://commits.webkit.org/248604@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 455104 [details].