-
Notifications
You must be signed in to change notification settings - Fork 28
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
Remove permission check #326
Conversation
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.
Personally I'm still undecided about this one and would like to hear from @reillyeon, especially as I don't know if adapting the Chromium implementation to this change would count as breaking backward compatibility, or if there are plans to add a UI for this permission in the pipeline.
@@ -345,22 +287,6 @@ <h3> | |||
</li> | |||
<li>Run the following steps <a>in parallel</a>: | |||
<ol> | |||
<li>Let |state:PermissionState| be the result of <a>requesting |
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.
Without these steps, I think you can drop the "run the following steps in parallel above", as all the remaining sub-steps are run from a queued global task.
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.
Ah, good suggestion!
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.
Acquiring the lock needs to happen in parallel.
239a418
to
f70fd9e
Compare
index.html
Outdated
@@ -343,67 +285,49 @@ <h3> | |||
</li> | |||
<li>Let |promise:Promise| be [=a new promise=]. | |||
</li> | |||
<li>Run the following steps <a>in parallel</a>: | |||
<li> | |||
<a>Queue a global task</a> on the <a>screen wake lock task |
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.
Do we still need to queue a global task here? We're already in the main thread at this point.
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.
We don't technically need to but this provides implementations with the freedom to not return a settled Promise synchronously from this method, as otherwise this method doesn't need to be Promise-returning at all.
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.
as otherwise this method doesn't need to be Promise-returning at all.
Wouldn't this be a case of "we thought there should be async stuff happening, now there's not but we can't break backwards compatibility"? It's how we ended up with WakeLockSentinel.release() returning a resolved promise after #299, for example.
I'm not saying I'm in favor of doing that, at this point I'm more curious about whether this is standard practice, or even if I'm looking at it from the wrong perspective.
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.
This was discussed at TPAC 2022: https://www.w3.org/2022/09/15-dap-minutes.html#t21
The consensus is that this PR should be merged, but the pending review comments still need to be addressed.
@rakuco, could we merge this and then revise the global task stuff above?... I think the visibility checks being done in parallel are also wrong (should be done sync I think, because the document could disappear by the time the check is done), so we might need to give the whole spec a once over. However, what's more important now is to remove the permission check. |
Quick update... fixed the merge conflicts and fixed the broken cross reference to [=Document/visibility state=] |
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.
There are some issues with the latest merge commit that resulted in some wrong steps in request() that need to be fixed.
@rakuco, could we merge this and then revise the global task stuff above?... I think the visibility checks being done in parallel are also wrong (should be done sync I think, because the document could disappear by the time the check is done), so we might need to give the whole spec a once over.
Let's not block on the queue global task stuff then. With that said, I don't think the visibility checks are done in parallel, the idea behind queuing a global task while in parallel was to prevent that. We spent quite a lot of time in #299 trying to get this right, so I was hoping that the current version already made sense.
I'm also curious about WebKit/WebKit#4733 -- the PR mentions there's a pending discussion about prompts, so I wonder (or would like to double check) if we may end up having to revert this PR not too far in the future.
Finally: can you also send a WPT pull request removing the permission-related bits from the tests?
index.html
Outdated
</li> | ||
<li data-tests="wakelock-request-denied.https.html">If |state| is | ||
{{PermissionState/"denied"}}, then: | ||
<li>If |document|'s [=Document/visibility state=] is "hidden", then: |
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.
Something went wrong with the merge in these steps too: all the main substeps within the "Queue a global task" step have been duplicated inside the If document.[[ActiveLocks]]["screen"] is empty substep (see the Preview link).
index.html
Outdated
@@ -343,67 +285,49 @@ <h3> | |||
</li> | |||
<li>Let |promise:Promise| be [=a new promise=]. | |||
</li> | |||
<li>Run the following steps <a>in parallel</a>: | |||
<li> | |||
<a>Queue a global task</a> on the <a>screen wake lock task |
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.
as otherwise this method doesn't need to be Promise-returning at all.
Wouldn't this be a case of "we thought there should be async stuff happening, now there's not but we can't break backwards compatibility"? It's how we ended up with WakeLockSentinel.release() returning a resolved promise after #299, for example.
I'm not saying I'm in favor of doing that, at this point I'm more curious about whether this is standard practice, or even if I'm looking at it from the wrong perspective.
Sent PR to remove test web-platform-tests/wpt#36121 Will start working on the other tests as part of #351 |
@rakuco wrote:
Not exactly. This is just a defensive design strategy in case we need to reject the promise in the future for some reason.
(As a followup...) It is. I think we should update |
I’m happy to see @marcoscaceres continue his substantial contributions (also in #351) in this WG. As the co-chair it is also my duty to remind you to either join this WG or use License Grants from Non-Participants mechanism. @xfq can you enable https://github.com/w3c/ash-nazg for this repo? |
I don't think this is racy. Firstly, it never makes sense to tell the site that it failed to release a lock, if there were even possible. The site has successfully expressed its desire to release the lock and it is up to the user agent to convey that to the underlying platform. There may be many other components of the system still holding the lock (including other sites, or other script on the same site) but that state is invisible to the current site. |
@anssiko, thanks for the reminder; I'll see what I can do about joining (though chances are low until objections are addressed). Just want to point out that this PR predates me joining Apple, so I'm just making an editorial contribution here. For #351, I can close that and maybe get @rakuco or someone else to send a PR to address the corresponding issue (#350)? (now regretting not making this also a join deliverable with WebAppsWG 😢) |
Tracked in w3c/ash-nazg#252 |
@@ -309,11 +251,19 @@ <h3> | |||
The <dfn>request()</dfn> method | |||
</h3> | |||
<p data-tests="wakelock-type.https.any.html"> | |||
The <code>request(|type:WakeLockType|)</code> method steps are: | |||
The `request(|type:WakeLockType|)` method steps are: |
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.
ReSpec doesn't seem to like this change. request(|type:WakeLockType|)
is being written literally like that in the page.
</p> | ||
<ol class="algorithm"> | ||
<li>Let |document:Document| be [=this=]'s [=relevant global | ||
object=]'s [=associated Document=]. | ||
object=]'s [=associated `Document`=]. |
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.
The change in the order of steps here looks unrelated. They might even make sense, but I'd rather do this in another PR.
<li data-tests="wakelock-document-hidden-manual.https.html">If | ||
|document|'s [=Document/visibility state=] is "`hidden`", return [=a | ||
promise rejected with=] {{"NotAllowedError"}} {{DOMException}}. | ||
</li> | ||
<li>Let |promise:Promise| be [=a new promise=]. | ||
</li> | ||
<li>Run the following steps <a>in parallel</a>: | ||
<li>[=In parallel=]: |
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.
Was there a particular reason to change the original version? It's just saying the same thing.
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 reads better.
<ol> | ||
<li>Let |state:PermissionState| be the result of <a>requesting | ||
permission to use</a> "`screen-wake-lock`". | ||
<li>Attempt to [=acquire a wake lock=] of type |
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.
The steps still look weird:
- The check for whether document.[[ActiveLocks]]["screen"] is empty was dropped.
- Only acquiring the wake lock happened in parallel, document.[[ActiveLocks]] was only read and manipulated from the the main thread to avoid races, but now all these steps are happening in parallel.
@@ -721,32 +624,29 @@ <h3> | |||
<li>Remove |lock| from | |||
|document|.{{Document/[[ActiveLocks]]}}[|type|]. | |||
</li> | |||
<li>[=Queue a task=] on the [=screen wake lock task source=] to: |
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.
The changes to this section also look unrelated to permissions and should be sent in a separate PR.
@rakuco could you take this over? (please remove the changes you don't agree with.) As I'm not a member of this group, I can't make any further changes. |
Closes #324
Please see #324 for rationale and discussion.
The following tasks have been completed:
Implementation commitment:
Preview | Diff