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

Implement step 6 of media `time marches on` algorithm. Improves stability of media WPTs #22477

Merged
merged 3 commits into from Jan 10, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Implement step 6 of media element 'time marches on' algoritm

  • Loading branch information
ferjm committed Jan 9, 2019
commit 6c2c3f75b90f075d4f7d23b800706e745cb10f8c
@@ -130,7 +130,7 @@ use style::values::specified::Length;
use tendril::fmt::UTF8;
use tendril::stream::LossyDecoder;
use tendril::{StrTendril, TendrilSink};
use time::Duration;
use time::{Duration, Timespec};
use uuid::Uuid;
use webrender_api::{DocumentId, ImageKey, RenderApiSender};
use webvr_traits::WebVRGamepadHand;
@@ -488,6 +488,7 @@ unsafe_no_jsmanaged_fields!(dyn Player<Error = ServoMediaError>);
unsafe_no_jsmanaged_fields!(Mutex<MediaFrameRenderer>);
unsafe_no_jsmanaged_fields!(RenderApiSender);
unsafe_no_jsmanaged_fields!(ResourceFetchTiming);
unsafe_no_jsmanaged_fields!(Timespec);

unsafe impl<'a> JSTraceable for &'a str {
#[inline]
@@ -204,6 +204,9 @@ pub struct HTMLMediaElement {
text_tracks_list: MutNullableDom<TextTrackList>,
/// Expected content length of the media asset being fetched or played.
content_length: Cell<Option<u64>>,
/// Time of last timeupdate notification.
#[ignore_malloc_size_of = "Defined in time"]
next_timeupdate_event: Cell<Timespec>,
}

/// <https://html.spec.whatwg.org/multipage/#dom-media-networkstate>
@@ -261,6 +264,7 @@ impl HTMLMediaElement {
played: Rc::new(DomRefCell::new(TimeRangesContainer::new())),
text_tracks_list: Default::default(),
content_length: Cell::new(None),
next_timeupdate_event: Cell::new(time::get_time() + Duration::milliseconds(250)),
}
}

@@ -303,7 +307,15 @@ impl HTMLMediaElement {

/// https://html.spec.whatwg.org/multipage/#time-marches-on
fn time_marches_on(&self) {
// TODO: implement this.
// Step 6.
if time::get_time() > self.next_timeupdate_event.get() {
let window = window_from_node(self);
window
.task_manager()
.media_element_task_source()
.queue_simple_event(self.upcast(), atom!("timeupdate"), &window);
self.next_timeupdate_event.set(time::get_time() + Duration::milliseconds(350));
}
}

/// <https://html.spec.whatwg.org/multipage/#internal-pause-steps>
@@ -1173,6 +1185,7 @@ impl HTMLMediaElement {
.borrow_mut()
.add(self.playback_position.get(), position);
self.playback_position.set(position);
self.time_marches_on();
},
PlayerEvent::StateChanged(ref state) => match *state {
PlaybackState::Paused => {
@@ -1,7 +1,9 @@
[autoplay-with-broken-track.html]
expected: TIMEOUT
[<video autoplay> with <track> child]
expected: TIMEOUT
expected:
if debug and (os == "mac") and (version == "OS X 10.14.1") and (processor == "x86_64") and (bits == 64): PASS
TIMEOUT

[<video autoplay> with <track src=\"invalid://url\" default=\"\"> child]
expected: TIMEOUT
@@ -2,9 +2,6 @@
type: testharness
disabled: Until https://github.com/servo/servo/pull/22477 is merged
expected: TIMEOUT
[setting src attribute on a sufficiently long autoplay audio should trigger timeupdate event]
expected: NOTRUN

[setting src attribute on a sufficiently long autoplay video should trigger timeupdate event]
expected: NOTRUN

@@ -5,6 +5,4 @@
[calling play() on a sufficiently long audio should trigger timeupdate event]
expected: NOTRUN

[calling play() on a sufficiently long video should trigger timeupdate event]
expected: FAIL

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.