FyroxEngine/Fyrox · warning

Widget `preview_message` method is already registered!

Error message

Widget {node_handle} `preview_message` method is already registered!

What it means

The widget methods registry tracks which widgets implement preview_message so the UI can route messages to them efficiently. During widget registration (register), inserting the node handle into the preview_message set failed because it was already present, meaning the same widget is being registered twice. The duplicate registration is harmless but signals a double-registration bug.

Solutions

  1. Find and remove the duplicate registration call for the widget (register should run once per node).
  2. If the widget was removed and re-added, ensure unregister() runs on removal so the handle leaves the set.
  3. Guard your code with a check (or the registry's own insert result) before registering again.
  4. If the double registration is benign, the warning can be ignored, but fix the call site to keep the registry consistent.

Example fix

// before
ui.register_widget(node); // called again after node already added
ui.register_widget(node);
// after
if !registered.contains(&node_handle) {
    ui.register_widget(node);
}
Defensive patterns

Strategy: validation

Validate before calling

// Track registration state in your widget manager
if self.registered_handles.insert(node_handle) {
    ui.register_widget(node);
}

Prevention

When it happens

Trigger: Calling register() (or the surrounding add_node/registration flow) twice for the same widget whose Control::preview_messages is true — e.g. re-adding a node, re-registering after removal, or a builder path that registers an already-registered node.

Common situations: Programmatically re-inserting a widget handle, a custom Control added via both a builder and manual registration, or plugin code that re-registers widgets on reload.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of FyroxEngine/Fyrox@76c91aad8e (2026-09-10). Data as JSON: /api/errors/02f1d893b6be2e20. Report an issue: GitHub.

Appendix: source

Thrown at fyrox-ui/src/lib.rs:663

impl Debug for Clipboard {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!(f, "Clipboard")
    }
}

#[derive(Default, PartialEq, Debug, Clone)]
struct WidgetMethodsRegistry {
    preview_message: FxHashSet<Handle<UiNode>>,
    on_update: FxHashSet<Handle<UiNode>>,
    handle_os_event: FxHashSet<Handle<UiNode>>,
}

impl WidgetMethodsRegistry {
    fn register<T: Control + ?Sized>(&mut self, node: &T) {
        let node_handle = node.handle();

        if node.preview_messages && !self.preview_message.insert(node_handle) {
            Log::warn(format!(
                "Widget {node_handle} `preview_message` method is already registered!"
            ));
        }
        if node.handle_os_events && !self.handle_os_event.insert(node_handle) {
            Log::warn(format!(
                "Widget {node_handle} `handle_os_event` method is already registered!"
            ));
        }
        if node.need_update && !self.on_update.insert(node_handle) {
            Log::warn(format!(
                "Widget {node_handle} `on_update` method is already registered!"
            ));
        }
    }

    fn unregister<T: Control + ?Sized>(&mut self, node: &T) {
        let node_handle = node.handle();

View on GitHub (pinned to 76c91aad8e)