Open Bug 1972767 Opened 6 hours ago Updated 5 hours ago

Selecting element from Browser Toolbox inspector crashes Firefox | MOZ_CRASH(the color could not be resolved even with a currentcolor specified?) | InspectorUtils.colorToRGBA doesn't handle light-dark in relative color

Categories

(DevTools :: Inspector, defect, P3)

defect

Tracking

(Not tracked)

People

(Reporter: nchevobbe, Unassigned, NeedInfo)

Details

Reported by gerard-majax on Element:

trying to use browser toolbox to select a UI element (notification), I'm hitting:

3529984> [3529984] Hit MOZ_CRASH(the color could not be resolved even with a currentcolor specified?) at servo/components/style/color/color_function.rs:420
3529984> #01: RustMozCrash (/home/alex/codaz/Mozilla/gecko-cinnabar/mozglue/static/rust/wrappers.cpp:18)
3529984> #02: mozglue_static::panic_hook (mozglue/static/rust/lib.rs:82)
3529984> #03: ??? (/home/alex/codaz/Mozilla/gecko-cinnabar/obj-browser-dbg/dist/bin/libxul.so + 0xf8c0f3c)
3529984> #04: std::panicking::rust_panic_with_hook (alloc/src/boxed.rs:0)
3529984> #05: std::panicking::begin_panic_handler::{{closure}} (std/src/panicking.rs:672)
3529984> #06: ??? (/home/alex/codaz/Mozilla/gecko-cinnabar/obj-browser-dbg/dist/bin/libxul.so + 0x10c2f299)
3529984> #07: ??? (/home/alex/codaz/Mozilla/gecko-cinnabar/obj-browser-dbg/dist/bin/libxul.so + 0x10c318e4)
3529984> #08: ??? (/home/alex/codaz/Mozilla/gecko-cinnabar/obj-browser-dbg/dist/bin/libxul.so + 0x10c7a433)
3529984> #09: ??? (/home/alex/codaz/Mozilla/gecko-cinnabar/obj-browser-dbg/dist/bin/libxul.so + 0x108f2895)
3529984> #10: style::values::computed::color::<impl style::values::generics::color::GenericColor<style::values::computed::percentage::Percentage>>::resolve_to_absolute (servo/components/style/values/computed/color.rs:85)
3529984> #11: Servo_ComputeColor (servo/ports/geckolib/glue.rs:8391)
3529984> #12: mozilla::dom::InspectorUtils::ColorToRGBA(mozilla::dom::GlobalObject&, nsTSubstring<char> const&, mozilla::dom::Document const*, mozilla::dom::Nullable<mozilla::dom::InspectorRGBATuple>&) (/home/alex/codaz/Mozilla/gecko-cinnabar/layout/inspector/InspectorUtils.cpp:0)
3529984> #13: mozilla::dom::InspectorUtils_Binding::colorToRGBA(JSContext*, unsigned int, JS::Value*) (InspectorUtilsBinding.cpp:3784)
3529984> #14: ??? (???:???)
3529984>
3529984> Program /home/alex/codaz/Mozilla/gecko-cinnabar/obj-browser-dbg/dist/bin/firefox (pid = 3529984) received signal 11.
3529984> Stack:
3529984> #01: nsProfileLock::FatalSignalHandler(int, siginfo_t*, void*) (/home/alex/codaz/Mozilla/gecko-cinnabar/toolkit/profile/nsProfileLock.cpp:191)
3529984> #02: WasmTrapHandler(int, siginfo_t*, void*) (/home/alex/codaz/Mozilla/gecko-cinnabar/js/src/wasm/WasmSignalHandlers.cpp:797)
3529984> #03: ??? (/lib/x86_64-linux-gnu/libc.so.6 + 0x45810)
3529984> #04: RustMozCrash (/home/alex/codaz/Mozilla/gecko-cinnabar/mozglue/static/rust/wrappers.cpp:18)
3529984> #05: mozglue_static::panic_hook (mozglue/static/rust/lib.rs:82)
3529984> #06: ??? (/home/alex/codaz/Mozilla/gecko-cinnabar/obj-browser-dbg/dist/bin/libxul.so + 0xf8c0f3c)
3529984> #07: std::panicking::rust_panic_with_hook (alloc/src/boxed.rs:0)
3529984> #08: std::panicking::begin_panic_handler::{{closure}} (std/src/panicking.rs:672)
3529984> #09: ??? (/home/alex/codaz/Mozilla/gecko-cinnabar/obj-browser-dbg/dist/bin/libxul.so + 0x10c2f299)
3529984> #10: ??? (/home/alex/codaz/Mozilla/gecko-cinnabar/obj-browser-dbg/dist/bin/libxul.so + 0x10c318e4)
3529984> #11: ??? (/home/alex/codaz/Mozilla/gecko-cinnabar/obj-browser-dbg/dist/bin/libxul.so + 0x10c7a433)
3529984> #12: ??? (/home/alex/codaz/Mozilla/gecko-cinnabar/obj-browser-dbg/dist/bin/libxul.so + 0x108f2895)
3529984> #13: style::values::computed::color::<impl style::values::generics::color::GenericColor<style::values::computed::percentage::Percentage>>::resolve_to_absolute (servo/components/style/values/computed/color.rs:85)
3529984> #14: Servo_ComputeColor (servo/ports/geckolib/glue.rs:8391)
3529984> #15: mozilla::dom::InspectorUtils::ColorToRGBA(mozilla::dom::GlobalObject&, nsTSubstring<char> const&, mozilla::dom::Document const*, mozilla::dom::Nullable<mozilla::dom::InspectorRGBATuple>&) (/home/alex/codaz/Mozilla/gecko-cinnabar/layout/inspector/InspectorUtils.cpp:0)
3529984> #16: mozilla::dom::InspectorUtils_Binding::colorToRGBA(JSContext*, unsigned int, JS::Value*) (InspectorUtilsBinding.cpp:3784)
3529984> #17: ??? (???:???)
3529984> Sleeping for 300 seconds.
3529984> Type 'gdb /home/alex/codaz/Mozilla/gecko-cinnabar/obj-browser-dbg/dist/bin/firefox 3529984' to attach your debugger to this thread.

The error comes from https://searchfox.org/mozilla-central/rev/5e24bf00212b4f5c053c1f8d943becf1b5bfd53c/servo/components/style/color/color_function.rs#414-427

pub fn resolve_to_absolute(&self, current_color: &AbsoluteColor) -> AbsoluteColor {
    // Map the color function to one with an absolute origin color.
    let resolvable = self.map_origin_color(|o| Some(o.resolve_to_absolute(current_color)));
    match resolvable.resolve_to_absolute() {
        Ok(color) => color,
        Err(..) => {
            debug_assert!(
                false,
                "the color could not be resolved even with a currentcolor specified?"
            );
            AbsoluteColor::TRANSPARENT_BLACK
        },
    }
}

This happened when trying to pick the "crash notification" element. You can get one displayed with the following diff:

diff --git a/browser/modules/ContentCrashHandlers.sys.mjs b/browser/modules/ContentCrashHandlers.sys.mjs
index 3a3f0951ea2ed..7de5dc5075caa 100644
--- a/browser/modules/ContentCrashHandlers.sys.mjs
+++ b/browser/modules/ContentCrashHandlers.sys.mjs
@@ -801,6 +801,8 @@ export var UnsubmittedCrashHandler = {
       lazy.RemoteSettingsCrashPull.start(
         this.showRequestedSubmissionsNotification.bind(this)
       );
+
+      this.showRequestedSubmissionsNotification(["1", "2", "3", "4"], true);
       if (this.prefs.prefHasUserValue("suppressUntilDate")) {
         if (this.prefs.getCharPref("suppressUntilDate") > this.dateString()) {
           // We'll be suppressing any notifications until after suppressedDate,

Okay, it looks like the function that we use doesn't support light-dark in relative color. For example InspectorUtils.colorToRGBA("oklch(from light-dark(blue, red) l c h)") will trigger the assertion.
Tiaan, would you know what's happening here?

Flags: needinfo?(tlouw)
Summary: Selecting element from Browser Toolbox inspector crashes Firefox | MOZ_CRASH(the color could not be resolved even with a currentcolor specified?) → Selecting element from Browser Toolbox inspector crashes Firefox | MOZ_CRASH(the color could not be resolved even with a currentcolor specified?) | InspectorUtils.colorToRGBA doesn't handle light-dark in relative color
Severity: -- → S3
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.