From 28c9ceedf6dd71935c2b4b99820f799f67beb1fc Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Wed, 15 Jan 2025 12:16:43 +0100 Subject: [PATCH] fonts: Remove synchronous web font loading functionality (#35000) Synchronous web font loading is not specification compliant and was added in #8341 to work around issues that do not exist any longer. This change removes the functionality and ensures that WPT tests are run with the spec compliant loader. Signed-off-by: Martin Robinson --- components/config/opts.rs | 4 ---- components/fonts/font_context.rs | 21 ------------------- components/layout_thread/lib.rs | 12 +---------- components/layout_thread_2020/lib.rs | 12 +---------- tests/wpt/meta/MANIFEST.json | 2 +- .../wptrunner/executors/executorservo.py | 2 +- 6 files changed, 4 insertions(+), 49 deletions(-) diff --git a/components/config/opts.rs b/components/config/opts.rs index 83cc99d8d2b..d00cd11bf1e 100644 --- a/components/config/opts.rs +++ b/components/config/opts.rs @@ -177,9 +177,6 @@ pub struct DebugOptions { /// Log GC passes and their durations. pub gc_profile: bool, - /// Load web fonts synchronously to avoid non-deterministic network-driven reflows. - pub load_webfonts_synchronously: bool, - /// Show webrender profiling stats on screen. pub webrender_stats: bool, @@ -209,7 +206,6 @@ impl DebugOptions { "dump-rule-tree" => self.dump_rule_tree = true, "dump-style-tree" => self.dump_style_tree = true, "gc-profile" => self.gc_profile = true, - "load-webfonts-synchronously" => self.load_webfonts_synchronously = true, "precache-shaders" => self.precache_shaders = true, "profile-script-events" => self.profile_script_events = true, "relayout-event" => self.relayout_event = true, diff --git a/components/fonts/font_context.rs b/components/fonts/font_context.rs index bba34146945..1ebe26a20b1 100644 --- a/components/fonts/font_context.rs +++ b/components/fonts/font_context.rs @@ -9,7 +9,6 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use app_units::Au; -use crossbeam_channel::unbounded; use fnv::FnvHasher; use fonts_traits::WebFontLoadFinishedCallback; use log::{debug, trace}; @@ -374,7 +373,6 @@ pub trait FontContextWebFontMethods { guard: &SharedRwLockReadGuard, device: &Device, finished_callback: WebFontLoadFinishedCallback, - synchronous: bool, ) -> usize; fn remove_all_web_fonts_from_stylesheet(&self, stylesheet: &DocumentStyleSheet); fn collect_unused_webrender_resources(&self, all: bool) @@ -388,21 +386,7 @@ impl FontContextWebFontMethods for Arc { guard: &SharedRwLockReadGuard, device: &Device, finished_callback: WebFontLoadFinishedCallback, - synchronous: bool, ) -> usize { - let (finished_callback, synchronous_receiver) = if synchronous { - let (sender, receiver) = unbounded(); - let finished_callback = move |_succeeded: bool| { - let _ = sender.send(()); - }; - ( - Arc::new(finished_callback) as WebFontLoadFinishedCallback, - Some(receiver), - ) - } else { - (finished_callback, None) - }; - let mut number_loading = 0; for rule in stylesheet.effective_rules(device, guard) { let CssRule::FontFace(ref lock) = *rule else { @@ -464,11 +448,6 @@ impl FontContextWebFontMethods for Arc { local_fonts: Arc::new(local_fonts), stylesheet: stylesheet.clone(), }); - - // If the load is synchronous wait for it to be signalled. - if let Some(ref synchronous_receiver) = synchronous_receiver { - synchronous_receiver.recv().unwrap(); - } } number_loading diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index 514600cf89a..962d807d068 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -639,22 +639,12 @@ impl LayoutThread { ); }; - // Find all font-face rules and notify the FontContext of them. - // GWTODO: Need to handle unloading web fonts. - let newly_loading_font_count = self.font_context.add_all_web_fonts_from_stylesheet( + self.font_context.add_all_web_fonts_from_stylesheet( stylesheet, guard, self.stylist.device(), Arc::new(web_font_finished_loading_callback) as WebFontLoadFinishedCallback, - self.debug.load_webfonts_synchronously, ); - - if self.debug.load_webfonts_synchronously && newly_loading_font_count > 0 { - // TODO: Handle failure in web font loading - let _ = self - .script_chan - .send(ConstellationControlMsg::WebFontLoaded(self.id, true)); - } } fn try_get_layout_root<'dom>(&self, node: impl LayoutNode<'dom>) -> Option { diff --git a/components/layout_thread_2020/lib.rs b/components/layout_thread_2020/lib.rs index 85d499ecfde..fbd862dd6ec 100644 --- a/components/layout_thread_2020/lib.rs +++ b/components/layout_thread_2020/lib.rs @@ -618,22 +618,12 @@ impl LayoutThread { )); }; - // Find all font-face rules and notify the font cache of them. - // GWTODO: Need to handle unloading web fonts. - let newly_loading_font_count = self.font_context.add_all_web_fonts_from_stylesheet( + self.font_context.add_all_web_fonts_from_stylesheet( stylesheet, guard, self.stylist.device(), Arc::new(web_font_finished_loading_callback) as WebFontLoadFinishedCallback, - self.debug.load_webfonts_synchronously, ); - - if self.debug.load_webfonts_synchronously && newly_loading_font_count > 0 { - // TODO: Handle failure in web font loading - let _ = self - .script_chan - .send(ConstellationControlMsg::WebFontLoaded(self.id, true)); - } } /// The high-level routine that performs layout. diff --git a/tests/wpt/meta/MANIFEST.json b/tests/wpt/meta/MANIFEST.json index d5b980c5fc8..8871e46b4ba 100644 --- a/tests/wpt/meta/MANIFEST.json +++ b/tests/wpt/meta/MANIFEST.json @@ -503873,7 +503873,7 @@ [] ], "executorservo.py": [ - "1d96ffa41da33c9b3c2650ee68c27174bf3081a6", + "8b6db6091a84e9e83ec8d161fc86b1d0387f41e6", [] ], "executorservodriver.py": [ diff --git a/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservo.py b/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservo.py index 1d96ffa41da..8b6db6091a8 100644 --- a/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservo.py +++ b/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservo.py @@ -231,7 +231,7 @@ class ServoRefTestExecutor(ServoExecutor): extra_args = ["--exit", "--output=%s" % output_path, "--window-size", viewport_size or "800x600"] - debug_opts = "disable-text-aa,load-webfonts-synchronously,replace-surrogates" + debug_opts = "disable-text-aa,replace-surrogates" if dpi: extra_args += ["--device-pixel-ratio", dpi]