Bug 231922 - Add NetworkProcess stubs for push subscriptions
Summary: Add NetworkProcess stubs for push subscriptions
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:
 
Reported: 2021-10-18 17:00 PDT by Ben Nham
Modified: 2021-10-19 22:16 PDT (History)
13 users (show)

See Also:


Attachments
Patch (49.21 KB, patch)
2021-10-18 17:10 PDT, Ben Nham
no flags Details | Formatted Diff | Diff
Patch (48.91 KB, patch)
2021-10-18 17:16 PDT, Ben Nham
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (48.90 KB, patch)
2021-10-18 18:08 PDT, Ben Nham
no flags Details | Formatted Diff | Diff
Patch (61.53 KB, patch)
2021-10-19 13:54 PDT, Ben Nham
no flags Details | Formatted Diff | Diff
Patch (61.53 KB, patch)
2021-10-19 17:26 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 2021-10-18 17:00:05 PDT
Add NetworkProcess stubs for push subscriptions
Comment 1 Ben Nham 2021-10-18 17:10:33 PDT
Created attachment 441659 [details]
Patch
Comment 2 Ben Nham 2021-10-18 17:16:46 PDT
Created attachment 441661 [details]
Patch
Comment 3 Ben Nham 2021-10-18 18:08:15 PDT
Created attachment 441668 [details]
Patch
Comment 4 Radar WebKit Bug Importer 2021-10-18 21:39:10 PDT
<rdar://problem/84400696>
Comment 5 Ben Nham 2021-10-18 21:42:57 PDT
Comment on attachment 441668 [details]
Patch

One note is that the IPC parser didn't seem to handle a return type of Expected<enum:uint8_t PushPermissionState, ExceptionData> properly (its codegen tried to emit an #include<enum:uint8_t ...> in the cpp file). For now that IPC message just returns an Expected<uint8_t, ExceptionData> until I can take a look at that codegen issue in a separate patch.
Comment 6 youenn fablet 2021-10-19 01:50:39 PDT
Comment on attachment 441668 [details]
Patch

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

> Source/WebCore/ChangeLog:9
> +        via ServiceWorkerRegistration => ServiceWorkerContainer => SWClientConnection.

Do the existing tests fully cover this case?
Maybe it is too early to do, but maybe there are some things to test (network process crash).

> Source/WebCore/Modules/push-api/PushSubscription.h:62
> +    WEBCORE_EXPORT PushSubscription(ServiceWorkerRegistration*, String&& endpoint, std::optional<EpochTimeStamp> expirationTime, Ref<PushSubscriptionOptions>&&, Vector<uint8_t>&& clientECDHPublicKey, Vector<uint8_t>&& auth);

It would be better to pass a Ref<ServiceWorkerRegistration> if possible.
If the issue is PushSubscription creation in Internals, we can always change createPushSubscription to add a ServiceWorkerRegistration as parameter.

> Source/WebCore/Modules/push-api/PushSubscription.h:64
> +    RefPtr<ServiceWorkerRegistration> m_serviceWorkerRegistration;

Would be better as a Ref.

> Source/WebCore/Modules/push-api/PushSubscriptionData.h:60
> +bool PushSubscriptionData::decode(Decoder& decoder, PushSubscriptionData& data)

Would be better to use the modern form:
template<class Decoder> std::optional<PushSubscriptionData> PushSubscriptionData::decode(Decoder& decoder)

> Source/WebCore/workers/service/ServiceWorkerContainer.cpp:557
> +    auto options = PushSubscriptionOptions::create(true, WTFMove(data.serverVAPIDPublicKey));

true is a bit mysterious.
I guess bool userVisibleOnly = true would be clearer.

> Source/WebCore/workers/service/ServiceWorkerContainer.cpp:581
> +        promise.resolve(result.releaseReturnValue());

Can we use promise.settle(WTFMove(result))?

> Source/WebCore/workers/service/ServiceWorkerContainer.cpp:599
> +        promise.resolve(createPushSubscriptionFromData(protectedRegistration, WTFMove(*optionalPushSubscriptionData)).ptr());

This triggers some count churn.
I would write it as 
RefPtr<PushSubscription> subscription;
if (optionalPushSubscriptionData)
     subscription = createPushSubscriptionFromData(protectedRegistration, WTFMove(*optionalPushSubscriptionData));
promise.resolve(WTFMove(subscription));

> Source/WebCore/workers/service/ServiceWorkerContainer.cpp:611
> +        promise.resolve(result.releaseReturnValue());

promise.settle as well?

> Source/WebCore/workers/service/WorkerSWClientConnection.cpp:224
> +void WorkerSWClientConnection::subscribeToPushService(ServiceWorkerRegistrationIdentifier registrationIdentifier, const Vector<uint8_t>& applicationServerKey, SubscribeToPushServiceCallback&& callback)

Could we pass a Vector<uint8_t>&& to not copy it here? It seems at the push manager layer, we have a Vector&&.
Comment 7 Ben Nham 2021-10-19 13:54:53 PDT
Created attachment 441788 [details]
Patch
Comment 8 Alex Christensen 2021-10-19 15:45:53 PDT
Comment on attachment 441788 [details]
Patch

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

> Source/WebCore/Modules/push-api/PushSubscriptionData.cpp:2
> + * Copyright (C) 2017 Apple Inc. All rights reserved.

nit: 2021
Comment 9 Ben Nham 2021-10-19 17:26:11 PDT
Created attachment 441824 [details]
Patch
Comment 10 EWS 2021-10-19 22:16:37 PDT
Committed r284518 (243261@main): <https://commits.webkit.org/243261@main>

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