RESOLVED FIXED231786
WebKit Managed Notifications: Skeleton NotificationProvider
https://bugs.webkit.org/show_bug.cgi?id=231786
Summary WebKit Managed Notifications: Skeleton NotificationProvider
Brady Eidson
Reported 2021-10-14 16:58:22 PDT
To change how Notifications work to be WebKit managed (instead of client managed) we'll add a different API::NotificationProvider to perform all the logic. Let's land a skeleton first. <rdar://84275562>
Attachments
Patch v1 (31.32 KB, patch)
2021-10-14 20:24 PDT, Brady Eidson
achristensen: review+
PFL v1 (31.57 KB, patch)
2021-10-14 21:03 PDT, Brady Eidson
ews-feeder: commit-queue-
PFL v2 (31.52 KB, patch)
2021-10-14 23:40 PDT, Brady Eidson
ews-feeder: commit-queue-
PFL v3 (31.50 KB, patch)
2021-10-15 01:20 PDT, Brady Eidson
no flags
New approach v1 (35.92 KB, patch)
2021-10-19 09:14 PDT, Brady Eidson
ews-feeder: commit-queue-
New approach v2 (35.89 KB, patch)
2021-10-19 09:17 PDT, Brady Eidson
no flags
New approach v3 (36.82 KB, patch)
2021-10-19 10:02 PDT, Brady Eidson
no flags
Patch with better messaging v1 (33.41 KB, patch)
2021-10-20 16:54 PDT, Brady Eidson
achristensen: review+
PFL v1 (33.38 KB, patch)
2021-10-20 17:06 PDT, Brady Eidson
ews-feeder: commit-queue-
PFL v2 (34.12 KB, patch)
2021-10-20 17:57 PDT, Brady Eidson
ews-feeder: commit-queue-
Another try PFL (33.95 KB, patch)
2021-10-20 18:48 PDT, Brady Eidson
ews-feeder: commit-queue-
PFL again (34.00 KB, patch)
2021-10-20 19:28 PDT, Brady Eidson
no flags
PFL maybe the last one? (40.09 KB, patch)
2021-10-20 21:22 PDT, Brady Eidson
no flags
PFL with better way to disable these tests (35.29 KB, patch)
2021-10-20 21:51 PDT, Brady Eidson
no flags
Brady Eidson
Comment 1 2021-10-14 20:24:27 PDT
Created attachment 441326 [details] Patch v1
Alex Christensen
Comment 2 2021-10-14 20:33:38 PDT
Comment on attachment 441326 [details] Patch v1 View in context: https://bugs.webkit.org/attachment.cgi?id=441326&action=review > Source/WebKit/UIProcess/Notifications/Cocoa/WebNotificationProviderCocoa.h:53 > + bool isClientReplaceable() const final { return false; } I don't think I understand why this is needed. Can we go without? > Source/WebKit/UIProcess/Notifications/Cocoa/WebNotificationProviderCocoa.mm:39 > + return std::make_unique<WebNotificationProviderCocoa>(); makeUnique which also does a fastMalloc check. > Source/WebKit/UIProcess/Notifications/Cocoa/WebNotificationProviderCocoa.mm:40 > + return nullptr; It would be nice if this returned makeUniqueRef<API::NotificationProvider>(); if it's not enabled. Then we would never need to null check m_provider in WebNotificationManagerProxy, which can also be changed from a std::unique_ptr to a UniqueRef. Right now it can never be null, and I think we should keep that.
Brady Eidson
Comment 3 2021-10-14 20:37:35 PDT
(In reply to Alex Christensen from comment #2) > Comment on attachment 441326 [details] > Patch v1 > > View in context: > https://bugs.webkit.org/attachment.cgi?id=441326&action=review > > > Source/WebKit/UIProcess/Notifications/Cocoa/WebNotificationProviderCocoa.h:53 > > + bool isClientReplaceable() const final { return false; } > > I don't think I understand why this is needed. Can we go without? I will explain in the ChangeLog as well, but for the record: Without this (temporary) mechanism, you'd be unable to run existing Safari against new WebKit to get the new feature, because Safari would override the NotificationProvider through an SPI call. > > > Source/WebKit/UIProcess/Notifications/Cocoa/WebNotificationProviderCocoa.mm:39 > > + return std::make_unique<WebNotificationProviderCocoa>(); > > makeUnique which also does a fastMalloc check. Yessssss > > > Source/WebKit/UIProcess/Notifications/Cocoa/WebNotificationProviderCocoa.mm:40 > > + return nullptr; > > It would be nice if this returned > makeUniqueRef<API::NotificationProvider>(); if it's not enabled. Then we > would never need to null check m_provider in WebNotificationManagerProxy, > which can also be changed from a std::unique_ptr to a UniqueRef. Right now > it can never be null, and I think we should keep that. This is to support the above - Note that *if* this returns null, then the WebNotificationManagerProxy will create the default API::NotificationProvider. This is necessary for the weird branch of having this feature enabled at runtime or not.
Alex Christensen
Comment 4 2021-10-14 20:59:49 PDT
Comment on attachment 441326 [details] Patch v1 View in context: https://bugs.webkit.org/attachment.cgi?id=441326&action=review >>> Source/WebKit/UIProcess/Notifications/Cocoa/WebNotificationProviderCocoa.mm:40 >>> + return nullptr; >> >> It would be nice if this returned makeUniqueRef<API::NotificationProvider>(); if it's not enabled. Then we would never need to null check m_provider in WebNotificationManagerProxy, which can also be changed from a std::unique_ptr to a UniqueRef. Right now it can never be null, and I think we should keep that. > > This is to support the above - Note that *if* this returns null, then the WebNotificationManagerProxy will create the default API::NotificationProvider. > > This is necessary for the weird branch of having this feature enabled at runtime or not. This has one call site. Immediately after it you have this: if (!m_provider) m_provider = makeUnique<API::NotificationProvider>(); I don't understand how returning null here and returning makeUnique<API::NotificationProvider>(); are different
Alex Christensen
Comment 5 2021-10-14 21:00:24 PDT
Comment on attachment 441326 [details] Patch v1 View in context: https://bugs.webkit.org/attachment.cgi?id=441326&action=review >>> Source/WebKit/UIProcess/Notifications/Cocoa/WebNotificationProviderCocoa.mm:40 >>> + return nullptr; >> >> It would be nice if this returned makeUniqueRef<API::NotificationProvider>(); if it's not enabled. Then we would never need to null check m_provider in WebNotificationManagerProxy, which can also be changed from a std::unique_ptr to a UniqueRef. Right now it can never be null, and I think we should keep that. > > This is to support the above - Note that *if* this returns null, then the WebNotificationManagerProxy will create the default API::NotificationProvider. > > This is necessary for the weird branch of having this feature enabled at runtime or not. This has one call site. Immediately after it you have this: if (!m_provider) m_provider = makeUnique<API::NotificationProvider>(); I don't understand how returning null here and returning makeUnique<API::NotificationProvider>(); are different
Brady Eidson
Comment 6 2021-10-14 21:03:42 PDT
Brady Eidson
Comment 7 2021-10-14 23:40:18 PDT
Brady Eidson
Comment 8 2021-10-15 01:20:54 PDT
EWS
Comment 9 2021-10-15 02:26:15 PDT
Committed r284240 (243049@main): <https://commits.webkit.org/243049@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 441345 [details].
WebKit Commit Bot
Comment 10 2021-10-18 17:20:10 PDT
Re-opened since this is blocked by bug 231926
Brady Eidson
Comment 11 2021-10-19 09:14:29 PDT
Created attachment 441736 [details] New approach v1
Brady Eidson
Comment 12 2021-10-19 09:17:15 PDT
Created attachment 441738 [details] New approach v2
Alex Christensen
Comment 13 2021-10-19 09:25:02 PDT
Comment on attachment 441736 [details] New approach v1 View in context: https://bugs.webkit.org/attachment.cgi?id=441736&action=review > Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp:295 > + if (decoder.messageName() == Messages::WebPageProxy::ShowNotification::name()) This is usually in generated code, and WebPageProxies aren't in the network process. I would add this: // FIXME: move these to a new message receiver type. That way we can make the NetworkSession own one of the new type and the WebPageProxy also own one of the new type, and both would forward messages to that new type and this would be auto-generated. > Source/WebKit/WebProcess/Notifications/WebNotificationManager.cpp:141 > +template<typename U> bool sendNotificationMessage(WebProcess& process, U&& message, WebPage* page) Can this be a WebPage& ? > Source/WebKit/WebProcess/Notifications/WebNotificationManager.cpp:148 > + { unnecessary
Brady Eidson
Comment 14 2021-10-19 09:58:47 PDT
(In reply to Alex Christensen from comment #13) > Comment on attachment 441736 [details] > New approach v1 > > View in context: > https://bugs.webkit.org/attachment.cgi?id=441736&action=review > > > Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp:295 > > + if (decoder.messageName() == Messages::WebPageProxy::ShowNotification::name()) > > This is usually in generated code, and WebPageProxies aren't in the network > process. I would add this: > // FIXME: move these to a new message receiver type. > That way we can make the NetworkSession own one of the new type and the > WebPageProxy also own one of the new type, and both would forward messages > to that new type and this would be auto-generated. Yes, we can autogenerate that type of thing in the future, but manual code will still have to be written for both on both sides of the wire. There's no example of this yet. Yay for new ground. > > > Source/WebKit/WebProcess/Notifications/WebNotificationManager.cpp:141 > > +template<typename U> bool sendNotificationMessage(WebProcess& process, U&& message, WebPage* page) > > Can this be a WebPage& ? > > > Source/WebKit/WebProcess/Notifications/WebNotificationManager.cpp:148 > > + { > > unnecessary Fixing these.
Brady Eidson
Comment 15 2021-10-19 10:02:10 PDT
Created attachment 441746 [details] New approach v3
Chris Dumez
Comment 16 2021-10-19 10:04:35 PDT
Comment on attachment 441736 [details] New approach v1 View in context: https://bugs.webkit.org/attachment.cgi?id=441736&action=review > Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp:274 > + if (decoder.messageReceiverName() == Messages::WebPageProxy::messageReceiverName()) { This looks wrong. I don't think NetworkConnectionToWebProcess should be dealing with WebPageProxy messages. Why can't the call site choose an appropriate message name based on which connection it is sending the IPC on? If this isn't possible, an alternative would be to introduce a new MessageReceiver type (e.g. WebNotificationProxy) in Shared/ that could be reused from both the network process and the UIProcess. It would look a lot nicer than having the network process handle WebPageProxy messages (which is super confusing).
Chris Dumez
Comment 17 2021-10-19 10:05:33 PDT
Comment on attachment 441746 [details] New approach v3 View in context: https://bugs.webkit.org/attachment.cgi?id=441746&action=review > Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp:274 > + if (decoder.messageReceiverName() == Messages::WebPageProxy::messageReceiverName()) { Looks like this new approach has the same issue.
Alex Christensen
Comment 18 2021-10-19 10:09:35 PDT
Comment on attachment 441746 [details] New approach v3 View in context: https://bugs.webkit.org/attachment.cgi?id=441746&action=review > Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.h:41 > + void cancelNotification(uint64_t notificationID); This should be a strongly typed identifier.
Brady Eidson
Comment 19 2021-10-19 10:33:26 PDT
(In reply to Chris Dumez from comment #16) > Comment on attachment 441736 [details] > New approach v1 > > View in context: > https://bugs.webkit.org/attachment.cgi?id=441736&action=review > > > Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp:274 > > + if (decoder.messageReceiverName() == Messages::WebPageProxy::messageReceiverName()) { > > This looks wrong. I don't think NetworkConnectionToWebProcess should be > dealing with WebPageProxy messages. Why can't the call site choose an > appropriate message name based on which connection it is sending the IPC on? I *literally asked you about this yesterday on Slack* and you said "No reason why not" Why should we duplicate message types for the exact identically same message (we shouldn't) > If this isn't possible, an alternative would be to introduce a new > MessageReceiver type (e.g. WebNotificationProxy) in Shared/ that could be > reused from both the network process and the UIProcess. It would look a lot > nicer than having the network process handle WebPageProxy messages (which is > super confusing). That's exactly what the FIXME says.
Brady Eidson
Comment 20 2021-10-19 10:34:28 PDT
(In reply to Alex Christensen from comment #18) > Comment on attachment 441746 [details] > New approach v3 > > View in context: > https://bugs.webkit.org/attachment.cgi?id=441746&action=review > > > Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.h:41 > > + void cancelNotification(uint64_t notificationID); > > This should be a strongly typed identifier. Seems like relevant cleanup for later (definitely not relevant to this patch)
Brady Eidson
Comment 21 2021-10-19 10:35:19 PDT
I'll work on the message receiver bit. Sad about the misunderstanding yesterday that led me to skip bothering with it.
Brady Eidson
Comment 22 2021-10-20 14:52:30 PDT
That was done in https://trac.webkit.org/changeset/284564/webkit Rebasing this patch on that work now.
Brady Eidson
Comment 23 2021-10-20 16:54:26 PDT
Created attachment 441955 [details] Patch with better messaging v1
Alex Christensen
Comment 24 2021-10-20 16:58:42 PDT
Comment on attachment 441955 [details] Patch with better messaging v1 View in context: https://bugs.webkit.org/attachment.cgi?id=441955&action=review > Source/WebCore/ChangeLog:8 > + No new tests (OOPS!). remove
Alex Christensen
Comment 25 2021-10-20 17:01:26 PDT
Comment on attachment 441955 [details] Patch with better messaging v1 View in context: https://bugs.webkit.org/attachment.cgi?id=441955&action=review > Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.h:2 > + * Copyright (C) 2020 Apple Inc. All rights reserved. 2021
Brady Eidson
Comment 26 2021-10-20 17:06:17 PDT
Brady Eidson
Comment 27 2021-10-20 17:57:11 PDT
Brady Eidson
Comment 28 2021-10-20 18:48:46 PDT
Created attachment 441971 [details] Another try PFL
Brady Eidson
Comment 29 2021-10-20 19:28:20 PDT
Created attachment 441973 [details] PFL again
Brady Eidson
Comment 30 2021-10-20 21:21:58 PDT
Have to disable BuiltInNotificationsEnabled on some layouttests for now. Re-enabling is covered by <rdar://84492078>
Brady Eidson
Comment 31 2021-10-20 21:22:32 PDT
Created attachment 441982 [details] PFL maybe the last one?
EWS Watchlist
Comment 32 2021-10-20 21:23:17 PDT
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Brady Eidson
Comment 33 2021-10-20 21:51:01 PDT
Created attachment 441984 [details] PFL with better way to disable these tests
EWS
Comment 34 2021-10-20 23:51:58 PDT
Committed r284591 (243324@main): <https://commits.webkit.org/243324@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 441984 [details].
Note You need to log in before you can comment on or make changes to this bug.