RESOLVED FIXED Bug 238544
ServiceWorkerRegistration.getNotifications should list all persistent notifications
https://bugs.webkit.org/show_bug.cgi?id=238544
Summary ServiceWorkerRegistration.getNotifications should list all persistent notific...
youenn fablet
Reported 2022-03-30 03:08:20 PDT
ServiceWorkerRegistration.getNotifications should list all persistent notifications
Attachments
Patch (32.49 KB, patch)
2022-03-30 03:29 PDT, youenn fablet
no flags
Patch (32.63 KB, patch)
2022-03-31 01:57 PDT, youenn fablet
no flags
Patch for landing (33.08 KB, patch)
2022-04-01 02:12 PDT, youenn fablet
no flags
youenn fablet
Comment 1 2022-03-30 03:29:18 PDT
youenn fablet
Comment 2 2022-03-31 01:57:07 PDT
Darin Adler
Comment 3 2022-03-31 09:37:59 PDT
Comment on attachment 456220 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=456220&action=review Not confident that all this code > Source/WebCore/workers/service/ServiceWorkerContainer.cpp:627 > + std::sort(data.begin(), data.end(), [](auto& a, auto& b) { return a.creationTime < b.creationTime; }); Is it safe to use an unstable sort here? If there are any two notifications with the same creationTime, then they could end up shuffled randomly by the sort algorithm. If we used a stable sort, then they would stay in the order they are already in, even if the times happened to be identical. > Source/WebCore/workers/service/WorkerSWClientConnection.cpp:84 > + for (auto& callback : navigationPreloadStateCallbacks.values()) > + callback(Exception { AbortError, "context stopped"_s }); This is in hash table (pseudo-random) order. Is that OK? > Source/WebCore/workers/service/WorkerSWClientConnection.cpp:88 > + for (auto& callback : getNotificationsCallbacks.values()) > callback(Exception { AbortError, "context stopped"_s }); Ditto. > Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.cpp:306 > + Vector<NotificationData> result; Should we be reserving initial capacity? Does this typically get sized the same as m_notifications or is it usually a much smaller subset? > Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.cpp:315 > + callback(WTFMove(result)); Can this vector be long-lived? If so, maybe we should do shrinkToFit after building it and before transferring ownership?
youenn fablet
Comment 4 2022-04-01 02:04:32 PDT
(In reply to Darin Adler from comment #3) > Comment on attachment 456220 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=456220&action=review > > Not confident that all this code > > > Source/WebCore/workers/service/ServiceWorkerContainer.cpp:627 > > + std::sort(data.begin(), data.end(), [](auto& a, auto& b) { return a.creationTime < b.creationTime; }); > > Is it safe to use an unstable sort here? If there are any two notifications > with the same creationTime, then they could end up shuffled randomly by the > sort algorithm. If we used a stable sort, then they would stay in the order > they are already in, even if the times happened to be identical. We get the vector from a UIProcess HashMap, there is no guarantee the order of the pre-sorted Vector will be stable. To be bullet proof, we would need to do the sorting in UIProcess and rely on both creationTime and UIProcess incrementing counter. I'll change this. > > Source/WebCore/workers/service/WorkerSWClientConnection.cpp:84 > > + for (auto& callback : navigationPreloadStateCallbacks.values()) > > + callback(Exception { AbortError, "context stopped"_s }); > > This is in hash table (pseudo-random) order. Is that OK? I think this is ok. These completion handlers can complete in no particular order. > > Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.cpp:306 > > + Vector<NotificationData> result; > > Should we be reserving initial capacity? Does this typically get sized the > same as m_notifications or is it usually a much smaller subset? Difficult to say. I would expect most web sites to have a single registration doing notifications but that is not guaranteed. If tag is empty, my guess is that it should be roughly the same as m_notifications. If tag is used, it probably means it is only a small subset. > > Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.cpp:315 > > + callback(WTFMove(result)); > > Can this vector be long-lived? If so, maybe we should do shrinkToFit after > building it and before transferring ownership? Vector is short lived, it is sent directly to WebProcess through IPC.
youenn fablet
Comment 5 2022-04-01 02:12:52 PDT
Created attachment 456338 [details] Patch for landing
EWS
Comment 6 2022-04-01 06:13:14 PDT
Committed r292218 (249121@main): <https://commits.webkit.org/249121@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 456338 [details].
Radar WebKit Bug Importer
Comment 7 2022-04-01 06:14:17 PDT
Note You need to log in before you can comment on or make changes to this bug.