emilk/egui · error

Id must be non-zero.

Error message

Id must be non-zero.

What it means

Error "Id must be non-zero." thrown in emilk/egui.

Solutions

  1. Do not construct an Id from the value 0: use Id::new with a non-zero hash source instead of from_high_entropy_bits(0).

Example fix

let id = egui::Id::new("my_widget"); // safe, non-zero

When it happens

Trigger: Thrown at crates/egui/src/id.rs:130 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of emilk/egui@8fb03c9ae9 (2026-08-19). Data as JSON: /api/errors/7c95f39c3382cc84. Report an issue: GitHub.

Appendix: source

Thrown at crates/egui/src/id.rs:152

        let id = self.hash_with_salt(salt);

        #[cfg(debug_assertions)]
        id_source::insert_child(id, self, &salt);

        id
    }

    fn hash_with_salt(self, salt: IdSalt) -> Self {
        use core::hash::{BuildHasher as _, Hasher as _};
        let mut hasher = ahash::RandomState::with_seeds(1, 2, 3, 4).build_hasher();
        hasher.write_u64(self.value());
        hasher.write_u64(salt.value());
        Self::from_hash(hasher.finish())
    }

    /// Short and readable summary
    pub fn short_debug_format(&self) -> String {
        format!("{:04X}", self.value() as u16)
    }

    /// The inner value of the [`Id`].
    ///
    /// This is a high-entropy hash, or [`Self::NULL`].
    #[inline(always)]
    pub fn value(&self) -> u64 {
        self.0.get()
    }

    pub fn accesskit_id(&self) -> accesskit::NodeId {
        self.value().into()
    }

    /// Create a new [`Id`] from a high-entropy value. No hashing is done.
    ///
    /// This can be useful if you have an [`Id`] that was converted to some other type
    /// (e.g. accesskit::NodeId) and you want to convert it back to an [`Id`].

View on GitHub (pinned to 8fb03c9ae9)