-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should the order of registrations returned by getRegistrations() be sorted by scope? #1465
Comments
FWIW I think we could make Chromium match the current spec by sorting by registration id. Do other browsers preserve the FIFO order? If so, maybe we should just change Chromium to do so and call it a day. @youennf @asutherland |
Per https://searchfox.org/mozilla-central/rev/9415ecf29ba1acbef9381335e0ecde5916ca4073/dom/serviceworkers/ServiceWorkerManager.cpp#1678 we (Firefox/Gecko) apparently order such that: // Sort by length, with longest match first.
// /foo/bar should be before /foo/
// Similarly /foo/b is between the two. This is an outgrowth of #287 deciding on longest prefix match now codified in https://w3c.github.io/ServiceWorker/#scope-match-algorithm. We store things as an ordered list, and we order the list so that if we traverse the list in order, we will naturally find the longest prefix first. This seems better than FIFO order to me and most consistent with the rest of the spec implementation. |
Thanks @asutherland. What order does getRegistrations() return when the scopes are "foo" and "bar"? |
WebKit implementation is sorting by insertion order. |
I think it's insertion-order dependent in that case, which makes it undesirable after all. For sanity of tests, I think the current spec of ordering based on the serialized scope is perhaps best. Actual insertion order depends on invocation of Set Registration invoked from inside Register which happens from inside the per-scope job queue which is triggered in parallel from Run Job queuing a task on an unnamed task source. |
So if we do that, will the order be a kind of lexicographical order but longer scopes will be earlier? For example:
Now I'm feeling that simple lexicographical order might be simpler. What do you think? |
In chromium, the registrations returned by getRegistrations() are composed of two parts (the corresponding code): stored registrations and unstored registrations. These two parts are inserted into the same vector and then return the vector. |
What's your opinion? @mattto |
To summarize the current situation:
I'm leaning toward insertion order as the one with least changes. For the tests that actually test the order, we'd have to make sure to set up the test correctly, as @asutherland mentions there are parallel tasks on unspecified task sources. But I don't feel strongly. cc @jakearchibald @jungkees |
A minor note: If my scopes pattern proposal moves forward then insertion order might work a little bit better. Of course, we can always define some sort order for the patterns and list-of-patterns but that may not be intuitive for developers. |
Insertion order sounds good to me if @asutherland is fine with that. I don't think we had any other intention except letting it be an ordered map for the level of compat we get from it. @mattto's comment on the test would be important, if we go with this decision. |
Insertion order works for me. |
Thanks everyone. It seems we have consensus to keep the current spec which requires insertion order. |
… ID. This patch makes the order of the registrations returned by getRegistrations() be sorted by registration ID, which fixes the flaky test of getregistrations.https.html. Related Github issue is in w3c/ServiceWorker#1465 Bug:925740 Change-Id: Iaa5716eec886232df61bd23487fbae5c63413e9c
… ID. This patch makes the order of the registrations returned by getRegistrations() be sorted by registration ID, which fixes the flaky test of getregistrations.https.html. Related Github issue is in w3c/ServiceWorker#1465 Bug: 925740 Change-Id: Iaa5716eec886232df61bd23487fbae5c63413e9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1984900 Reviewed-by: Makoto Shimazu <shimazu@chromium.org> Commit-Queue: Wei4 Wang <wei4.wang@intel.com> Cr-Commit-Position: refs/heads/master@{#732749}
… ID. This patch makes the order of the registrations returned by getRegistrations() be sorted by registration ID, which fixes the flaky test of getregistrations.https.html. Related Github issue is in w3c/ServiceWorker#1465 Bug: 925740 Change-Id: Iaa5716eec886232df61bd23487fbae5c63413e9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1984900 Reviewed-by: Makoto Shimazu <shimazu@chromium.org> Commit-Queue: Wei4 Wang <wei4.wang@intel.com> Cr-Commit-Position: refs/heads/master@{#732749}
… ID. (#21046) This patch makes the order of the registrations returned by getRegistrations() be sorted by registration ID, which fixes the flaky test of getregistrations.https.html. Related Github issue is in w3c/ServiceWorker#1465 Bug: 925740 Change-Id: Iaa5716eec886232df61bd23487fbae5c63413e9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1984900 Reviewed-by: Makoto Shimazu <shimazu@chromium.org> Commit-Queue: Wei4 Wang <wei4.wang@intel.com> Cr-Commit-Position: refs/heads/master@{#732749} Co-authored-by: WangW_intel <54053982+wangw-1991@users.noreply.github.com>
…gistrations() by registration ID., a=testonly Automatic update from web-platform-tests Sort the registrations returned by getRegistrations() by registration ID. (#21046) This patch makes the order of the registrations returned by getRegistrations() be sorted by registration ID, which fixes the flaky test of getregistrations.https.html. Related Github issue is in w3c/ServiceWorker#1465 Bug: 925740 Change-Id: Iaa5716eec886232df61bd23487fbae5c63413e9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1984900 Reviewed-by: Makoto Shimazu <shimazu@chromium.org> Commit-Queue: Wei4 Wang <wei4.wang@intel.com> Cr-Commit-Position: refs/heads/master@{#732749} Co-authored-by: WangW_intel <54053982+wangw-1991@users.noreply.github.com> -- wpt-commits: 3b8990ef1b99135ad02f13b3389049921054c88f wpt-pr: 21046
…gistrations() by registration ID., a=testonly Automatic update from web-platform-tests Sort the registrations returned by getRegistrations() by registration ID. (#21046) This patch makes the order of the registrations returned by getRegistrations() be sorted by registration ID, which fixes the flaky test of getregistrations.https.html. Related Github issue is in w3c/ServiceWorker#1465 Bug: 925740 Change-Id: Iaa5716eec886232df61bd23487fbae5c63413e9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1984900 Reviewed-by: Makoto Shimazu <shimazu@chromium.org> Commit-Queue: Wei4 Wang <wei4.wang@intel.com> Cr-Commit-Position: refs/heads/master@{#732749} Co-authored-by: WangW_intel <54053982+wangw-1991@users.noreply.github.com> -- wpt-commits: 3b8990ef1b99135ad02f13b3389049921054c88f wpt-pr: 21046
…gistrations() by registration ID., a=testonly Automatic update from web-platform-tests Sort the registrations returned by getRegistrations() by registration ID. (#21046) This patch makes the order of the registrations returned by getRegistrations() be sorted by registration ID, which fixes the flaky test of getregistrations.https.html. Related Github issue is in w3c/ServiceWorker#1465 Bug: 925740 Change-Id: Iaa5716eec886232df61bd23487fbae5c63413e9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1984900 Reviewed-by: Makoto Shimazu <shimazuchromium.org> Commit-Queue: Wei4 Wang <wei4.wangintel.com> Cr-Commit-Position: refs/heads/master{#732749} Co-authored-by: WangW_intel <54053982+wangw-1991users.noreply.github.com> -- wpt-commits: 3b8990ef1b99135ad02f13b3389049921054c88f wpt-pr: 21046 UltraBlame original commit: 3cdd21c5e484de85c344fe475dbeadb697bf886c
…gistrations() by registration ID., a=testonly Automatic update from web-platform-tests Sort the registrations returned by getRegistrations() by registration ID. (#21046) This patch makes the order of the registrations returned by getRegistrations() be sorted by registration ID, which fixes the flaky test of getregistrations.https.html. Related Github issue is in w3c/ServiceWorker#1465 Bug: 925740 Change-Id: Iaa5716eec886232df61bd23487fbae5c63413e9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1984900 Reviewed-by: Makoto Shimazu <shimazuchromium.org> Commit-Queue: Wei4 Wang <wei4.wangintel.com> Cr-Commit-Position: refs/heads/master{#732749} Co-authored-by: WangW_intel <54053982+wangw-1991users.noreply.github.com> -- wpt-commits: 3b8990ef1b99135ad02f13b3389049921054c88f wpt-pr: 21046 UltraBlame original commit: 3cdd21c5e484de85c344fe475dbeadb697bf886c
This question is raised when I tried to fix a flaky test in Chromium.
Currently we use an ordered map for scope to registration map but don't use the sort operation before iterating over the map (step 3.2 in the spec of getRegistrations()). This means that the order of the scope to registration map is FIFO.
Should we change it to sort the registration map before iteration, or is FIFO better in this case?
Do you have any thoughts?
The text was updated successfully, but these errors were encountered: