Repository navigation
Declarative Web Push: Support pushnotification event for declarative messages that are mutable - #18087
Conversation
|
EWS run on previous version of this PR (hash 9436650) Details |
9436650 to
8b9ac17
Compare
|
EWS run on previous version of this PR (hash 8b9ac17) Details |
8b9ac17 to
db7d27d
Compare
|
EWS run on previous version of this PR (hash db7d27d) Details |
db7d27d to
b7dced9
Compare
|
EWS run on previous version of this PR (hash b7dced9) Details |
b7dced9 to
07dcef8
Compare
|
EWS run on previous version of this PR (hash 07dcef8) Details |
07dcef8 to
51fa4c7
Compare
|
EWS run on previous version of this PR (hash 51fa4c7) Details
|
51fa4c7 to
381ddb1
Compare
|
EWS run on previous version of this PR (hash 381ddb1) Details |
brentfulgham
left a comment
There was a problem hiding this comment.
Looks good, I had a few small questions and suggestions but no need for another review from me. r=me!
There was a problem hiding this comment.
This could just be forward declared, since it's passed as a reference and not a member of this class.
There was a problem hiding this comment.
That is how it originally was. In one of the EWS runs it broke various different builds in fun and creative ways.
Because it was building locally, and shrouded in UnifiedSource mystery on the bots... I decided to take the shortcut option. =/
There was a problem hiding this comment.
Could this be ~PushNotificationEvent() = default;?
There was a problem hiding this comment.
Yup. Needed to set a breakpoint at some point, didn't revert back 👍
There was a problem hiding this comment.
I think you missed this change.
There was a problem hiding this comment.
I think these last three includes could be forward-declared.
There was a problem hiding this comment.
You could probably move the #if ENABLE(DECLARATIVE_WEB_PUSH) inside the if(serviceWorkerGlobalScope), then you could delete line 328.
There was a problem hiding this comment.
Maybe:
if (!isDeclarative && !result) {
if (auto session = networkSession(sessionID)) {
session->notificationmanager()....
There was a problem hiding this comment.
Could WebCore::NotificationPayload be forward declared?
There was a problem hiding this comment.
Of all the "This could be forward declared?" comments this one hurts the most in the number of files I'd have to go touch.
The frustration here is that I can get it building locally, but then the wildly different configs on the bots (iOS, tv, older Mac, linuxes) all have different notions of unified sources.
I tried to resolve these forward declare vs includes multiple times today, but can't afford to spend any more time back-and-forthing with EWS on this =(
There was a problem hiding this comment.
If it's a huge issue, don't bother. I've just trained myself to watch for these includes since it's a lot of work to remove them later (as you know!) :-)
cdumez
left a comment
There was a problem hiding this comment.
Still reviewing but putting a few comments out there since this was already r+
There was a problem hiding this comment.
Did you mean to return a const std::optional<NotificationData>& ?
There was a problem hiding this comment.
Yup, that's what I meant.
There was a problem hiding this comment.
Should be a std::optional<unsigned long long> since the member is optional.
There was a problem hiding this comment.
Are you sure this isn't supported? I thought this worked, as long as the implementation returned a std::optional<unsigned long>.
There was a problem hiding this comment.
I just checked and this is totally supported. We have plenty of examples in the existing code base where this is working. We don't need custom bindings.
There was a problem hiding this comment.
When I figured tried, it absolutely failed compiling miserably.
I do see other users of it, so I'm trying again.
There was a problem hiding this comment.
Ping me on Slack if you get into trouble with the generated bindings. Hopefully I can help. We should definitely be able to make this work without custom bindings.
There was a problem hiding this comment.
WTFMove(resultPayload).isolatedCopy() no? since we're passing to another thread.
There was a problem hiding this comment.
I don't understand why we have code that does WTFMove(resultPayload).isolatedCopy(), if moving the object to another thread is bad.
Shouldn't such cases always just be resultPayload = resultPayload.isolatedCopy() (assuming the return of isolatedCopy is automatically moved to the new lambda value?
There was a problem hiding this comment.
Many of our objects (like String) have a more optimized isolatedCopy() version when called on a r-value reference (which avoids isolated copying in cases where it is safe). Therefore, if our can WTFMove(), you should WTFMove().isolatedCopy().
Also, you should always isolatedCopy() when passing non-trivial types to another thread.
There was a problem hiding this comment.
Yah, if we deem somewhere needs an isolatedCopy(), then the WTFMove(...) part is unnecessary.
I'll check more closely on this, but I'm not convinced we need them:
It came directly off IPC and been WTFMove()'d around.
After addressing all other feedback, will look closely.
There was a problem hiding this comment.
Yah, if we deem somewhere needs an isolatedCopy(), then the WTFMove(...) part is unnecessary.
I explained that this isn't true. WTFMove(foo).isolatedCopy() is more efficient with MANY of our types. See for example String:
WTF_EXPORT_PRIVATE String WARN_UNUSED_RETURN isolatedCopy() const &;
WTF_EXPORT_PRIVATE String WARN_UNUSED_RETURN isolatedCopy() &&;
It came directly off IPC and been WTFMove()'d around.
We use WTFMove().isolatedCopy() these days to do this safely. It is as efficient and you can't get it wrong. It is bad practice to make assumption and just WTFMove() to another thread. We stopped doing this a while back.
There was a problem hiding this comment.
Don't we need to isolatedCopy() data and proposedPayload?
There was a problem hiding this comment.
I looked at those types. We don't need to isolatedCopy() data but I believe we need it for proposedPayload.
There was a problem hiding this comment.
I don't think so - Each of them has directly come in off IPC and been WTFMove()'d around.
Certainly data never has been before this patch.
There was a problem hiding this comment.
That's what WTFMove(proposedPayload).isolatedCopy() is for and you need to make sure proposedPayload has a && isolatedCopy().
There was a problem hiding this comment.
Not needed? It's not stored for later use and cannot possibly be cleared here before this use is done.
There was a problem hiding this comment.
Ryosuke and I are fixing them after you land code like this because the static analyzer complains. You're calling a function on it on the next line so you need to hold a strong ref to it. Recent policy change for safety.
There was a problem hiding this comment.
Definitely less sure about lifecycle for this one - Added.
There was a problem hiding this comment.
For the same reason as the last one about the current notification even, not needed.
There was a problem hiding this comment.
Please, no raw pointer variable in new code, even if you think it is safe.
There was a problem hiding this comment.
Missing ? since you say in the comment below that this attribute is nullable.
381ddb1 to
58bb336
Compare
|
EWS run on previous version of this PR (hash 58bb336) Details
|
58bb336 to
8df4f26
Compare
|
EWS run on previous version of this PR (hash 8df4f26) Details
|
cdumez
left a comment
There was a problem hiding this comment.
LGTM with nits.
Nice that you were able to make unsigned long long? work in the IDL.
There was a problem hiding this comment.
I think you missed this change.
There was a problem hiding this comment.
nit: little bit of a weird pattern. This would be more concise and achieve the same:
if (RefPtr event = downcast<ServiceWorkerGlobalScope>(*scope).pushNotificationEvent()) {
There was a problem hiding this comment.
Same weird pattern. Not much use in saying both auto and RefPtr.
There was a problem hiding this comment.
Missing crossThreadCopy() for resultPayload.
8df4f26 to
46eeaab
Compare
|
EWS run on previous version of this PR (hash 46eeaab) Details
|
46eeaab to
de03b84
Compare
|
EWS run on current version of this PR (hash de03b84) Details |
…e messages that are mutable https://bugs.webkit.org/show_bug.cgi?id=261956 rdar://114886688 Reviewed by Brent Fulgham and Chris Dumez. When a declarative web push message arrives, and the sender has explicitly marked it "mutable", we fire a new `pushnotification` event at the Service Worker if there is one. That event handler is given the proposed Notification described by the declarative message, and has the opportunity to offer a new one instead. It is also given the proposed AppBadge count described by the declarative message, and can modify that as well. If the event takes too long, or does *not* override the proposed Notification or AppBadge count, then the originals described by the declarative message are used instead. Implementation-wise, it's amazing how long of a chain of message handlers and completion handlers exist to get a push message from the UI process to the point where an event can be dispatched to the ServiceWorker. This patch changes every single link in that chain to: 1 - Pass along the proposed NotificationPayload if one exists 2 - Change the CompletionHandlers to return the new NotificationPayload to be used. * Source/WebCore/CMakeLists.txt: * Source/WebCore/DerivedSources-input.xcfilelist: * Source/WebCore/DerivedSources-output.xcfilelist: * Source/WebCore/DerivedSources.make: * Source/WebCore/Headers.cmake: * Source/WebCore/Modules/notifications/Notification.cpp: (WebCore::Notification::create): (WebCore::Notification::Notification): * Source/WebCore/Modules/notifications/Notification.h: * Source/WebCore/Modules/notifications/NotificationOptionsPayload.h: (WebCore::NotificationOptionsPayload::isolatedCopy): * Source/WebCore/Modules/notifications/NotificationPayload.cpp: (WebCore::NotificationPayload::fromNotificationData): * Source/WebCore/Modules/notifications/NotificationPayload.h: (WebCore::NotificationPayload::isolatedCopy): * Source/WebCore/Modules/push-api/PushNotificationEvent.cpp: Copied from Source/WebCore/Modules/notifications/NotificationPayload.cpp. (WebCore::PushNotificationEvent::PushNotificationEvent): (WebCore::PushNotificationEvent::~PushNotificationEvent): (WebCore::PushNotificationEvent::create): * Source/WebCore/Modules/push-api/PushNotificationEvent.h: Added. * Source/WebCore/Modules/push-api/PushNotificationEvent.idl: Copied from Source/WebCore/Modules/notifications/NotificationOptionsPayload.h. * Source/WebCore/Modules/push-api/PushNotificationEventInit.h: Copied from Source/WebCore/Modules/notifications/NotificationOptionsPayload.h. * Source/WebCore/Modules/push-api/PushNotificationEventInit.idl: Copied from Source/WebCore/Modules/notifications/NotificationOptionsPayload.h. * Source/WebCore/Modules/webcodecs/WebCodecsAudioEncoder.cpp: * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/bindings/js/WebCoreBuiltinNames.h: * Source/WebCore/dom/EventNames.h: * Source/WebCore/dom/EventNames.in: * Source/WebCore/page/WorkerNavigator.cpp: (WebCore::WorkerNavigator::setAppBadge): * Source/WebCore/testing/ServiceWorkerInternals.cpp: (WebCore::ServiceWorkerInternals::schedulePushEvent): * Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp: (WebCore::ServiceWorkerGlobalScope::dispatchPushEvent): (WebCore::ServiceWorkerGlobalScope::dispatchPushNotificationEvent): (WebCore::ServiceWorkerGlobalScope::clearPushNotificationEvent): * Source/WebCore/workers/service/ServiceWorkerGlobalScope.h: * Source/WebCore/workers/service/ServiceWorkerRegistration.cpp: (WebCore::ServiceWorkerRegistration::showNotification): * Source/WebCore/workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::firePushEvent): * Source/WebCore/workers/service/context/SWContextManager.h: * Source/WebCore/workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::queueTaskToFirePushEvent): (WebCore::ServiceWorkerThread::queueTaskToFirePushNotificationEvent): (WebCore::ServiceWorkerThread::startNotificationPayloadFunctionalEventMonitoring): (WebCore::ServiceWorkerThread::heartBeatTimerFired): * Source/WebCore/workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::stopNotificationPayloadFunctionalEventMonitoring): * Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp: (WebCore::ServiceWorkerThreadProxy::firePushEvent): * Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h: * Source/WebCore/workers/service/server/SWServer.cpp: (WebCore::SWServer::processPushMessage): * Source/WebCore/workers/service/server/SWServer.h: * Source/WebCore/workers/service/server/SWServerToContextConnection.h: * Source/WebKit/NetworkProcess/NetworkProcess.cpp: (WebKit::NetworkProcess::processPushMessage): * Source/WebKit/NetworkProcess/NetworkProcess.h: * Source/WebKit/NetworkProcess/NetworkProcess.messages.in: * Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp: (WebKit::WebSWServerToContextConnection::firePushEvent): * Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h: * Source/WebKit/Scripts/webkit/messages.py: (types_that_cannot_be_forward_declared): * Source/WebKit/Shared/Cocoa/WebPushMessageCocoa.mm: (WebKit::WebPushMessage::fromDictionary): * Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in: * Source/WebKit/Shared/WebPushMessage.h: * Source/WebKit/Shared/WebPushMessage.serialization.in: * Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp: (WebKit::NetworkProcessProxy::processPushMessage): * Source/WebKit/UIProcess/Network/NetworkProcessProxy.h: * Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::processPushMessage): * Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::firePushEvent): * Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h: * Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in: * Source/WebKit/webpushd/PushService.mm: (WebPushD::PushService::didReceivePushMessage): * Source/WebKit/webpushd/WebPushDaemon.mm: (WebPushD::WebPushDaemon::injectPushMessageForTesting): (WebPushD::WebPushDaemon::getPendingPushMessages): * Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm: (-[PushNotificationDelegate clearMostRecents]): Canonical link: https://commits.webkit.org/268358@main
de03b84 to
4b36aea
Compare
|
Committed 268358@main (4b36aea): https://commits.webkit.org/268358@main Reviewed commits have been landed. Closing PR #18087 and removing active labels. |
4b36aea
de03b84