mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #22944 - ferjm:player.shutdown, r=ceyusa
Shutdown player when HTMLMediaElement is dropped - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #22931 - [X] There are tests for these changes <!-- 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/22944) <!-- Reviewable:end -->
This commit is contained in:
commit
5ae562bfc3
12 changed files with 372 additions and 261 deletions
14
.travis.yml
14
.travis.yml
|
@ -20,13 +20,13 @@ matrix:
|
|||
- sudo add-apt-repository 'deb http://apt.llvm.org/precise/ llvm-toolchain-precise-3.9 main' -y
|
||||
- sudo apt-get update -q
|
||||
- sudo apt-get install clang-3.9 llvm-3.9 llvm-3.9-runtime -y
|
||||
- curl -L https://servo-deps.s3.amazonaws.com/gstreamer/gstreamer-x86_64-linux-gnu.tar.gz | tar xz
|
||||
- sed -i "s;prefix=/root/gstreamer;prefix=$PWD/gstreamer;g" $PWD/gstreamer/lib/x86_64-linux-gnu/pkgconfig/*.pc
|
||||
- export PKG_CONFIG_PATH=$PWD/gstreamer/lib/x86_64-linux-gnu/pkgconfig
|
||||
- export GST_PLUGIN_SYSTEM_PATH=$PWD/gstreamer/lib/x86_64-linux-gnu/gstreamer-1.0
|
||||
- export GST_PLUGIN_SCANNER=$PWD/gstreamer/libexec/gstreamer-1.0/gst-plugin-scanner
|
||||
- export PATH=$PATH:$PWD/gstreamer/bin
|
||||
- export LD_LIBRARY_PATH=$PWD/gstreamer/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
|
||||
- curl -L http://servo-deps.s3.amazonaws.com/gstreamer/gstreamer-1.14-x86_64-linux-gnu.20190213.tar.gz | tar xz
|
||||
- sed -i "s;prefix=/opt/gst;prefix=$PWD/gst;g" $PWD/gst/lib/pkgconfig/*.pc
|
||||
- export PKG_CONFIG_PATH=$PWD/gst/lib/pkgconfig
|
||||
- export GST_PLUGIN_SYSTEM_PATH=$PWD/gst/lib/gstreamer-1.0
|
||||
- export GST_PLUGIN_SCANNER=$PWD/gst/libexec/gstreamer-1.0/gst-plugin-scanner
|
||||
- export PATH=$PATH:$PWD/gst/bin
|
||||
- export LD_LIBRARY_PATH=$PWD/gst/lib:$LD_LIBRARY_PATH
|
||||
- export LLVM_CONFIG=/usr/lib/llvm-3.9/bin/llvm-config
|
||||
- curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain none -y
|
||||
- source ~/.profile
|
||||
|
|
512
Cargo.lock
generated
512
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -96,6 +96,7 @@ servo_atoms = {path = "../atoms"}
|
|||
servo_config = {path = "../config"}
|
||||
servo_geometry = {path = "../geometry" }
|
||||
servo-media = {git = "https://github.com/servo/media"}
|
||||
servo-media-auto = {git = "https://github.com/servo/media"}
|
||||
servo_rand = {path = "../rand"}
|
||||
servo_url = {path = "../url"}
|
||||
smallvec = { version = "0.6", features = ["std", "union"] }
|
||||
|
|
|
@ -50,7 +50,8 @@ use servo_media::audio::context::{AudioContext, AudioContextOptions, ProcessingS
|
|||
use servo_media::audio::context::{OfflineAudioContextOptions, RealTimeAudioContextOptions};
|
||||
use servo_media::audio::decoder::AudioDecoderCallbacks;
|
||||
use servo_media::audio::graph::NodeId;
|
||||
use servo_media::{Backend, ServoMedia};
|
||||
use servo_media::ServoMedia;
|
||||
use servo_media_auto::Backend;
|
||||
use std::cell::Cell;
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::mem;
|
||||
|
@ -75,7 +76,7 @@ struct DecodeResolver {
|
|||
pub struct BaseAudioContext {
|
||||
eventtarget: EventTarget,
|
||||
#[ignore_malloc_size_of = "servo_media"]
|
||||
audio_context_impl: AudioContext<Backend>,
|
||||
audio_context_impl: AudioContext,
|
||||
/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-destination
|
||||
destination: MutNullableDom<AudioDestinationNode>,
|
||||
listener: MutNullableDom<AudioListener>,
|
||||
|
@ -108,6 +109,8 @@ impl BaseAudioContext {
|
|||
},
|
||||
};
|
||||
|
||||
ServoMedia::init::<Backend>();
|
||||
|
||||
let context = BaseAudioContext {
|
||||
eventtarget: EventTarget::new_inherited(),
|
||||
audio_context_impl: ServoMedia::get()
|
||||
|
@ -131,7 +134,7 @@ impl BaseAudioContext {
|
|||
false
|
||||
}
|
||||
|
||||
pub fn audio_context_impl(&self) -> &AudioContext<Backend> {
|
||||
pub fn audio_context_impl(&self) -> &AudioContext {
|
||||
&self.audio_context_impl
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,6 @@ use servo_media::audio::param::ParamType;
|
|||
use servo_media::player::Player;
|
||||
use servo_media::streams::MediaStream as BackendMediaStream;
|
||||
use servo_media::webrtc::WebRtcController;
|
||||
use servo_media::Backend;
|
||||
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
||||
use smallvec::SmallVec;
|
||||
use std::cell::{Cell, RefCell, UnsafeCell};
|
||||
|
@ -481,7 +480,7 @@ unsafe_no_jsmanaged_fields!(InteractiveWindow);
|
|||
unsafe_no_jsmanaged_fields!(CanvasId);
|
||||
unsafe_no_jsmanaged_fields!(SourceSet);
|
||||
unsafe_no_jsmanaged_fields!(AudioBuffer);
|
||||
unsafe_no_jsmanaged_fields!(AudioContext<Backend>);
|
||||
unsafe_no_jsmanaged_fields!(AudioContext);
|
||||
unsafe_no_jsmanaged_fields!(NodeId);
|
||||
unsafe_no_jsmanaged_fields!(AnalysisEngine, DistanceModel, PanningModel, ParamType);
|
||||
unsafe_no_jsmanaged_fields!(dyn Player);
|
||||
|
|
|
@ -68,6 +68,7 @@ use servo_config::pref;
|
|||
use servo_media::player::frame::{Frame, FrameRenderer};
|
||||
use servo_media::player::{PlaybackState, Player, PlayerError, PlayerEvent, StreamType};
|
||||
use servo_media::ServoMedia;
|
||||
use servo_media_auto::Backend;
|
||||
use servo_url::ServoUrl;
|
||||
use std::cell::Cell;
|
||||
use std::collections::VecDeque;
|
||||
|
@ -249,6 +250,7 @@ pub enum ReadyState {
|
|||
|
||||
impl HTMLMediaElement {
|
||||
pub fn new_inherited(tag_name: LocalName, prefix: Option<Prefix>, document: &Document) -> Self {
|
||||
ServoMedia::init::<Backend>();
|
||||
Self {
|
||||
htmlelement: HTMLElement::new_inherited(tag_name, prefix, document),
|
||||
network_state: Cell::new(NetworkState::Empty),
|
||||
|
@ -1147,15 +1149,16 @@ impl HTMLMediaElement {
|
|||
action_receiver.to_opaque(),
|
||||
Box::new(move |message| {
|
||||
let event: PlayerEvent = message.to().unwrap();
|
||||
trace!("Player event {:?}", event);
|
||||
let this = trusted_node.clone();
|
||||
task_source
|
||||
.queue_with_canceller(
|
||||
task!(handle_player_event: move || {
|
||||
this.root().handle_player_event(&event);
|
||||
}),
|
||||
&canceller,
|
||||
)
|
||||
.unwrap();
|
||||
if let Err(err) = task_source.queue_with_canceller(
|
||||
task!(handle_player_event: move || {
|
||||
this.root().handle_player_event(&event);
|
||||
}),
|
||||
&canceller,
|
||||
) {
|
||||
warn!("Could not queue player event handler task {:?}", err);
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
|
@ -1489,6 +1492,14 @@ impl HTMLMediaElement {
|
|||
}
|
||||
}
|
||||
|
||||
impl Drop for HTMLMediaElement {
|
||||
fn drop(&mut self) {
|
||||
if let Err(err) = self.player.shutdown() {
|
||||
warn!("Error shutting down player {:?}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl HTMLMediaElementMethods for HTMLMediaElement {
|
||||
// https://html.spec.whatwg.org/multipage/#dom-media-networkstate
|
||||
fn NetworkState(&self) -> u16 {
|
||||
|
|
|
@ -17,6 +17,7 @@ use crate::dom::promise::Promise;
|
|||
use dom_struct::dom_struct;
|
||||
use servo_media::streams::capture::{Constrain, ConstrainRange, MediaTrackConstraintSet};
|
||||
use servo_media::ServoMedia;
|
||||
use servo_media_auto::Backend;
|
||||
use std::rc::Rc;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -26,6 +27,7 @@ pub struct MediaDevices {
|
|||
|
||||
impl MediaDevices {
|
||||
pub fn new_inherited() -> MediaDevices {
|
||||
ServoMedia::init::<Backend>();
|
||||
MediaDevices {
|
||||
eventtarget: EventTarget::new_inherited(),
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ use servo_media::webrtc::{
|
|||
BundlePolicy, IceCandidate, SdpType, SessionDescription, WebRtcController, WebRtcSignaller,
|
||||
};
|
||||
use servo_media::ServoMedia;
|
||||
use servo_media_auto::Backend;
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
|
@ -117,6 +118,7 @@ impl RTCPeerConnection {
|
|||
RTCPeerConnectionBinding::Wrap,
|
||||
);
|
||||
let signaller = this.make_signaller();
|
||||
ServoMedia::init::<Backend>();
|
||||
*this.controller.borrow_mut() = Some(ServoMedia::get().unwrap().create_webrtc(signaller));
|
||||
if let Some(ref servers) = config.iceServers {
|
||||
if let Some(ref server) = servers.get(0) {
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
{
|
||||
"items": {
|
||||
"conformancechecker": {
|
||||
"mozilla/remove_video_iframe.html": []
|
||||
},
|
||||
"manual": {
|
||||
"mozilla/remove_video_iframe.html": []
|
||||
},
|
||||
"reftest": {
|
||||
"css/abs-overflow-stackingcontext.html": [
|
||||
[
|
||||
|
@ -7325,6 +7331,7 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"mozilla/remove_video_iframe.html": [],
|
||||
"mozilla/reparse_style_elements.html": [
|
||||
[
|
||||
"mozilla/reparse_style_elements.html",
|
||||
|
@ -7626,7 +7633,11 @@
|
|||
],
|
||||
{}
|
||||
]
|
||||
]
|
||||
],
|
||||
"mozilla/remove_video_iframe.html": []
|
||||
},
|
||||
"stub": {
|
||||
"mozilla/remove_video_iframe.html": []
|
||||
},
|
||||
"support": {
|
||||
".gitignore": [
|
||||
|
@ -10864,6 +10875,7 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"mozilla/remove_video_iframe.html": [],
|
||||
"mozilla/reparse_style_elements_ref.html": [
|
||||
[
|
||||
{}
|
||||
|
@ -10939,6 +10951,11 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"mozilla/resources/remove_video_iframe_inner.html": [
|
||||
[
|
||||
{}
|
||||
]
|
||||
],
|
||||
"mozilla/resources/second.html": [
|
||||
[
|
||||
{}
|
||||
|
@ -10949,6 +10966,11 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"mozilla/resources/video.mp4": [
|
||||
[
|
||||
{}
|
||||
]
|
||||
],
|
||||
"mozilla/resources/worker_success.js": [
|
||||
[
|
||||
{}
|
||||
|
@ -13550,6 +13572,12 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"mozilla/remove_video_iframe.html": [
|
||||
[
|
||||
"/_mozilla/mozilla/remove_video_iframe.html",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"mozilla/response-data-brotli.htm": [
|
||||
[
|
||||
"mozilla/response-data-brotli.htm",
|
||||
|
@ -13862,6 +13890,12 @@
|
|||
{}
|
||||
]
|
||||
]
|
||||
},
|
||||
"visual": {
|
||||
"mozilla/remove_video_iframe.html": []
|
||||
},
|
||||
"wdspec": {
|
||||
"mozilla/remove_video_iframe.html": []
|
||||
}
|
||||
},
|
||||
"paths": {
|
||||
|
@ -20461,6 +20495,10 @@
|
|||
"d562e12720350501ad14223b668131837fd10620",
|
||||
"support"
|
||||
],
|
||||
"mozilla/remove_video_iframe.html": [
|
||||
"67b28d100828334ba96736d5fb2bcf01ed554d68",
|
||||
"testharness"
|
||||
],
|
||||
"mozilla/reparse_style_elements.html": [
|
||||
"e54f5a28d131ab41f89d3d70a9d01ea2fae751c1",
|
||||
"reftest"
|
||||
|
@ -20529,6 +20567,10 @@
|
|||
"b0883f382e1a80609b7b2c7904e701fbe6760b14",
|
||||
"support"
|
||||
],
|
||||
"mozilla/resources/remove_video_iframe_inner.html": [
|
||||
"bdd3d9349af8ade8bb4dcec1d7d46256ee2cffa1",
|
||||
"support"
|
||||
],
|
||||
"mozilla/resources/second.html": [
|
||||
"c4fbe534ed193e1d192c0338997a8d9da8eb6406",
|
||||
"support"
|
||||
|
@ -20537,6 +20579,10 @@
|
|||
"8faa57c0c47c4fdf27c052d059b28ee1088235e9",
|
||||
"support"
|
||||
],
|
||||
"mozilla/resources/video.mp4": [
|
||||
"fb5dbca23808bee44003692cb0e139dd6a22e874",
|
||||
"support"
|
||||
],
|
||||
"mozilla/resources/worker_success.js": [
|
||||
"327986f34b9b20476b6a7b1189c732a9ea8b9f68",
|
||||
"support"
|
||||
|
|
14
tests/wpt/mozilla/tests/mozilla/remove_video_iframe.html
Normal file
14
tests/wpt/mozilla/tests/mozilla/remove_video_iframe.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>Removing an iframe loading a video should not panic</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<iframe id="video" src="resources/remove_video_iframe_inner.html"></iframe>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
setTimeout(function() {
|
||||
document.getElementById('video').remove();
|
||||
t.done();
|
||||
}, 1000);
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1 @@
|
|||
<video autoplay src="video.mp4"></video>
|
BIN
tests/wpt/mozilla/tests/mozilla/resources/video.mp4
Normal file
BIN
tests/wpt/mozilla/tests/mozilla/resources/video.mp4
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue