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

WIP: Implement HTMLMediaElement.loop attribute #22321

Closed
wants to merge 5 commits into from

Conversation

@kkpoon
Copy link
Contributor

kkpoon commented Nov 30, 2018

Implement HTMLMediaElement.loop attribute

  • enabled loop attribute in HTMLMediaElement
  • initialised loop value as Cell::new(false)
  • set playback_position to default_playback_start_position in PlayerEvent::EndOfStream event when loop is set

  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #22290 (github issue number if applicable).

  • There are tests for these changes OR

This change is Reviewable

@highfive
Copy link

highfive commented Nov 30, 2018

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @avadacatavra (or someone else) soon.

@highfive
Copy link

highfive commented Nov 30, 2018

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/htmlmediaelement.rs
  • @KiChjang: components/script/dom/htmlmediaelement.rs
@highfive
Copy link

highfive commented Nov 30, 2018

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
Copy link
Member

KiChjang left a comment

Thanks for working on this! I have some minor nits and a general question regarding the playback ended handler.

@@ -163,6 +163,8 @@ pub struct HTMLMediaElement {
paused: Cell<bool>,
/// <https://html.spec.whatwg.org/multipage/#attr-media-autoplay>
autoplaying: Cell<bool>,
/// <https://html.spec.whatwg.org/multipage/media.html#attr-media-loop>

This comment has been minimized.

Copy link
@KiChjang

KiChjang Nov 30, 2018

Member

Similar to the doc comments above, you'll need to remove media.html from the URL.

@@ -163,6 +163,8 @@ pub struct HTMLMediaElement {
paused: Cell<bool>,
/// <https://html.spec.whatwg.org/multipage/#attr-media-autoplay>
autoplaying: Cell<bool>,
/// <https://html.spec.whatwg.org/multipage/media.html#attr-media-loop>
loop: Cell<bool>,

This comment has been minimized.

Copy link
@KiChjang

KiChjang Nov 30, 2018

Member

loop is a reserved keyword in Rust, so I would be very surprised if this passed compilation.

This comment has been minimized.

Copy link
@ferjm

ferjm Nov 30, 2018

Member

I believe we don't need to add the attribute here in this case. We can use the make_bool_getter! and make_bool_setter! macros instead and use self.Loop() to check the attribute's value. You can take the autoplay attribute as an example.

@@ -1218,6 +1221,12 @@ impl HTMLMediaElement {
if self.ready_state.get() < ReadyState::HaveMetadata {
self.queue_dedicated_media_source_failure_steps();
}
if self.loop.get() {

This comment has been minimized.

Copy link
@KiChjang

KiChjang Nov 30, 2018

Member

The step annotations above indicate that this may be the incorrect location to add the looping functionality. I suspect the concept of the end of the media resource may not even be implemented yet. @ferjm Am I correct in claiming so? If not, where do we handle the playback ended event?

This comment has been minimized.

Copy link
@ferjm

ferjm Nov 30, 2018

Member

The concept of the end of the media resource is not implemented yet. It should be done as part of #22294.

I do believe this is the right place to add the looping functionality. But apart from seeking to the start position we need to do a couple of things more:

  • Do an early return if the previous condition is true, as we don't want to loop if there are errors.
  • Add a XXX comment saying that we need to identify if the stream is seekable or not to decide if we can loop. Please, reference #22297 in the comment.
  • Set playback_position to default_playback_start_position here.
Copy link
Member

ferjm left a comment

Thanks for the PR! This is a good start, but we need to make some changes. I left some comments in the code.

We need to add the loop attribute to the HTMLMediaElement WebIDL file. It's already there, but commented out.

We have a Web Platform Test at tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/audio_loop_base.html to test this functionality. You will likely need to update the tests expectations.

Finally, please, test that the code builds and works as expected locally. Note that the looping step may take some time as we don't have a media cache yet, so we discard everything that we play and seeking to the start will require fetching the data again from the network.

@@ -163,6 +163,8 @@ pub struct HTMLMediaElement {
paused: Cell<bool>,
/// <https://html.spec.whatwg.org/multipage/#attr-media-autoplay>
autoplaying: Cell<bool>,
/// <https://html.spec.whatwg.org/multipage/media.html#attr-media-loop>
loop: Cell<bool>,

This comment has been minimized.

Copy link
@ferjm

ferjm Nov 30, 2018

Member

I believe we don't need to add the attribute here in this case. We can use the make_bool_getter! and make_bool_setter! macros instead and use self.Loop() to check the attribute's value. You can take the autoplay attribute as an example.

@@ -1218,6 +1221,12 @@ impl HTMLMediaElement {
if self.ready_state.get() < ReadyState::HaveMetadata {
self.queue_dedicated_media_source_failure_steps();
}
if self.loop.get() {

This comment has been minimized.

Copy link
@ferjm

ferjm Nov 30, 2018

Member

The concept of the end of the media resource is not implemented yet. It should be done as part of #22294.

I do believe this is the right place to add the looping functionality. But apart from seeking to the start position we need to do a couple of things more:

  • Do an early return if the previous condition is true, as we don't want to loop if there are errors.
  • Add a XXX comment saying that we need to identify if the stream is seekable or not to decide if we can loop. Please, reference #22297 in the comment.
  • Set playback_position to default_playback_start_position here.
@kkpoon kkpoon changed the title Implement HTMLMediaElement.loop attribute WIP: Implement HTMLMediaElement.loop attribute Nov 30, 2018
@kkpoon
Copy link
Contributor Author

kkpoon commented Nov 30, 2018

Thanks for the comments. Working on it :D

@kkpoon kkpoon force-pushed the kkpoon:impl-HTMLMediaElement-loop branch 2 times, most recently from aa0cbad to 0f09af3 Dec 1, 2018
@germangb germangb mentioned this pull request Dec 1, 2018
3 of 3 tasks complete
@kkpoon
Copy link
Contributor Author

kkpoon commented Dec 3, 2018

Working hard to compile it locally...

@kkpoon kkpoon force-pushed the kkpoon:impl-HTMLMediaElement-loop branch from 0f09af3 to 1ca5944 Dec 5, 2018
@kkpoon
Copy link
Contributor Author

kkpoon commented Dec 6, 2018

Hi @ferjm, test-wpt and update-wpt have been run and after checking the tests updated by update-wpt, seem only tests/wpt/metadata/html/dom/interfaces.https.html.ini is related. Yet, it removes the testes about loop, is this expected?

@ferjm
Copy link
Member

ferjm commented Dec 6, 2018

Yes, that's expected. That test is checking the interfaces exposed to web content. We weren't exposing the loop attribute before this patch, that's why the test was failing in the loop related checks and why we needed to whitelist the failures. Now we are exposing this attribute, so the test shouldn't fail anymore.

Did you check if https://github.com/servo/servo/blob/master/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/audio_loop_base.html is passing?

bors-servo added a commit that referenced this pull request Dec 7, 2018
Implement Ended media attribute

<!-- Please describe your changes on the following line: -->

This PR should implement:
* New method `HTMLMediaElement::earliest_possible_position()` for the [earliest possible position](https://html.spec.whatwg.org/multipage/media.html#earliest-possible-position)
* `Ended` attribute following https://html.spec.whatwg.org/multipage/media.html#ended-playback
* Queue steps for when the playback position reaches the end

This PR contains placeholders for the following issues (I can rebase changes after the corresponding PRs get merged)
- #22321 (Define the Loop attribute)
- #22293 (To identify playback direction. Either forwards or backwards)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #22294.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22348)
<!-- Reviewable:end -->
@kkpoon
Copy link
Contributor Author

kkpoon commented Dec 8, 2018

Yes, that's expected. That test is checking the interfaces exposed to web content. We weren't exposing the loop attribute before this patch, that's why the test was failing in the loop related checks and why we needed to whitelist the failures. Now we are exposing this attribute, so the test shouldn't fail anymore.

Did you check if https://github.com/servo/servo/blob/master/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/audio_loop_base.html is passing?

Hi @ferjm

I check the servo.log from test-wtp,

{"source": "web-platform-tests", "test": "/html/semantics/embedded-content/media-elements/audio_loop_base.html", "thread": "MainThread", "time": 1544206279706, "action": "test_start", "pid": 2564}
{"status": "SKIP", "source": "web-platform-tests", "test": "/html/semantics/embedded-content/media-elements/audio_loop_base.html", "thread": "MainThread", "time": 1544206279706, "action": "test_end", "pid": 2564}

It seems being skipped. Any idea about this?, I run it on a machine in DigitalOcean. ubuntu-1804 8ram4vcpu.

Thanks

@jdm
Copy link
Member

jdm commented Dec 8, 2018

bors-servo added a commit that referenced this pull request Dec 10, 2018
Implement Ended media attribute

<!-- Please describe your changes on the following line: -->

This PR should implement:
* New method `HTMLMediaElement::earliest_possible_position()` for the [earliest possible position](https://html.spec.whatwg.org/multipage/media.html#earliest-possible-position)
* `Ended` attribute following https://html.spec.whatwg.org/multipage/media.html#ended-playback
* Queue steps for when the playback position reaches the end

This PR contains placeholders for the following issues (I can rebase changes after the corresponding PRs get merged)
- #22321 (Define the Loop attribute)
- #22293 (To identify playback direction. Either forwards or backwards)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [x] These changes fix #22294.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22348)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this pull request Dec 10, 2018
Implement Ended media attribute

<!-- Please describe your changes on the following line: -->

This PR should implement:
* New method `HTMLMediaElement::earliest_possible_position()` for the [earliest possible position](https://html.spec.whatwg.org/multipage/media.html#earliest-possible-position)
* `Ended` attribute following https://html.spec.whatwg.org/multipage/media.html#ended-playback
* Queue steps for when the playback position reaches the end

This PR contains placeholders for the following issues (I can rebase changes after the corresponding PRs get merged)
- #22321 (Define the Loop attribute)
- #22293 (To identify playback direction. Either forwards or backwards)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [x] These changes fix #22294.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22348)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this pull request Dec 11, 2018
Implement Ended media attribute

<!-- Please describe your changes on the following line: -->

This PR should implement:
* New method `HTMLMediaElement::earliest_possible_position()` for the [earliest possible position](https://html.spec.whatwg.org/multipage/media.html#earliest-possible-position)
* `Ended` attribute following https://html.spec.whatwg.org/multipage/media.html#ended-playback
* Queue steps for when the playback position reaches the end

This PR contains placeholders for the following issues (I can rebase changes after the corresponding PRs get merged)
- #22321 (Define the Loop attribute)
- #22293 (To identify playback direction. Either forwards or backwards)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [x] These changes fix #22294.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22348)
<!-- Reviewable:end -->
@jdm jdm assigned ferjm and unassigned avadacatavra Dec 17, 2018
@ferjm
Copy link
Member

ferjm commented Dec 18, 2018

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

bors-servo commented Dec 18, 2018

Trying commit ac71d3d with merge 2840685...

bors-servo added a commit that referenced this pull request Dec 18, 2018
WIP: Implement HTMLMediaElement.loop attribute

Implement HTMLMediaElement.loop attribute

- enabled `loop` attribute in `HTMLMediaElement`
- initialised `loop` value as `Cell::new(false)`
- set `playback_position` to `default_playback_start_position` in `PlayerEvent::EndOfStream` event when `loop` is set

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #22290 (github issue number if applicable).

---

- [ ] There are tests for these changes OR

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22321)
<!-- Reviewable:end -->
@kkpoon
Copy link
Contributor Author

kkpoon commented Dec 22, 2018

I get the test fail about reached the unreachable code. I think it is the media error event at here https://github.com/servo/servo/blob/master/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/audio_loop_base.html#L35

Any way to check about the detail of that error?

bors-servo added a commit that referenced this pull request Dec 22, 2018
Implement Ended media attribute

<!-- Please describe your changes on the following line: -->

This PR should implement:
* New method `HTMLMediaElement::earliest_possible_position()` for the [earliest possible position](https://html.spec.whatwg.org/multipage/media.html#earliest-possible-position)
* `Ended` attribute following https://html.spec.whatwg.org/multipage/media.html#ended-playback
* Queue steps for when the playback position reaches the end

This PR contains placeholders for the following issues (I can rebase changes after the corresponding PRs get merged)
- #22321 (Define the Loop attribute)
- #22293 (To identify playback direction. Either forwards or backwards)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [x] These changes fix #22294.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22348)
<!-- Reviewable:end -->
@ferjm
Copy link
Member

ferjm commented Dec 26, 2018

You should be able to get the error from the error attribute of the media element. However, I suspect that these tests may give you intermittent results until I manage to land #22477.

@ferjm
Copy link
Member

ferjm commented Jan 10, 2019

@kkpoon #22477 has just landed, so you should experience more stability with the WPTs after rebasing on top of master.

@jdm
Copy link
Member

jdm commented Jan 10, 2019

@bors-servo try=wpt

bors-servo added a commit that referenced this pull request Jan 10, 2019
WIP: Implement HTMLMediaElement.loop attribute

Implement HTMLMediaElement.loop attribute

- enabled `loop` attribute in `HTMLMediaElement`
- initialised `loop` value as `Cell::new(false)`
- set `playback_position` to `default_playback_start_position` in `PlayerEvent::EndOfStream` event when `loop` is set

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #22290 (github issue number if applicable).

---

- [ ] There are tests for these changes OR

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22321)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jan 10, 2019

Trying commit 3dccbdd with merge 9b574db...

@bors-servo
Copy link
Contributor

bors-servo commented Jan 10, 2019

💔 Test failed - linux-rel-css

bors-servo added a commit that referenced this pull request Jan 10, 2019
Implement Ended media attribute

<!-- Please describe your changes on the following line: -->

This PR should implement:
* New method `HTMLMediaElement::earliest_possible_position()` for the [earliest possible position](https://html.spec.whatwg.org/multipage/media.html#earliest-possible-position)
* `Ended` attribute following https://html.spec.whatwg.org/multipage/media.html#ended-playback
* Queue steps for when the playback position reaches the end

This PR contains placeholders for the following issues (I can rebase changes after the corresponding PRs get merged)
- #22321 (Define the Loop attribute)
- #22293 (To identify playback direction. Either forwards or backwards)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [x] These changes fix #22294.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22348)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jan 11, 2019

The latest upstream changes (presumably #22522) made this pull request unmergeable. Please resolve the merge conflicts.

bors-servo added a commit that referenced this pull request Jan 14, 2019
Implement Ended media attribute

<!-- Please describe your changes on the following line: -->

This PR should implement:
* New method `HTMLMediaElement::earliest_possible_position()` for the [earliest possible position](https://html.spec.whatwg.org/multipage/media.html#earliest-possible-position)
* `Ended` attribute following https://html.spec.whatwg.org/multipage/media.html#ended-playback
* Queue steps for when the playback position reaches the end

This PR contains placeholders for the following issues (I can rebase changes after the corresponding PRs get merged)
- #22321 (Define the Loop attribute)
- #22293 (To identify playback direction. Either forwards or backwards)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [x] These changes fix #22294.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22348)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this pull request Jan 14, 2019
Implement Ended media attribute

<!-- Please describe your changes on the following line: -->

This PR should implement:
* New method `HTMLMediaElement::earliest_possible_position()` for the [earliest possible position](https://html.spec.whatwg.org/multipage/media.html#earliest-possible-position)
* `Ended` attribute following https://html.spec.whatwg.org/multipage/media.html#ended-playback
* Queue steps for when the playback position reaches the end

This PR contains placeholders for the following issues (I can rebase changes after the corresponding PRs get merged)
- #22321 (Define the Loop attribute)
- #22293 (To identify playback direction. Either forwards or backwards)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [x] These changes fix #22294.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22348)
<!-- Reviewable:end -->
@kkpoon kkpoon closed this Feb 1, 2019
@ferjm
Copy link
Member

ferjm commented Feb 1, 2019

@kkpoon sorry, I mistakenly closed #22290. Are you still working on this?

@kkpoon
Copy link
Contributor Author

kkpoon commented Feb 1, 2019

Oh, I just though it is done.
Yes, I still want to try on this. Just almost finish one in PerformanceResourceTiming.

@kkpoon kkpoon reopened this Feb 1, 2019
@ferjm
Copy link
Member

ferjm commented Mar 11, 2019

@kkpoon how are things going? Are you still interested in working on this issue?

@kkpoon
Copy link
Contributor Author

kkpoon commented Mar 12, 2019

@ferjm Sorry that I am not able to work on this at this moment. You may take over this PR or close it for other to work on this.

Haven't update the status and I am sorry about that.

@ferjm
Copy link
Member

ferjm commented Mar 12, 2019

No worries! Let's close this for now. Feel free to reopen if you find the time to work on it again. Thanks!

@ferjm ferjm closed this Mar 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

7 participants
You can’t perform that action at this time.