From 022e5ba65d7ba8a5f7d91c102af7c109eb23ffca Mon Sep 17 00:00:00 2001 From: sunil mayya Date: Thu, 22 Feb 2024 10:43:49 +0000 Subject: [PATCH] Bug 1864817 - initialize STYLE_THREAD_POOL in Sevo_initialize. r=emilio,jesup Differential Revision: https://phabricator.services.mozilla.com/D201022 --- Cargo.lock | 1 + gfx/thebes/gfxPlatformFontList.cpp | 6 +++--- modules/libpref/init/StaticPrefList.yaml | 8 ++++---- servo/ports/geckolib/Cargo.toml | 1 + servo/ports/geckolib/glue.rs | 3 +++ servo/ports/geckolib/lib.rs | 1 + 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9360e590a88d..12c58e052f71 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2094,6 +2094,7 @@ dependencies = [ "cstr", "dom", "gecko-profiler", + "lazy_static", "libc", "log", "malloc_size_of", diff --git a/gfx/thebes/gfxPlatformFontList.cpp b/gfx/thebes/gfxPlatformFontList.cpp index 709a0f3c2773..8b4b585a0994 100644 --- a/gfx/thebes/gfxPlatformFontList.cpp +++ b/gfx/thebes/gfxPlatformFontList.cpp @@ -755,7 +755,7 @@ bool gfxPlatformFontList::InitOtherFamilyNames( // (This is used so we can reliably run reftests that depend on localized // font-family names being available.) if (aDeferOtherFamilyNamesLoading && - StaticPrefs::gfx_font_loader_delay_AtStartup() > 0) { + StaticPrefs::gfx_font_loader_delay() > 0) { if (!mPendingOtherFamilyNameTask) { RefPtr task = new InitOtherFamilyNamesRunnable(); @@ -2648,7 +2648,7 @@ bool gfxPlatformFontList::LoadFontInfo() { // Limit the time spent reading fonts in one pass, unless the font-loader // delay was set to zero, in which case we run to completion even if it // causes some jank. - if (StaticPrefs::gfx_font_loader_delay_AtStartup() > 0) { + if (StaticPrefs::gfx_font_loader_delay() > 0) { TimeDuration elapsed = TimeStamp::Now() - start; if (elapsed.ToMilliseconds() > FONT_LOADER_MAX_TIMESLICE && i + 1 != endIndex) { @@ -2751,7 +2751,7 @@ void gfxPlatformFontList::GetPrefsAndStartLoader() { if (AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdownConfirmed)) { return; } - uint32_t delay = std::max(1u, StaticPrefs::gfx_font_loader_delay_AtStartup()); + uint32_t delay = std::max(1u, StaticPrefs::gfx_font_loader_delay()); if (NS_IsMainThread()) { StartLoader(delay); } else { diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 539eead0113b..03fbdce2c8c9 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -6063,13 +6063,13 @@ mirror: once - name: gfx.font_loader.delay - type: uint32_t + type: RelaxedAtomicUint32 #if defined(XP_WIN) value: 60000 #else value: 8000 #endif - mirror: once + mirror: always # Disable antialiasing of Ahem, for use in tests. - name: gfx.font_rendering.ahem_antialias_none @@ -8781,9 +8781,9 @@ # numbers override as specified. # Note that 1 still creates a thread-pool of one thread! - name: layout.css.stylo-threads - type: int32_t + type: RelaxedAtomicInt32 value: -1 - mirror: once + mirror: always rust: true # Stylo work unit size. This is the amount of nodes we'll process in a single diff --git a/servo/ports/geckolib/Cargo.toml b/servo/ports/geckolib/Cargo.toml index ebf4178014e9..1bdaaa80b7d9 100644 --- a/servo/ports/geckolib/Cargo.toml +++ b/servo/ports/geckolib/Cargo.toml @@ -31,3 +31,4 @@ style = {path = "../../components/style", features = ["gecko"]} style_traits = {path = "../../components/style_traits"} thin-vec = { version = "0.2.1", features = ["gecko-ffi"] } to_shmem = {path = "../../components/to_shmem"} +lazy_static = "1.0" diff --git a/servo/ports/geckolib/glue.rs b/servo/ports/geckolib/glue.rs index a6c4ef126257..994ba554d542 100644 --- a/servo/ports/geckolib/glue.rs +++ b/servo/ports/geckolib/glue.rs @@ -204,6 +204,9 @@ pub unsafe extern "C" fn Servo_Initialize( // Pretend that we're a Servo Layout thread, to make some assertions happy. thread_state::initialize(thread_state::ThreadState::LAYOUT); + debug_assert!(is_main_thread()); + lazy_static::initialize(&STYLE_THREAD_POOL); + // Perform some debug-only runtime assertions. origin_flags::assert_flags_match(); traversal_flags::assert_traversal_flags_match(); diff --git a/servo/ports/geckolib/lib.rs b/servo/ports/geckolib/lib.rs index c11f6ab36ed1..8f6f344d4ddd 100644 --- a/servo/ports/geckolib/lib.rs +++ b/servo/ports/geckolib/lib.rs @@ -23,6 +23,7 @@ extern crate style; extern crate style_traits; extern crate thin_vec; extern crate to_shmem; +extern crate lazy_static; mod error_reporter; #[allow(non_snake_case)]