mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Suspend/resume media activity based on document activity
This commit is contained in:
parent
51ed44c77d
commit
d7bebce537
2 changed files with 19 additions and 12 deletions
24
Cargo.lock
generated
24
Cargo.lock
generated
|
@ -4221,7 +4221,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servo-media"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/media#8c072eb922d0c8cb431f8c1cf80b304e03fe66bb"
|
||||
source = "git+https://github.com/servo/media#7776958f353b5881fa1d6ec97a236940f7a30d16"
|
||||
dependencies = [
|
||||
"servo-media-audio 0.1.0 (git+https://github.com/servo/media)",
|
||||
"servo-media-player 0.1.0 (git+https://github.com/servo/media)",
|
||||
|
@ -4233,7 +4233,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servo-media-audio"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/media#8c072eb922d0c8cb431f8c1cf80b304e03fe66bb"
|
||||
source = "git+https://github.com/servo/media#7776958f353b5881fa1d6ec97a236940f7a30d16"
|
||||
dependencies = [
|
||||
"boxfnonce 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byte-slice-cast 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -4250,7 +4250,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servo-media-dummy"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/media#8c072eb922d0c8cb431f8c1cf80b304e03fe66bb"
|
||||
source = "git+https://github.com/servo/media#7776958f353b5881fa1d6ec97a236940f7a30d16"
|
||||
dependencies = [
|
||||
"boxfnonce 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ipc-channel 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -4265,7 +4265,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servo-media-gstreamer"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/media#8c072eb922d0c8cb431f8c1cf80b304e03fe66bb"
|
||||
source = "git+https://github.com/servo/media#7776958f353b5881fa1d6ec97a236940f7a30d16"
|
||||
dependencies = [
|
||||
"boxfnonce 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byte-slice-cast 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -4301,7 +4301,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servo-media-gstreamer-render"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/media#8c072eb922d0c8cb431f8c1cf80b304e03fe66bb"
|
||||
source = "git+https://github.com/servo/media#7776958f353b5881fa1d6ec97a236940f7a30d16"
|
||||
dependencies = [
|
||||
"gstreamer 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gstreamer-video 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -4311,7 +4311,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servo-media-gstreamer-render-android"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/media#8c072eb922d0c8cb431f8c1cf80b304e03fe66bb"
|
||||
source = "git+https://github.com/servo/media#7776958f353b5881fa1d6ec97a236940f7a30d16"
|
||||
dependencies = [
|
||||
"glib 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gstreamer 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -4324,7 +4324,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servo-media-gstreamer-render-unix"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/media#8c072eb922d0c8cb431f8c1cf80b304e03fe66bb"
|
||||
source = "git+https://github.com/servo/media#7776958f353b5881fa1d6ec97a236940f7a30d16"
|
||||
dependencies = [
|
||||
"glib 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gstreamer 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -4337,7 +4337,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servo-media-player"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/media#8c072eb922d0c8cb431f8c1cf80b304e03fe66bb"
|
||||
source = "git+https://github.com/servo/media#7776958f353b5881fa1d6ec97a236940f7a30d16"
|
||||
dependencies = [
|
||||
"ipc-channel 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -4349,7 +4349,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servo-media-streams"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/media#8c072eb922d0c8cb431f8c1cf80b304e03fe66bb"
|
||||
source = "git+https://github.com/servo/media#7776958f353b5881fa1d6ec97a236940f7a30d16"
|
||||
dependencies = [
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -4358,12 +4358,12 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servo-media-traits"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/media#8c072eb922d0c8cb431f8c1cf80b304e03fe66bb"
|
||||
source = "git+https://github.com/servo/media#7776958f353b5881fa1d6ec97a236940f7a30d16"
|
||||
|
||||
[[package]]
|
||||
name = "servo-media-webrtc"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/media#8c072eb922d0c8cb431f8c1cf80b304e03fe66bb"
|
||||
source = "git+https://github.com/servo/media#7776958f353b5881fa1d6ec97a236940f7a30d16"
|
||||
dependencies = [
|
||||
"boxfnonce 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -4462,7 +4462,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servo_media_derive"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/media#8c072eb922d0c8cb431f8c1cf80b304e03fe66bb"
|
||||
source = "git+https://github.com/servo/media#7776958f353b5881fa1d6ec97a236940f7a30d16"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -145,6 +145,7 @@ use script_traits::{
|
|||
use servo_arc::Arc;
|
||||
use servo_atoms::Atom;
|
||||
use servo_config::pref;
|
||||
use servo_media::{ClientContextId, ServoMedia};
|
||||
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::{Cell, Ref, RefMut};
|
||||
|
@ -499,12 +500,17 @@ impl Document {
|
|||
// Set the document's activity level, reflow if necessary, and suspend or resume timers.
|
||||
if activity != self.activity.get() {
|
||||
self.activity.set(activity);
|
||||
let media = ServoMedia::get().unwrap();
|
||||
let pipeline_id = self.window().pipeline_id().expect("doc with no pipeline");
|
||||
let client_context_id =
|
||||
ClientContextId::build(pipeline_id.namespace_id.0, pipeline_id.index.0.get());
|
||||
if activity == DocumentActivity::FullyActive {
|
||||
self.title_changed();
|
||||
self.dirty_all_nodes();
|
||||
self.window()
|
||||
.reflow(ReflowGoal::Full, ReflowReason::CachedPageNeededReflow);
|
||||
self.window().resume();
|
||||
media.resume(&client_context_id);
|
||||
// html.spec.whatwg.org/multipage/#history-traversal
|
||||
// Step 4.6
|
||||
if self.ready_state.get() == DocumentReadyState::Complete {
|
||||
|
@ -544,6 +550,7 @@ impl Document {
|
|||
}
|
||||
} else {
|
||||
self.window().suspend();
|
||||
media.suspend(&client_context_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue