Skip to content
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

Replace return with resolve #227

Merged
merged 1 commit into from
Sep 2, 2024
Merged

Replace return with resolve #227

merged 1 commit into from
Sep 2, 2024

Conversation

beaufortfrancois
Copy link
Collaborator

@beaufortfrancois beaufortfrancois commented Jun 10, 2024

FIX #226


Preview | Diff

Copy link

@padenot padenot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obvious fix, looks good.

Comment on lines 379 to 380
2. If the previous step threw an exception, reject |promise| with that
exception and abort these steps.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. If the previous step threw an exception, reject |promise| with that
exception and abort these steps.
2. If the previous step [=exception/throws|threw=] an exception, [=queue a task=] using [=this=]'s [=media element event task source=] to [=/reject=] |promise| with that exception and abort these steps.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait! Then this algorithm is wrong then. Above it says it runs “in parallel”, and you can see from both implementations that it’s running on the main thread.

This needs be updated to return a promise rejected with X and the later run the steps in parallel.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reject path runs on the main thread because it's easy to catch some errors but the resolve path and some reject paths are not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to split those up then. This should match implementations. I can see like 6 reject cases that run on the main thread. Only see this in WebKit getting sent off main thread:

    if (videoElement.webkitSupportsPresentationMode(HTMLVideoElement::VideoPresentationMode::PictureInPicture)) {
        videoElementPictureInPicture->m_enterPictureInPicturePromise = WTFMove(promise);
        videoElement.webkitSetPresentationMode(HTMLVideoElement::VideoPresentationMode::PictureInPicture);
    }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even there... we would need to check what videoElement.webkitSetPresentationMode does and if it goes off main thread.

Comment on lines +353 to 354
4. [=/Resolve=] |promise| with the <a>Picture-in-Picture window</a> associated with
{{pictureInPictureElement}}.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
4. [=/Resolve=] |promise| with the <a>Picture-in-Picture window</a> associated with
{{pictureInPictureElement}}.
4. [=Queue a task=] using |video|'s [=media element event task source=] to [=/resolve=] |promise| with the <a>Picture-in-Picture window</a> associated with |video|'s {{pictureInPictureElement}}.

Comment on lines 351 to 352
3. If the previous step threw an exception, reject |promise| with that
exception and abort these steps.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
3. If the previous step threw an exception, reject |promise| with that
exception and abort these steps.
3. If the previous step [=exception/throws|threw=] an exception, [=queue a task=] using |video|'s [=media element event task source=] to [=/reject=] |promise| with that exception and abort these steps.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@marcoscaceres marcoscaceres Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be:

The {{requestPictureInPicture()}} method, when invoked, MUST run the following steps:

1. Run the <a>request Picture-in-Picture algorithm</a> with [=this=].
2. If the previous step [=exception/throws|threw=] an exception, return [=a promise rejected with=] that exception.
3. Return [=a promise resolved with=] [=this=]'s associated [=Picture-in-Picture window=].

As it never seems to go into parallel.

Copy link
Member

@marcoscaceres marcoscaceres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be like this... also, we should make better use of [=this=], but we can do that as a followup. I need to go through the document and fix up how internal things are accessed.

@joeyparrish
Copy link
Member

Thanks @beaufortfrancois for addressing this!

@beaufortfrancois
Copy link
Collaborator Author

What shall we do about this PR?
It seems like updating the spec with suggested changes from @marcoscaceres would make current implementations not compliant.

@beaufortfrancois
Copy link
Collaborator Author

If that's okay with everyone, I'll merge this PR and will open an issue about @marcoscaceres's feedback

@beaufortfrancois beaufortfrancois merged commit e819c96 into main Sep 2, 2024
2 checks passed
@beaufortfrancois beaufortfrancois deleted the fix branch September 2, 2024 07:34
github-actions bot added a commit that referenced this pull request Sep 2, 2024
SHA: e819c96
Reason: push, by beaufortfrancois

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@beaufortfrancois
Copy link
Collaborator Author

I've opened #229

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typo: Return promise vs resolve promise
5 participants