Fix Servo taking a long time to start on MacOS after a recompile (#30726)

* update init as we initialize media in the background now

With [#405](https://github.com/servo/media/pull/405) changes in
servo/media we move initialization of the media engine to a
background thread. This PR updates the init function in libservo
to adapt that behaviour.

Co-authored-by: Martin Robinson <mrobinson@igalia.com>

* review fix: simplify code

* Update media

---------

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
atbrakhi 2023-11-14 11:15:02 +01:00 committed by GitHub
parent 098e6a1580
commit 1e5db618d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 23 deletions

15
Cargo.lock generated
View file

@ -5071,8 +5071,9 @@ dependencies = [
[[package]]
name = "servo-media"
version = "0.1.0"
source = "git+https://github.com/servo/media#8ea11a849d5c2f0e469d1d1ccad93a74fbd81462"
source = "git+https://github.com/servo/media#97515f64c551e37854c6e29eff93988c4d0ee152"
dependencies = [
"once_cell",
"servo-media-audio",
"servo-media-player",
"servo-media-streams",
@ -5083,7 +5084,7 @@ dependencies = [
[[package]]
name = "servo-media-audio"
version = "0.2.0"
source = "git+https://github.com/servo/media#8ea11a849d5c2f0e469d1d1ccad93a74fbd81462"
source = "git+https://github.com/servo/media#97515f64c551e37854c6e29eff93988c4d0ee152"
dependencies = [
"boxfnonce",
"byte-slice-cast",
@ -5190,7 +5191,7 @@ dependencies = [
[[package]]
name = "servo-media-player"
version = "0.1.0"
source = "git+https://github.com/servo/media#8ea11a849d5c2f0e469d1d1ccad93a74fbd81462"
source = "git+https://github.com/servo/media#97515f64c551e37854c6e29eff93988c4d0ee152"
dependencies = [
"ipc-channel",
"serde",
@ -5202,7 +5203,7 @@ dependencies = [
[[package]]
name = "servo-media-streams"
version = "0.1.0"
source = "git+https://github.com/servo/media#8ea11a849d5c2f0e469d1d1ccad93a74fbd81462"
source = "git+https://github.com/servo/media#97515f64c551e37854c6e29eff93988c4d0ee152"
dependencies = [
"lazy_static",
"uuid",
@ -5211,12 +5212,12 @@ dependencies = [
[[package]]
name = "servo-media-traits"
version = "0.1.0"
source = "git+https://github.com/servo/media#8ea11a849d5c2f0e469d1d1ccad93a74fbd81462"
source = "git+https://github.com/servo/media#97515f64c551e37854c6e29eff93988c4d0ee152"
[[package]]
name = "servo-media-webrtc"
version = "0.1.0"
source = "git+https://github.com/servo/media#8ea11a849d5c2f0e469d1d1ccad93a74fbd81462"
source = "git+https://github.com/servo/media#97515f64c551e37854c6e29eff93988c4d0ee152"
dependencies = [
"boxfnonce",
"lazy_static",
@ -5293,7 +5294,7 @@ dependencies = [
[[package]]
name = "servo_media_derive"
version = "0.1.0"
source = "git+https://github.com/servo/media#8ea11a849d5c2f0e469d1d1ccad93a74fbd81462"
source = "git+https://github.com/servo/media#97515f64c551e37854c6e29eff93988c4d0ee152"
dependencies = [
"proc-macro2",
"quote",

View file

@ -112,6 +112,7 @@ mod media_platform {
#[cfg(any(windows, target_os = "macos"))]
pub fn init() {
ServoMedia::init_with_backend(|| {
let mut plugin_dir = std::env::current_exe().unwrap();
plugin_dir.pop();
@ -119,7 +120,7 @@ mod media_platform {
plugin_dir.push("lib");
}
let backend = match GStreamerBackend::init_with_plugins(
match GStreamerBackend::init_with_plugins(
plugin_dir,
&gstreamer_plugins::GSTREAMER_PLUGINS,
) {
@ -128,8 +129,8 @@ mod media_platform {
eprintln!("Error initializing GStreamer: {:?}", e);
std::process::exit(1);
},
};
ServoMedia::init_with_backend(backend);
}
});
}
#[cfg(not(any(windows, target_os = "macos")))]