-
Notifications
You must be signed in to change notification settings - Fork 29
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
[spec] Support saved queries for selectURL #188
Conversation
We update the spec to support saved queries, as a followup to #176.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM % a nit
@wanderview Please take a look, thanks! |
spec.bs
Outdated
1. Let |savedQueryName| be |options|["`savedQuery`"]. | ||
1. If |savedQueryName| is nonempty, then: | ||
1. Let |site| be the result of running [=obtain a site=] on |workletDataOrigin|. | ||
1. Let |savedIndex| be the result of running [=get the index for a saved query=] on |navigable|, |site|, and |savedQueryName|. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears that you could use the same name for two completely different queries and this would return the value of the first query. Is this the desired behavior?
For example, maybe we should return an error if the parameters passed to selectUrl in the second call differ from the first call? Or should the second call override the parameters from the first selectUrl by creating a new saved query?
This is kind of stemming from the awkardness of adding a parameter to an existing function call. It seems like what you might want is something more like how SQL has separate "prepare statement" and "execute statement" calls. You could consider a prepareSelectUrl()
that takes all params and assigns a name. Then a separate selectUrl(name)
call that operates only on the name without any other params.
If we want to keep a single function call that is overloaded I think we should just be intentional if the site calls it twice with different arguments, but the same name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears that you could use the same name for two completely different queries and this would return the value of the first query. Is this the desired behavior?
The short answer is: probably yes.
The long answer is that I did forget to take into account the operation name, and I may not want to ignore that. I am thinking about that some more offline.
But we deliberately want the array of URLs to be able to be different, and note that we do handle the error that happens if we end up with an out of range index because of this.
We would ignore any passed data
for options
in the case that we are able to retrieve a saved query result. The other options
parameters are still handled.
So there shouldn't be a need for a separate prepareSelectUrl()
statement. I just need to decide whether or not operation names should be incorporated into the map, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case I recommend returning an error if the operation name doesn't match the previously used operation name for the same saved query. Its probably a developer mistake. Allowing the same saved query name for different operations sounds like a footgun.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After further contemplation and discussion with the team, we've decided two things.
- Saved queries will be stored on a per-origin (instead of per-site) basis. I have updated this spec PR accordingly.
- We do indeed want names of saved queries to be independent of operation names, and for the storing and lookup of saved queries to ignore the operation names. So two calls to
selectURL()
that have different operation names could still access the same saved query result if they use the samesavedQuery
parameter. While this could lead to some developers making mistakes, it also allows for greater flexibility and simplicity. We would need to be sure to document this properly, of course, including in the current explainer PR (where the effect of differing operation names is currently not mentioned).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to double-check, if you start with being more restrictive where you throw an error for same-savedQuery and different-operation, then you can relax that later if needed. If you do what you propose and then find developers are having trouble you can't safely make it more restrictive in a backward compatible way.
I'm not going to block the PR on this, but I want to double-check because I think in web standards we generally want to be more restrictive unless there is a compelling reason to do otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have particularly strong feelings here. It seems unlikely to be a footgun to me, but at the same time I can't think of a good reason to use the same saved-query on two different operations. So, let's say that we go ahead with your proposal here as it seems reasonable.
So now the proposal is that a saved-query key is <origin, operation_name, saved_query_name>
.
For similar reasons, what would you think about also including the worklet script url as part of the key?
e.g., <origin, operation_name, worklet_script_url, saved_query_name>
Like operations, presumably different scripts could have different behavior, even if the operation name is the same. This gets a little funky in that urls aren't actually const resources, but still.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I have updated the spec so that queries are keyed by <origin, operation_name, saved_query_name>
.
I think we should just not reuse the query (i.e. act as if it's the first time this query is seen) if there is different operation name, rather than throwing, to simplify things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be clear, keying on <origin, operation_name, saved_query_name>
does your proposal above, right? It ignores mismatched operations because you end up with different slots in your map. To do what I was proposing I think the key needs to be <origin, saved_query_name>
and then in the map value the operation_name
is saved so you can compare it on lookup.
(Edit: Or maybe I am confused about the key here? Sorry if I am missing something.)
I'm not sure I understand enough about how different worklets can mix on a page to have an opinion on how to treat conflicting scripts URLs. If we assume folks are going to hash URLs for different versions of the same worklet, though, it does seem like a flow we should be concerned with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be clear, keying on <origin, operation_name, saved_query_name> does your proposal above, right? It ignores mismatched operations because you end up with different slots in your map. To do what I was proposing I think the key needs to be <origin, saved_query_name> and then in the map value the operation_name is saved so you can compare it on lookup.
Yes. The key would need to be <origin, saved_query_name>
to do what you propose. But I think it would be best to key on <origin, operation_name, saved_query_name>
instead because it seems to make more sense for us to simply narrow the scope for the saved queries further from the beginning, rather than to add additional errors. We wouldn't throw if there is a mismatch, but we wouldn't re-use a query in the case of a mismatch either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one spec language improvement fixed. This changes the setting and getting of the saved query using tuples as the key.
After further discussion with the team, we decided to also key on the script's URL. So now I have updated the spec so the the key is Would you mind please taking one more look? @wanderview @xyaoinum Thanks! |
I added one more comment, but otherwise LGTM. |
Still LGTM |
SHA: 2951ea5 Reason: push, by pythagoraskitty Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
See explainer update at WICG/shared-storage#176 and spec updates at WICG/shared-storage#188 WICG/shared-storage#202 Currently the feature is disabled by default. We will enable by default after the I2S has been sent and approved. Bug: 367440966 Change-Id: I82d731a7e2d6bcc2368658a619a6eb1d4d751025 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5920781 Commit-Queue: Cammie Smith Barnes <cammie@chromium.org> Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1374887}
We add support for saved queries, keyed by (`data_origin`, `script_url`, `operation_name`, `query_name`). When a named query is first invoked, the per page budgets are charged as usual, the index result is stored for later in case the query is reused from the same page. On query reuse, the previously calculated and stored index result will be used to select the URL at that index in the current list, and the per page budgets will not be re-charged. When the page is destroyed, all associated saved queries are also destroyed. See explainer update at WICG/shared-storage#176 and spec updates at WICG/shared-storage#188 WICG/shared-storage#202 Bug: 367440966 Change-Id: I89fd7e65cd14c9d60d6ac53906f95593a2259a37 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5868889 Reviewed-by: Ken Buchanan <kenrb@chromium.org> Reviewed-by: Yao Xiao <yaoxia@chromium.org> Commit-Queue: Cammie Smith Barnes <cammie@chromium.org> Cr-Commit-Position: refs/heads/main@{#1375507}
We add support for saved queries, keyed by (`data_origin`, `script_url`, `operation_name`, `query_name`). When a named query is first invoked, the per page budgets are charged as usual, the index result is stored for later in case the query is reused from the same page. On query reuse, the previously calculated and stored index result will be used to select the URL at that index in the current list, and the per page budgets will not be re-charged. When the page is destroyed, all associated saved queries are also destroyed. See explainer update at WICG/shared-storage#176 and spec updates at WICG/shared-storage#188 WICG/shared-storage#202 Bug: 367440966 Change-Id: I89fd7e65cd14c9d60d6ac53906f95593a2259a37 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5868889 Reviewed-by: Ken Buchanan <kenrb@chromium.org> Reviewed-by: Yao Xiao <yaoxia@chromium.org> Commit-Queue: Cammie Smith Barnes <cammie@chromium.org> Cr-Commit-Position: refs/heads/main@{#1375507}
We add support for saved queries, keyed by (`data_origin`, `script_url`, `operation_name`, `query_name`). When a named query is first invoked, the per page budgets are charged as usual, the index result is stored for later in case the query is reused from the same page. On query reuse, the previously calculated and stored index result will be used to select the URL at that index in the current list, and the per page budgets will not be re-charged. When the page is destroyed, all associated saved queries are also destroyed. See explainer update at WICG/shared-storage#176 and spec updates at WICG/shared-storage#188 WICG/shared-storage#202 Bug: 367440966 Change-Id: I89fd7e65cd14c9d60d6ac53906f95593a2259a37 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5868889 Reviewed-by: Ken Buchanan <kenrb@chromium.org> Reviewed-by: Yao Xiao <yaoxia@chromium.org> Commit-Queue: Cammie Smith Barnes <cammie@chromium.org> Cr-Commit-Position: refs/heads/main@{#1375507} Co-authored-by: Camillia Smith Barnes <cammie@chromium.org>
… selectURL, a=testonly Automatic update from web-platform-tests Shared Storage: Support saved queries in selectURL (#48868) We add support for saved queries, keyed by (`data_origin`, `script_url`, `operation_name`, `query_name`). When a named query is first invoked, the per page budgets are charged as usual, the index result is stored for later in case the query is reused from the same page. On query reuse, the previously calculated and stored index result will be used to select the URL at that index in the current list, and the per page budgets will not be re-charged. When the page is destroyed, all associated saved queries are also destroyed. See explainer update at WICG/shared-storage#176 and spec updates at WICG/shared-storage#188 WICG/shared-storage#202 Bug: 367440966 Change-Id: I89fd7e65cd14c9d60d6ac53906f95593a2259a37 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5868889 Reviewed-by: Ken Buchanan <kenrb@chromium.org> Reviewed-by: Yao Xiao <yaoxia@chromium.org> Commit-Queue: Cammie Smith Barnes <cammie@chromium.org> Cr-Commit-Position: refs/heads/main@{#1375507} Co-authored-by: Camillia Smith Barnes <cammie@chromium.org> -- wpt-commits: 3c0bfa31dc842d0dbce0e377bfd39a4aa0ec4fd9 wpt-pr: 48868
… selectURL, a=testonly Automatic update from web-platform-tests Shared Storage: Support saved queries in selectURL (#48868) We add support for saved queries, keyed by (`data_origin`, `script_url`, `operation_name`, `query_name`). When a named query is first invoked, the per page budgets are charged as usual, the index result is stored for later in case the query is reused from the same page. On query reuse, the previously calculated and stored index result will be used to select the URL at that index in the current list, and the per page budgets will not be re-charged. When the page is destroyed, all associated saved queries are also destroyed. See explainer update at WICG/shared-storage#176 and spec updates at WICG/shared-storage#188 WICG/shared-storage#202 Bug: 367440966 Change-Id: I89fd7e65cd14c9d60d6ac53906f95593a2259a37 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5868889 Reviewed-by: Ken Buchanan <kenrb@chromium.org> Reviewed-by: Yao Xiao <yaoxia@chromium.org> Commit-Queue: Cammie Smith Barnes <cammie@chromium.org> Cr-Commit-Position: refs/heads/main@{#1375507} Co-authored-by: Camillia Smith Barnes <cammie@chromium.org> -- wpt-commits: 3c0bfa31dc842d0dbce0e377bfd39a4aa0ec4fd9 wpt-pr: 48868
… selectURL, a=testonly Automatic update from web-platform-tests Shared Storage: Support saved queries in selectURL (#48868) We add support for saved queries, keyed by (`data_origin`, `script_url`, `operation_name`, `query_name`). When a named query is first invoked, the per page budgets are charged as usual, the index result is stored for later in case the query is reused from the same page. On query reuse, the previously calculated and stored index result will be used to select the URL at that index in the current list, and the per page budgets will not be re-charged. When the page is destroyed, all associated saved queries are also destroyed. See explainer update at WICG/shared-storage#176 and spec updates at WICG/shared-storage#188 WICG/shared-storage#202 Bug: 367440966 Change-Id: I89fd7e65cd14c9d60d6ac53906f95593a2259a37 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5868889 Reviewed-by: Ken Buchanan <kenrbchromium.org> Reviewed-by: Yao Xiao <yaoxiachromium.org> Commit-Queue: Cammie Smith Barnes <cammiechromium.org> Cr-Commit-Position: refs/heads/main{#1375507} Co-authored-by: Camillia Smith Barnes <cammiechromium.org> -- wpt-commits: 3c0bfa31dc842d0dbce0e377bfd39a4aa0ec4fd9 wpt-pr: 48868 UltraBlame original commit: be7ca250d6301d51162a3b8b73ec9f0fa1beecf0
… selectURL, a=testonly Automatic update from web-platform-tests Shared Storage: Support saved queries in selectURL (#48868) We add support for saved queries, keyed by (`data_origin`, `script_url`, `operation_name`, `query_name`). When a named query is first invoked, the per page budgets are charged as usual, the index result is stored for later in case the query is reused from the same page. On query reuse, the previously calculated and stored index result will be used to select the URL at that index in the current list, and the per page budgets will not be re-charged. When the page is destroyed, all associated saved queries are also destroyed. See explainer update at WICG/shared-storage#176 and spec updates at WICG/shared-storage#188 WICG/shared-storage#202 Bug: 367440966 Change-Id: I89fd7e65cd14c9d60d6ac53906f95593a2259a37 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5868889 Reviewed-by: Ken Buchanan <kenrbchromium.org> Reviewed-by: Yao Xiao <yaoxiachromium.org> Commit-Queue: Cammie Smith Barnes <cammiechromium.org> Cr-Commit-Position: refs/heads/main{#1375507} Co-authored-by: Camillia Smith Barnes <cammiechromium.org> -- wpt-commits: 3c0bfa31dc842d0dbce0e377bfd39a4aa0ec4fd9 wpt-pr: 48868 UltraBlame original commit: be7ca250d6301d51162a3b8b73ec9f0fa1beecf0
… selectURL, a=testonly Automatic update from web-platform-tests Shared Storage: Support saved queries in selectURL (#48868) We add support for saved queries, keyed by (`data_origin`, `script_url`, `operation_name`, `query_name`). When a named query is first invoked, the per page budgets are charged as usual, the index result is stored for later in case the query is reused from the same page. On query reuse, the previously calculated and stored index result will be used to select the URL at that index in the current list, and the per page budgets will not be re-charged. When the page is destroyed, all associated saved queries are also destroyed. See explainer update at WICG/shared-storage#176 and spec updates at WICG/shared-storage#188 WICG/shared-storage#202 Bug: 367440966 Change-Id: I89fd7e65cd14c9d60d6ac53906f95593a2259a37 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5868889 Reviewed-by: Ken Buchanan <kenrbchromium.org> Reviewed-by: Yao Xiao <yaoxiachromium.org> Commit-Queue: Cammie Smith Barnes <cammiechromium.org> Cr-Commit-Position: refs/heads/main{#1375507} Co-authored-by: Camillia Smith Barnes <cammiechromium.org> -- wpt-commits: 3c0bfa31dc842d0dbce0e377bfd39a4aa0ec4fd9 wpt-pr: 48868 UltraBlame original commit: be7ca250d6301d51162a3b8b73ec9f0fa1beecf0
… selectURL, a=testonly Automatic update from web-platform-tests Shared Storage: Support saved queries in selectURL (#48868) We add support for saved queries, keyed by (`data_origin`, `script_url`, `operation_name`, `query_name`). When a named query is first invoked, the per page budgets are charged as usual, the index result is stored for later in case the query is reused from the same page. On query reuse, the previously calculated and stored index result will be used to select the URL at that index in the current list, and the per page budgets will not be re-charged. When the page is destroyed, all associated saved queries are also destroyed. See explainer update at WICG/shared-storage#176 and spec updates at WICG/shared-storage#188 WICG/shared-storage#202 Bug: 367440966 Change-Id: I89fd7e65cd14c9d60d6ac53906f95593a2259a37 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5868889 Reviewed-by: Ken Buchanan <kenrb@chromium.org> Reviewed-by: Yao Xiao <yaoxia@chromium.org> Commit-Queue: Cammie Smith Barnes <cammie@chromium.org> Cr-Commit-Position: refs/heads/main@{#1375507} Co-authored-by: Camillia Smith Barnes <cammie@chromium.org> -- wpt-commits: 3c0bfa31dc842d0dbce0e377bfd39a4aa0ec4fd9 wpt-pr: 48868
We update the spec to support saved queries, as a followup to #176.
Preview | Diff