swaywsr icon indicating copy to clipboard operation
swaywsr copied to clipboard

get class error: MissingInformation("Node{...}")

Open savchenko opened this issue 1 year ago • 8 comments

Launched in foreground, I have noticed get class error: MissingInformation("Node{...}") repeatedly returned to stdout.

Here, {...} is:

{
    id: 69,
    name: None,
    node_type: Con,
    border: None,
    current_border_width: 0,
    layout: SplitH,
    percent: Some(1.0),
    rect: Rect { x: 0, y: 26, width: 1920, height: 1054 },
    window_rect: Rect { x: 0, y: 0, width: 0, height: 0 },
    deco_rect: Rect { x: 0, y: 0, width: 0, height: 0 },
    geometry: Rect { x: 0, y: 0, width: 0, height: 0 },
    urgent: false,
    focused: false,
    focus: [9],
    nodes: [Node {
      id: 9,
      name: Some(\"SP — Mozilla Firefox\"),
      node_type: Con,
      border: Pixel,
      current_border_width: 4,
      layout: None,
      percent: Some(1.0),
      rect: Rect { x: 0, y: 26, width: 1920, height: 1054 },
      window_rect: Rect { x: 0, y: 4, width: 1920, height: 1054 },
      deco_rect: Rect { x: 0, y: 0, width: 0, height: 0 },
      geometry: Rect { x: 0, y: 0, width: 960, height: 790 },
      urgent: false,
      focused: false,
      focus: [],
      nodes: [],
      floating_nodes: [],
      sticky: false,
      representation: None,
      fullscreen_mode: Some(0),
      app_id: Some(\"Firefox-esr\"),
      pid: Some(93387),
      window: None,
      num: None,
      window_properties: None,
      marks: [],
      inhibit_idle: Some(false),
      idle_inhibitors: Some(IdleInhibitors { application: None, user: None }),
      shell: Some(XdgShell),
      visible: Some(false),
      output: None 
  }],
    floating_nodes: [],
    sticky: false,
    representation: None,
    fullscreen_mode: Some(0),
    app_id: None,
    pid: None,
    window: None,
    num: None,
    window_properties: None,
    marks: [],
    inhibit_idle: None,
    idle_inhibitors: None,
    shell: None,
    visible: None,
    output: None 
}

Formatted for readability. After some monkey-patching and println!() debugging, this seems to happen when workspace name is unchanged:

Old workspace name: 5 Pass
New workspace name: 5 Pass

get class error: MissingInformation [...]

The above is from https://github.com/pedroscaff/swaywsr/blob/c07ddf35c2e09180348930af9884f046c93ef768/src/lib.rs#L166

savchenko avatar Jan 20 '24 11:01 savchenko

Ano example of a Node that errors:

Node {
    id: 126,
    name: None,
    node_type: Con,
    border: None,
    current_border_width: 0,
    layout: SplitH,
    percent: Some(1.0),
    rect: Rect {
        x: 0,
        y: 26,
        width: 1920,
        height: 1054
    },
    window_rect: Rect {
        x: 0,
        y: 0,
        width: 0,
        height: 0
    },
    deco_rect: Rect {
        x: 0,
        y: 0,
        width: 0,
        height: 0
    },
    geometry: Rect {
        x: 0,
        y: 0,
        width: 0,
        height: 0
    },
    urgent: false,
    focused: false,
    focus: [9],
    nodes: [Node {
        id: 9,
        name: Some("SP — Mozilla Firefox"),
        node_type: Con,
        border: Pixel,
        current_border_width: 4,
        layout: None,
        percent: Some(1.0),
        rect: Rect {
            x: 0,
            y: 26,
            width: 1920,
            height: 1054
        },
        window_rect: Rect {
            x: 0,
            y: 4,
            width: 1920,
            height: 1054
        },
        deco_rect: Rect {
            x: 0,
            y: 0,
            width: 0,
            height: 0
        },
        geometry: Rect {
            x: 0,
            y: 0,
            width: 960,
            height: 790
        },
        urgent: false,
        focused: false,
        focus: [],
        nodes: [],
        floating_nodes: [],
        sticky: false,
        representation: None,
        fullscreen_mode: Some(0),
        app_id: Some("Firefox-esr"),
        pid: Some(93387),
        window: None,
        num: None,
        window_properties: None,
        marks: [],
        inhibit_idle: Some(false),
        idle_inhibitors: Some(IdleInhibitors {
            application: None,
            user: None
        }),
        shell: Some(XdgShell),
        visible: Some(false),
        output: None
    }],
    floating_nodes: [],
    sticky: false,
    representation: None,
    fullscreen_mode: Some(0),
    app_id: None,
    pid: None,
    window: None,
    num: None,
    window_properties: None,
    marks: [],
    inhibit_idle: None,
    idle_inhibitors: None,
    shell: None,
    visible: None,
    output: None
}

savchenko avatar Jan 21 '24 01:01 savchenko

thanks for the issue @savchenko, I'll take a look this week and get back to you :)

pedroscaff avatar Feb 06 '24 08:02 pedroscaff

@pedroscaff , just a heads-up, you might want to pull some changes from https://github.com/savchenko/swaywsr

savchenko avatar Feb 06 '24 09:02 savchenko

Hi, just to write that when testing for the PR I've just sent, I also noticed this defect.

GallaisPoutine avatar May 05 '24 18:05 GallaisPoutine

Hi again,

After a bit of research it appears on my side that we get into this caveat when the name of the node currently parsed is None. That can be explained by :

    if let Some(class) = name {
    ...
    } else {
        //println!("{:#?}", node);
        Err(LookupError::MissingInformation(format!("{:?}", node)))
    }

I guess the normal behavior would be to get this only when a class to not have a name, but since this is in get_class() which resolves ultimately in each update_tree() call, we maybe should remove the warning here.

Edit: Workspaces contain a non-floating 'root' container which is used to hold all the other containers. This one is almost empty, but links the subnodes. Testing with the below layout, I get two class errors for #6: con "(null)" and #64: con "(null)", which do not appear to have names

Layout:

$ swaymsg -t get_tree
#1: root "root"
  #2147483647: output "__i3"
    #2147483646: workspace "__i3_scratch"
  #3: output "LVDS-1"
    #4: workspace "1  |  |  | "
      #6: con "(null)"
        #32: con "get class error: MissingInformation("Node{...}") · Issue #13 · pedroscaff/swaywsr — Mozilla Firefox" (xdg_shell, pid: 4115, app_id: "firefox")
        #55: con "lib.rs (~/src/i3wsr/src) - GVIM1" (xwayland, pid: 6383, instance: "gvim", class: "Gvim", X11 window: 0x800003)
        #5: con "raphael@archlinux:~/src/swaywsr" (xdg_shell, pid: 3555, app_id: "foot")
        #61: con "lib.rs (~/src/swaywsr/src) - GVIM2" (xwayland, pid: 8122, instance: "gvim", class: "Gvim", X11 window: 0xA00003)
        #53: con "swaywsr: --all - gitk" (xwayland, pid: 6189, instance: "gitk", class: "Gitk", X11 window: 0x600062)
        #38: con "config (~/.config/sway) - GVIM" (xwayland, pid: 5483, instance: "gvim", class: "Gvim", X11 window: 0x400003)
        #54: con "raphael@archlinux:~/src/i3wsr" (xdg_shell, pid: 6246, app_id: "foot")
    #62: workspace "2 "
      #64: con "(null)"
        #63: con "raphael@archlinux:~" (xdg_shell, pid: 9918, app_id: "foot")
      #68: floating_con "raphael@archlinux:~" (xdg_shell, pid: 10959, app_id: "foot")

GallaisPoutine avatar May 05 '24 23:05 GallaisPoutine

Here is a workaround: 131238b - Fix MissingInformation class error

GallaisPoutine avatar May 06 '24 17:05 GallaisPoutine

thanks a lot @GallaisPoutine, I hope I can merge it this week but I promise latest next week, I'm quite busy but should get more calm from Monday on :slightly_smiling_face:

pedroscaff avatar May 07 '24 07:05 pedroscaff

No worries @pedroscaff, take your time. 🙂

GallaisPoutine avatar May 07 '24 09:05 GallaisPoutine

thanks @GallaisPoutine and @savchenko for reporting and fixing the bug :slightly_smiling_face:.

pedroscaff avatar May 28 '24 14:05 pedroscaff