elkowar / eww

ElKowars wacky widgets
https://elkowar.github.io/eww
MIT License
9.36k stars 382 forks source link

[BUG] "Scope not in graph" for children of "for", when using listener #675

Open flmng0 opened 1 year ago

flmng0 commented 1 year ago

Checklist before submitting an issue

Description of the bug

When the listener script outputs a line, eww logs shows: "Scope not in graph"

I went through the code and changed the error so that I could see the Scope index that couldn't be found, and noticed that the values continually get bigger and bigger.

The above statement isn't the issue, I just thought it would be relevant and was trying to do some debugging on my own.

The error leads me to believe that there are hanging references somewhere.

Sorry for not being able to provide more information

Reproducing the issue

Minimal config:

eww.yuck

(deflisten bspwm-state
  :initial `{"desktops":[]}`
  "./desktops")

(defwindow bar
  :geometry (geometry :anchor 'center left')
  :windowtype 'dock'
  (desktops))

(defwidget desktops []
  (box :orientation 'v'
    (for desktop in { bspwm-state.desktops}
      (desktop-label :desktop {desktop}))))

(defwidget desktop-label [desktop]
  {bspwm-state.focusedDesktopId == desktop.id ? 'Y' : 'N'})

./desktops:

#!/usr/bin/env bash

bspc query -T --monitor
bspc subscribe desktop | while read
do
    bspc query -T --monitor
done

Expected behaviour

There shouldn't be an error as far as I'm aware, the listeners should stop before the widget updates and the notify is sent.

Additional context

The bspc query -T --monitor outputs with the following format:

{
  "focusedDesktopId": <ID as number>,
  "desktops": [
    { "id": <ID as number> },
    ....
  ]
}

Full output

There are a bunch of omitted fields, so here's a full example output:

Full example output from bspc
```json {"name":"eDP","id":4194306,"randrId":83,"wired":true,"stickyCount":0,"windowGap":12,"borderWidth":2,"focusedDesktopId":4194308,"padding":{"top":0,"right":0,"bottom":0,"left":56},"rectangle":{"x":0,"y":0,"width":1920,"height":1080},"desktops":[{"name":"I","id":4194308,"layout":"monocle","userLayout":"monocle","windowGap":12,"borderWidth":2,"focusedNodeId":16777230,"padding":{"top":0,"right":0,"bottom":0,"left":0},"root":{"id":4194317,"splitType":"vertical","splitRatio":0.520000,"vacant":false,"hidden":false,"sticky":false,"private":false,"locked":false,"marked":false,"presel":null,"rectangle":{"x":56,"y":0,"width":1864,"height":1080},"constraints":{"min_width":64,"min_height":32},"firstChild":{"id":16777230,"splitType":"vertical","splitRatio":0.471082,"vacant":false,"hidden":false,"sticky":false,"private":false,"locked":false,"marked":false,"presel":null,"rectangle":{"x":56,"y":0,"width":1864,"height":1080},"constraints":{"min_width":32,"min_height":32},"firstChild":null,"secondChild":null,"client":{"className":"kitty","instanceName":"kitty","borderWidth":2,"state":"tiled","lastState":"tiled","layer":"normal","lastLayer":"normal","urgent":false,"shown":true,"tiledRectangle":{"x":56,"y":0,"width":1864,"height":1080},"floatingRectangle":{"x":638,"y":338,"width":640,"height":400}}},"secondChild":{"id":25165838,"splitType":"vertical","splitRatio":0.520000,"vacant":false,"hidden":false,"sticky":false,"private":false,"locked":false,"marked":false,"presel":null,"rectangle":{"x":56,"y":0,"width":1864,"height":1080},"constraints":{"min_width":32,"min_height":32},"firstChild":null,"secondChild":null,"client":{"className":"kitty","instanceName":"kitty","borderWidth":2,"state":"tiled","lastState":"tiled","layer":"normal","lastLayer":"normal","urgent":false,"shown":true,"tiledRectangle":{"x":56,"y":0,"width":1864,"height":1080},"floatingRectangle":{"x":26,"y":-2,"width":1864,"height":1080}}},"client":null}},{"name":"II","id":4194309,"layout":"tiled","userLayout":"tiled","windowGap":12,"borderWidth":2,"focusedNodeId":18874412,"padding":{"top":0,"right":0,"bottom":0,"left":0},"root":{"id":18874412,"splitType":"vertical","splitRatio":0.520000,"vacant":false,"hidden":false,"sticky":false,"private":false,"locked":false,"marked":false,"presel":null,"rectangle":{"x":68,"y":12,"width":1852,"height":1068},"constraints":{"min_width":32,"min_height":32},"firstChild":null,"secondChild":null,"client":{"className":"firefox","instanceName":"Navigator","borderWidth":2,"state":"tiled","lastState":"tiled","layer":"normal","lastLayer":"normal","urgent":false,"shown":false,"tiledRectangle":{"x":68,"y":12,"width":1836,"height":1052},"floatingRectangle":{"x":478,"y":11,"width":960,"height":1053}}}},{"name":"III","id":4194310,"layout":"monocle","userLayout":"monocle","windowGap":12,"borderWidth":2,"focusedNodeId":27262990,"padding":{"top":0,"right":0,"bottom":0,"left":0},"root":{"id":27262990,"splitType":"vertical","splitRatio":0.520000,"vacant":false,"hidden":false,"sticky":false,"private":false,"locked":false,"marked":false,"presel":null,"rectangle":{"x":56,"y":0,"width":1864,"height":1080},"constraints":{"min_width":32,"min_height":32},"firstChild":null,"secondChild":null,"client":{"className":"kitty","instanceName":"kitty","borderWidth":2,"state":"tiled","lastState":"tiled","layer":"normal","lastLayer":"normal","urgent":false,"shown":false,"tiledRectangle":{"x":56,"y":0,"width":1864,"height":1080},"floatingRectangle":{"x":40,"y":12,"width":1836,"height":1052}}}},{"name":"IV","id":4194311,"layout":"tiled","userLayout":"tiled","windowGap":12,"borderWidth":2,"focusedNodeId":0,"padding":{"top":0,"right":0,"bottom":0,"left":0},"root":null},{"name":"V","id":4194312,"layout":"tiled","userLayout":"tiled","windowGap":12,"borderWidth":2,"focusedNodeId":0,"padding":{"top":0,"right":0,"bottom":0,"left":0},"root":null}]} ```
Prettified
```json { "name": "eDP", "id": 4194306, "randrId": 83, "wired": true, "stickyCount": 0, "windowGap": 12, "borderWidth": 2, "focusedDesktopId": 4194308, "padding": { "top": 0, "right": 0, "bottom": 0, "left": 56 }, "rectangle": { "x": 0, "y": 0, "width": 1920, "height": 1080 }, "desktops": [ { "name": "I", "id": 4194308, "layout": "monocle", "userLayout": "monocle", "windowGap": 12, "borderWidth": 2, "focusedNodeId": 16777230, "padding": { "top": 0, "right": 0, "bottom": 0, "left": 0 }, "root": { "id": 4194317, "splitType": "vertical", "splitRatio": 0.52, "vacant": false, "hidden": false, "sticky": false, "private": false, "locked": false, "marked": false, "presel": null, "rectangle": { "x": 56, "y": 0, "width": 1864, "height": 1080 }, "constraints": { "min_width": 64, "min_height": 32 }, "firstChild": { "id": 16777230, "splitType": "vertical", "splitRatio": 0.471082, "vacant": false, "hidden": false, "sticky": false, "private": false, "locked": false, "marked": false, "presel": null, "rectangle": { "x": 56, "y": 0, "width": 1864, "height": 1080 }, "constraints": { "min_width": 32, "min_height": 32 }, "firstChild": null, "secondChild": null, "client": { "className": "kitty", "instanceName": "kitty", "borderWidth": 2, "state": "tiled", "lastState": "tiled", "layer": "normal", "lastLayer": "normal", "urgent": false, "shown": true, "tiledRectangle": { "x": 56, "y": 0, "width": 1864, "height": 1080 }, "floatingRectangle": { "x": 638, "y": 338, "width": 640, "height": 400 } } }, "secondChild": { "id": 25165838, "splitType": "vertical", "splitRatio": 0.52, "vacant": false, "hidden": false, "sticky": false, "private": false, "locked": false, "marked": false, "presel": null, "rectangle": { "x": 56, "y": 0, "width": 1864, "height": 1080 }, "constraints": { "min_width": 32, "min_height": 32 }, "firstChild": null, "secondChild": null, "client": { "className": "kitty", "instanceName": "kitty", "borderWidth": 2, "state": "tiled", "lastState": "tiled", "layer": "normal", "lastLayer": "normal", "urgent": false, "shown": true, "tiledRectangle": { "x": 56, "y": 0, "width": 1864, "height": 1080 }, "floatingRectangle": { "x": 26, "y": -2, "width": 1864, "height": 1080 } } }, "client": null } }, { "name": "II", "id": 4194309, "layout": "tiled", "userLayout": "tiled", "windowGap": 12, "borderWidth": 2, "focusedNodeId": 18874412, "padding": { "top": 0, "right": 0, "bottom": 0, "left": 0 }, "root": { "id": 18874412, "splitType": "vertical", "splitRatio": 0.52, "vacant": false, "hidden": false, "sticky": false, "private": false, "locked": false, "marked": false, "presel": null, "rectangle": { "x": 68, "y": 12, "width": 1852, "height": 1068 }, "constraints": { "min_width": 32, "min_height": 32 }, "firstChild": null, "secondChild": null, "client": { "className": "firefox", "instanceName": "Navigator", "borderWidth": 2, "state": "tiled", "lastState": "tiled", "layer": "normal", "lastLayer": "normal", "urgent": false, "shown": false, "tiledRectangle": { "x": 68, "y": 12, "width": 1836, "height": 1052 }, "floatingRectangle": { "x": 478, "y": 11, "width": 960, "height": 1053 } } } }, { "name": "III", "id": 4194310, "layout": "monocle", "userLayout": "monocle", "windowGap": 12, "borderWidth": 2, "focusedNodeId": 27262990, "padding": { "top": 0, "right": 0, "bottom": 0, "left": 0 }, "root": { "id": 27262990, "splitType": "vertical", "splitRatio": 0.52, "vacant": false, "hidden": false, "sticky": false, "private": false, "locked": false, "marked": false, "presel": null, "rectangle": { "x": 56, "y": 0, "width": 1864, "height": 1080 }, "constraints": { "min_width": 32, "min_height": 32 }, "firstChild": null, "secondChild": null, "client": { "className": "kitty", "instanceName": "kitty", "borderWidth": 2, "state": "tiled", "lastState": "tiled", "layer": "normal", "lastLayer": "normal", "urgent": false, "shown": false, "tiledRectangle": { "x": 56, "y": 0, "width": 1864, "height": 1080 }, "floatingRectangle": { "x": 40, "y": 12, "width": 1836, "height": 1052 } } } }, { "name": "IV", "id": 4194311, "layout": "tiled", "userLayout": "tiled", "windowGap": 12, "borderWidth": 2, "focusedNodeId": 0, "padding": { "top": 0, "right": 0, "bottom": 0, "left": 0 }, "root": null }, { "name": "V", "id": 4194312, "layout": "tiled", "userLayout": "tiled", "windowGap": 12, "borderWidth": 2, "focusedNodeId": 0, "padding": { "top": 0, "right": 0, "bottom": 0, "left": 0 }, "root": null } ] } ```
flmng0 commented 1 year ago

eww debug output

Here ``` App { scope_graph: ScopeGraph { graph: ScopeGraphInternal { last_index: ScopeIndex(442), scopes: { ScopeIndex(439): Scope { name: "desktop-label", ancestor: Some( ScopeIndex(438), ), data: { "desktop": "{"borderWidth":2,"focusedNodeId":0,"id":4194311,"layout":"tiled","name":"IV","padding":{"bottom":0,"left":0,"right":0,"top":0},"root":null,"userLayout":"tiled","windowGap":12}", }, listeners: { "bspwm-state": [ Listener { needed_variables: [ "bspwm-state", "desktop", ], f: "function", }, ], "desktop": [ Listener { needed_variables: [ "bspwm-state", "desktop", ], f: "function", }, ], }, node_index: ScopeIndex(439), }, ScopeIndex(432): Scope { name: "for desktop = {\"borderWidth\":2,\"focusedNodeId\":16777230,\"id\":4194308,\"layout\":\"monocle\",\"name\":\"I\",\"padding\":{\"bottom\":0,\"left\":0,\"right\":0,\"top\":0},\"root\":{\"client\":null,\"constraints\":{\"min_height\":32,\"min_width\":64},\"firstChild\":{\"client\":{\"borderWidth\":2,\"className\":\"kitty\",\"floatingRectangle\":{\"height\":400,\"width\":640,\"x\":638,\"y\":338},\"instanceName\":\"kitty\",\"lastLayer\":\"normal\",\"lastState\":\"tiled\",\"layer\":\"normal\",\"shown\":false,\"state\":\"tiled\",\"tiledRectangle\":{\"height\":1080,\"width\":1864,\"x\":56,\"y\":0},\"urgent\":false},\"constraints\":{\"min_height\":32,\"min_width\":32},\"firstChild\":null,\"hidden\":false,\"id\":16777230,\"locked\":false,\"marked\":false,\"presel\":null,\"private\":false,\"rectangle\":{\"height\":1080,\"width\":1864,\"x\":56,\"y\":0},\"secondChild\":null,\"splitRatio\":0.471082,\"splitType\":\"vertical\",\"sticky\":false,\"vacant\":false},\"hidden\":false,\"id\":4194317,\"locked\":false,\"marked\":false,\"presel\":null,\"private\":false,\"rectangle\":{\"height\":1080,\"width\":1864,\"x\":56,\"y\":0},\"secondChild\":{\"client\":{\"borderWidth\":2,\"className\":\"kitty\",\"floatingRectangle\":{\"height\":1080,\"width\":1864,\"x\":26,\"y\":-2},\"instanceName\":\"kitty\",\"lastLayer\":\"normal\",\"lastState\":\"tiled\",\"layer\":\"normal\",\"shown\":false,\"state\":\"tiled\",\"tiledRectangle\":{\"height\":1080,\"width\":1864,\"x\":56,\"y\":0},\"urgent\":false},\"constraints\":{\"min_height\":32,\"min_width\":32},\"firstChild\":null,\"hidden\":false,\"id\":25165838,\"locked\":false,\"marked\":false,\"presel\":null,\"private\":false,\"rectangle\":{\"height\":1080,\"width\":1864,\"x\":56,\"y\":0},\"secondChild\":null,\"splitRatio\":0.52,\"splitType\":\"vertical\",\"sticky\":false,\"vacant\":false},\"splitRatio\":0.52,\"splitType\":\"vertical\",\"sticky\":false,\"vacant\":false},\"userLayout\":\"monocle\",\"windowGap\":12}", ancestor: Some( ScopeIndex(31), ), data: { "desktop": "{"borderWidth":2,"focusedNodeId":16777230,"id":4194308,"layout":"monocle","name":"I","padding":{"bottom":0,"left":0,"right":0,"top":0},"root":{"client":null,"constraints":{"min_height":32,"min_width":64},"firstChild":{"client":{"borderWidth":2,"className":"kitty","floatingRectangle":{"height":400,"width":640,"x":638,"y":338},"instanceName":"kitty","lastLayer":"normal","lastState":"tiled","layer":"normal","shown":false,"state":"tiled","tiledRectangle":{"height":1080,"width":1864,"x":56,"y":0},"urgent":false},"constraints":{"min_height":32,"min_width":32},"firstChild":null,"hidden":false,"id":16777230,"locked":false,"marked":false,"presel":null,"private":false,"rectangle":{"height":1080,"width":1864,"x":56,"y":0},"secondChild":null,"splitRatio":0.471082,"splitType":"vertical","sticky":false,"vacant":false},"hidden":false,"id":4194317,"locked":false,"marked":false,"presel":null,"private":false,"rectangle":{"height":1080,"width":1864,"x":56,"y":0},"secondChild":{"client":{"borderWidth":2,"className":"kitty","floatingRectangle":{"height":1080,"width":1864,"x":26,"y":-2},"instanceName":"kitty","lastLayer":"normal","lastState":"tiled","layer":"normal","shown":false,"state":"tiled","tiledRectangle":{"height":1080,"width":1864,"x":56,"y":0},"urgent":false},"constraints":{"min_height":32,"min_width":32},"firstChild":null,"hidden":false,"id":25165838,"locked":false,"marked":false,"presel":null,"private":false,"rectangle":{"height":1080,"width":1864,"x":56,"y":0},"secondChild":null,"splitRatio":0.52,"splitType":"vertical","sticky":false,"vacant":false},"splitRatio":0.52,"splitType":"vertical","sticky":false,"vacant":false},"userLayout":"monocle","windowGap":12}", }, listeners: {}, node_index: ScopeIndex(432), }, ScopeIndex(437): Scope { name: "desktop-label", ancestor: Some( ScopeIndex(436), ), data: { "desktop": "{"borderWidth":2,"focusedNodeId":27262990,"id":4194310,"layout":"monocle","name":"III","padding":{"bottom":0,"left":0,"right":0,"top":0},"root":{"client":{"borderWidth":2,"className":"kitty","floatingRectangle":{"height":1052,"width":1836,"x":40,"y":12},"instanceName":"kitty","lastLayer":"normal","lastState":"tiled","layer":"normal","shown":true,"state":"tiled","tiledRectangle":{"height":1080,"width":1864,"x":56,"y":0},"urgent":false},"constraints":{"min_height":32,"min_width":32},"firstChild":null,"hidden":false,"id":27262990,"locked":false,"marked":false,"presel":null,"private":false,"rectangle":{"height":1080,"width":1864,"x":56,"y":0},"secondChild":null,"splitRatio":0.52,"splitType":"vertical","sticky":false,"vacant":false},"userLayout":"monocle","windowGap":12}", }, listeners: { "desktop": [ Listener { needed_variables: [ "bspwm-state", "desktop", ], f: "function", }, ], "bspwm-state": [ Listener { needed_variables: [ "bspwm-state", "desktop", ], f: "function", }, ], }, node_index: ScopeIndex(437), }, ScopeIndex(29): Scope { name: "global", ancestor: None, data: { "EWW_NET": "{ "enp2s0": { "NET_UP": 0, "NET_DOWN": 0 },"lo": { "NET_UP": 0, "NET_DOWN": 0 },"wlp3s0": { "NET_UP": 1270, "NET_DOWN": 2912 } }", "EWW_CMD": ""/home/tmthy/ext/eww/target/debug/eww" --config "/home/tmthy/code/eww-mini"", "EWW_EXECUTABLE": "/home/tmthy/ext/eww/target/debug/eww", "EWW_RAM": "{"total_mem": 6093049856, "free_mem": 2049040384, "total_swap": 6092222464, "free_swap": 4990013440, "available_mem": 4240429056, "used_mem": 1852620800, "used_mem_perc": 30.405478}", "EWW_CPU": "{ "cores": [{"core": "cpu0", "freq": 1400, "usage": 1},{"core": "cpu1", "freq": 1400, "usage": 0},{"core": "cpu2", "freq": 1400, "usage": 1},{"core": "cpu3", "freq": 1400, "usage": 0},{"core": "cpu4", "freq": 1326, "usage": 1},{"core": "cpu5", "freq": 1400, "usage": 1},{"core": "cpu6", "freq": 1272, "usage": 1},{"core": "cpu7", "freq": 1400, "usage": 1}], "avg": 0.66755277 }", "EWW_TEMPS": "{ "AMDGPU_EDGE": 51,"DELL_SMM_AMBIENT": 39,"DELL_SMM_CPU": 50,"DELL_SMM_SODIMM": 36,"K10TEMP_TCTL": 51.125,"NVME_COMPOSITE_PC_SN530_NVME_WDC_512GB_TEMP1": 35.85 }", "EWW_DISK": "{ "/": {"name": "/dev/nvme0n1p3", "total": 510405902336, "free": 500875313152, "used": 9530589184, "used_perc": 1.8672569},"/home": {"name": "/dev/nvme0n1p3", "total": 510405902336, "free": 500875313152, "used": 9530589184, "used_perc": 1.8672569},"/boot": {"name": "/dev/nvme0n1p2", "total": 1020702720, "free": 758718464, "used": 261984256, "used_perc": 25.667048},"/boot/efi": {"name": "/dev/nvme0n1p1", "total": 627900416, "free": 613273600, "used": 14626816, "used_perc": 2.3294802} }", "EWW_BATTERY": "{"BAT1": { "status": "Discharging", "capacity": 14 }, "total_avg": 14.4}", "EWW_CONFIG_DIR": "/home/tmthy/code/eww-mini", "bspwm-state": "{"name":"eDP","id":4194306,"randrId":83,"wired":true,"stickyCount":0,"windowGap":12,"borderWidth":2,"focusedDesktopId":4194310,"padding":{"top":0,"right":0,"bottom":0,"left":56},"rectangle":{"x":0,"y":0,"width":1920,"height":1080},"desktops":[{"name":"I","id":4194308,"layout":"monocle","userLayout":"monocle","windowGap":12,"borderWidth":2,"focusedNodeId":16777230,"padding":{"top":0,"right":0,"bottom":0,"left":0},"root":{"id":4194317,"splitType":"vertical","splitRatio":0.520000,"vacant":false,"hidden":false,"sticky":false,"private":false,"locked":false,"marked":false,"presel":null,"rectangle":{"x":56,"y":0,"width":1864,"height":1080},"constraints":{"min_width":64,"min_height":32},"firstChild":{"id":16777230,"splitType":"vertical","splitRatio":0.471082,"vacant":false,"hidden":false,"sticky":false,"private":false,"locked":false,"marked":false,"presel":null,"rectangle":{"x":56,"y":0,"width":1864,"height":1080},"constraints":{"min_width":32,"min_height":32},"firstChild":null,"secondChild":null,"client":{"className":"kitty","instanceName":"kitty","borderWidth":2,"state":"tiled","lastState":"tiled","layer":"normal","lastLayer":"normal","urgent":false,"shown":false,"tiledRectangle":{"x":56,"y":0,"width":1864,"height":1080},"floatingRectangle":{"x":638,"y":338,"width":640,"height":400}}},"secondChild":{"id":25165838,"splitType":"vertical","splitRatio":0.520000,"vacant":false,"hidden":false,"sticky":false,"private":false,"locked":false,"marked":false,"presel":null,"rectangle":{"x":56,"y":0,"width":1864,"height":1080},"constraints":{"min_width":32,"min_height":32},"firstChild":null,"secondChild":null,"client":{"className":"kitty","instanceName":"kitty","borderWidth":2,"state":"tiled","lastState":"tiled","layer":"normal","lastLayer":"normal","urgent":false,"shown":false,"tiledRectangle":{"x":56,"y":0,"width":1864,"height":1080},"floatingRectangle":{"x":26,"y":-2,"width":1864,"height":1080}}},"client":null}},{"name":"II","id":4194309,"layout":"tiled","userLayout":"tiled","windowGap":12,"borderWidth":2,"focusedNodeId":18874412,"padding":{"top":0,"right":0,"bottom":0,"left":0},"root":{"id":18874412,"splitType":"vertical","splitRatio":0.520000,"vacant":false,"hidden":false,"sticky":false,"private":false,"locked":false,"marked":false,"presel":null,"rectangle":{"x":68,"y":12,"width":1852,"height":1068},"constraints":{"min_width":32,"min_height":32},"firstChild":null,"secondChild":null,"client":{"className":"firefox","instanceName":"Navigator","borderWidth":2,"state":"tiled","lastState":"tiled","layer":"normal","lastLayer":"normal","urgent":false,"shown":false,"tiledRectangle":{"x":68,"y":12,"width":1836,"height":1052},"floatingRectangle":{"x":478,"y":11,"width":960,"height":1053}}}},{"name":"III","id":4194310,"layout":"monocle","userLayout":"monocle","windowGap":12,"borderWidth":2,"focusedNodeId":27262990,"padding":{"top":0,"right":0,"bottom":0,"left":0},"root":{"id":27262990,"splitType":"vertical","splitRatio":0.520000,"vacant":false,"hidden":false,"sticky":false,"private":false,"locked":false,"marked":false,"presel":null,"rectangle":{"x":56,"y":0,"width":1864,"height":1080},"constraints":{"min_width":32,"min_height":32},"firstChild":null,"secondChild":null,"client":{"className":"kitty","instanceName":"kitty","borderWidth":2,"state":"tiled","lastState":"tiled","layer":"normal","lastLayer":"normal","urgent":false,"shown":true,"tiledRectangle":{"x":56,"y":0,"width":1864,"height":1080},"floatingRectangle":{"x":40,"y":12,"width":1836,"height":1052}}}},{"name":"IV","id":4194311,"layout":"tiled","userLayout":"tiled","windowGap":12,"borderWidth":2,"focusedNodeId":0,"padding":{"top":0,"right":0,"bottom":0,"left":0},"root":null},{"name":"V","id":4194312,"layout":"tiled","userLayout":"tiled","windowGap":12,"borderWidth":2,"focusedNodeId":0,"padding":{"top":0,"right":0,"bottom":0,"left":0},"root":null}]}", }, listeners: {}, node_index: ScopeIndex(29), }, ScopeIndex(31): Scope { name: "desktops", ancestor: Some( ScopeIndex(30), ), data: {}, listeners: { "bspwm-state": [ Listener { needed_variables: [ "bspwm-state", ], f: "function", }, ], }, node_index: ScopeIndex(31), }, ScopeIndex(435): Scope { name: "desktop-label", ancestor: Some( ScopeIndex(434), ), data: { "desktop": "{"borderWidth":2,"focusedNodeId":18874412,"id":4194309,"layout":"tiled","name":"II","padding":{"bottom":0,"left":0,"right":0,"top":0},"root":{"client":{"borderWidth":2,"className":"firefox","floatingRectangle":{"height":1053,"width":960,"x":478,"y":11},"instanceName":"Navigator","lastLayer":"normal","lastState":"tiled","layer":"normal","shown":false,"state":"tiled","tiledRectangle":{"height":1052,"width":1836,"x":68,"y":12},"urgent":false},"constraints":{"min_height":32,"min_width":32},"firstChild":null,"hidden":false,"id":18874412,"locked":false,"marked":false,"presel":null,"private":false,"rectangle":{"height":1068,"width":1852,"x":68,"y":12},"secondChild":null,"splitRatio":0.52,"splitType":"vertical","sticky":false,"vacant":false},"userLayout":"tiled","windowGap":12}", }, listeners: { "bspwm-state": [ Listener { needed_variables: [ "bspwm-state", "desktop", ], f: "function", }, ], "desktop": [ Listener { needed_variables: [ "bspwm-state", "desktop", ], f: "function", }, ], }, node_index: ScopeIndex(435), }, ScopeIndex(436): Scope { name: "for desktop = {\"borderWidth\":2,\"focusedNodeId\":27262990,\"id\":4194310,\"layout\":\"monocle\",\"name\":\"III\",\"padding\":{\"bottom\":0,\"left\":0,\"right\":0,\"top\":0},\"root\":{\"client\":{\"borderWidth\":2,\"className\":\"kitty\",\"floatingRectangle\":{\"height\":1052,\"width\":1836,\"x\":40,\"y\":12},\"instanceName\":\"kitty\",\"lastLayer\":\"normal\",\"lastState\":\"tiled\",\"layer\":\"normal\",\"shown\":true,\"state\":\"tiled\",\"tiledRectangle\":{\"height\":1080,\"width\":1864,\"x\":56,\"y\":0},\"urgent\":false},\"constraints\":{\"min_height\":32,\"min_width\":32},\"firstChild\":null,\"hidden\":false,\"id\":27262990,\"locked\":false,\"marked\":false,\"presel\":null,\"private\":false,\"rectangle\":{\"height\":1080,\"width\":1864,\"x\":56,\"y\":0},\"secondChild\":null,\"splitRatio\":0.52,\"splitType\":\"vertical\",\"sticky\":false,\"vacant\":false},\"userLayout\":\"monocle\",\"windowGap\":12}", ancestor: Some( ScopeIndex(31), ), data: { "desktop": "{"borderWidth":2,"focusedNodeId":27262990,"id":4194310,"layout":"monocle","name":"III","padding":{"bottom":0,"left":0,"right":0,"top":0},"root":{"client":{"borderWidth":2,"className":"kitty","floatingRectangle":{"height":1052,"width":1836,"x":40,"y":12},"instanceName":"kitty","lastLayer":"normal","lastState":"tiled","layer":"normal","shown":true,"state":"tiled","tiledRectangle":{"height":1080,"width":1864,"x":56,"y":0},"urgent":false},"constraints":{"min_height":32,"min_width":32},"firstChild":null,"hidden":false,"id":27262990,"locked":false,"marked":false,"presel":null,"private":false,"rectangle":{"height":1080,"width":1864,"x":56,"y":0},"secondChild":null,"splitRatio":0.52,"splitType":"vertical","sticky":false,"vacant":false},"userLayout":"monocle","windowGap":12}", }, listeners: {}, node_index: ScopeIndex(436), }, ScopeIndex(438): Scope { name: "for desktop = {\"borderWidth\":2,\"focusedNodeId\":0,\"id\":4194311,\"layout\":\"tiled\",\"name\":\"IV\",\"padding\":{\"bottom\":0,\"left\":0,\"right\":0,\"top\":0},\"root\":null,\"userLayout\":\"tiled\",\"windowGap\":12}", ancestor: Some( ScopeIndex(31), ), data: { "desktop": "{"borderWidth":2,"focusedNodeId":0,"id":4194311,"layout":"tiled","name":"IV","padding":{"bottom":0,"left":0,"right":0,"top":0},"root":null,"userLayout":"tiled","windowGap":12}", }, listeners: {}, node_index: ScopeIndex(438), }, ScopeIndex(441): Scope { name: "desktop-label", ancestor: Some( ScopeIndex(440), ), data: { "desktop": "{"borderWidth":2,"focusedNodeId":0,"id":4194312,"layout":"tiled","name":"V","padding":{"bottom":0,"left":0,"right":0,"top":0},"root":null,"userLayout":"tiled","windowGap":12}", }, listeners: { "bspwm-state": [ Listener { needed_variables: [ "bspwm-state", "desktop", ], f: "function", }, ], "desktop": [ Listener { needed_variables: [ "bspwm-state", "desktop", ], f: "function", }, ], }, node_index: ScopeIndex(441), }, ScopeIndex(434): Scope { name: "for desktop = {\"borderWidth\":2,\"focusedNodeId\":18874412,\"id\":4194309,\"layout\":\"tiled\",\"name\":\"II\",\"padding\":{\"bottom\":0,\"left\":0,\"right\":0,\"top\":0},\"root\":{\"client\":{\"borderWidth\":2,\"className\":\"firefox\",\"floatingRectangle\":{\"height\":1053,\"width\":960,\"x\":478,\"y\":11},\"instanceName\":\"Navigator\",\"lastLayer\":\"normal\",\"lastState\":\"tiled\",\"layer\":\"normal\",\"shown\":false,\"state\":\"tiled\",\"tiledRectangle\":{\"height\":1052,\"width\":1836,\"x\":68,\"y\":12},\"urgent\":false},\"constraints\":{\"min_height\":32,\"min_width\":32},\"firstChild\":null,\"hidden\":false,\"id\":18874412,\"locked\":false,\"marked\":false,\"presel\":null,\"private\":false,\"rectangle\":{\"height\":1068,\"width\":1852,\"x\":68,\"y\":12},\"secondChild\":null,\"splitRatio\":0.52,\"splitType\":\"vertical\",\"sticky\":false,\"vacant\":false},\"userLayout\":\"tiled\",\"windowGap\":12}", ancestor: Some( ScopeIndex(31), ), data: { "desktop": "{"borderWidth":2,"focusedNodeId":18874412,"id":4194309,"layout":"tiled","name":"II","padding":{"bottom":0,"left":0,"right":0,"top":0},"root":{"client":{"borderWidth":2,"className":"firefox","floatingRectangle":{"height":1053,"width":960,"x":478,"y":11},"instanceName":"Navigator","lastLayer":"normal","lastState":"tiled","layer":"normal","shown":false,"state":"tiled","tiledRectangle":{"height":1052,"width":1836,"x":68,"y":12},"urgent":false},"constraints":{"min_height":32,"min_width":32},"firstChild":null,"hidden":false,"id":18874412,"locked":false,"marked":false,"presel":null,"private":false,"rectangle":{"height":1068,"width":1852,"x":68,"y":12},"secondChild":null,"splitRatio":0.52,"splitType":"vertical","sticky":false,"vacant":false},"userLayout":"tiled","windowGap":12}", }, listeners: {}, node_index: ScopeIndex(434), }, ScopeIndex(433): Scope { name: "desktop-label", ancestor: Some( ScopeIndex(432), ), data: { "desktop": "{"borderWidth":2,"focusedNodeId":16777230,"id":4194308,"layout":"monocle","name":"I","padding":{"bottom":0,"left":0,"right":0,"top":0},"root":{"client":null,"constraints":{"min_height":32,"min_width":64},"firstChild":{"client":{"borderWidth":2,"className":"kitty","floatingRectangle":{"height":400,"width":640,"x":638,"y":338},"instanceName":"kitty","lastLayer":"normal","lastState":"tiled","layer":"normal","shown":false,"state":"tiled","tiledRectangle":{"height":1080,"width":1864,"x":56,"y":0},"urgent":false},"constraints":{"min_height":32,"min_width":32},"firstChild":null,"hidden":false,"id":16777230,"locked":false,"marked":false,"presel":null,"private":false,"rectangle":{"height":1080,"width":1864,"x":56,"y":0},"secondChild":null,"splitRatio":0.471082,"splitType":"vertical","sticky":false,"vacant":false},"hidden":false,"id":4194317,"locked":false,"marked":false,"presel":null,"private":false,"rectangle":{"height":1080,"width":1864,"x":56,"y":0},"secondChild":{"client":{"borderWidth":2,"className":"kitty","floatingRectangle":{"height":1080,"width":1864,"x":26,"y":-2},"instanceName":"kitty","lastLayer":"normal","lastState":"tiled","layer":"normal","shown":false,"state":"tiled","tiledRectangle":{"height":1080,"width":1864,"x":56,"y":0},"urgent":false},"constraints":{"min_height":32,"min_width":32},"firstChild":null,"hidden":false,"id":25165838,"locked":false,"marked":false,"presel":null,"private":false,"rectangle":{"height":1080,"width":1864,"x":56,"y":0},"secondChild":null,"splitRatio":0.52,"splitType":"vertical","sticky":false,"vacant":false},"splitRatio":0.52,"splitType":"vertical","sticky":false,"vacant":false},"userLayout":"monocle","windowGap":12}", }, listeners: { "desktop": [ Listener { needed_variables: [ "bspwm-state", "desktop", ], f: "function", }, ], "bspwm-state": [ Listener { needed_variables: [ "bspwm-state", "desktop", ], f: "function", }, ], }, node_index: ScopeIndex(433), }, ScopeIndex(30): Scope { name: "bar", ancestor: Some( ScopeIndex(29), ), data: {}, listeners: {}, node_index: ScopeIndex(30), }, ScopeIndex(440): Scope { name: "for desktop = {\"borderWidth\":2,\"focusedNodeId\":0,\"id\":4194312,\"layout\":\"tiled\",\"name\":\"V\",\"padding\":{\"bottom\":0,\"left\":0,\"right\":0,\"top\":0},\"root\":null,\"userLayout\":\"tiled\",\"windowGap\":12}", ancestor: Some( ScopeIndex(31), ), data: { "desktop": "{"borderWidth":2,"focusedNodeId":0,"id":4194312,"layout":"tiled","name":"V","padding":{"bottom":0,"left":0,"right":0,"top":0},"root":null,"userLayout":"tiled","windowGap":12}", }, listeners: {}, node_index: ScopeIndex(440), }, }, hierarchy_relations: OneToNElementsMap { child_to_parent: { ScopeIndex(438): ( ScopeIndex(31), [], ), ScopeIndex(433): ( ScopeIndex(432), [ ProvidedAttr { attr_name: "desktop", expression: desktop, }, ], ), ScopeIndex(439): ( ScopeIndex(438), [ ProvidedAttr { attr_name: "desktop", expression: desktop, }, ], ), ScopeIndex(441): ( ScopeIndex(440), [ ProvidedAttr { attr_name: "desktop", expression: desktop, }, ], ), ScopeIndex(434): ( ScopeIndex(31), [], ), ScopeIndex(435): ( ScopeIndex(434), [ ProvidedAttr { attr_name: "desktop", expression: desktop, }, ], ), ScopeIndex(436): ( ScopeIndex(31), [], ), ScopeIndex(31): ( ScopeIndex(30), [], ), ScopeIndex(432): ( ScopeIndex(31), [], ), ScopeIndex(30): ( ScopeIndex(29), [], ), ScopeIndex(437): ( ScopeIndex(436), [ ProvidedAttr { attr_name: "desktop", expression: desktop, }, ], ), ScopeIndex(440): ( ScopeIndex(31), [], ), }, parent_to_children: { ScopeIndex(30): { ScopeIndex(31), }, ScopeIndex(31): { ScopeIndex(434), ScopeIndex(436), ScopeIndex(440), ScopeIndex(438), ScopeIndex(432), }, ScopeIndex(434): { ScopeIndex(435), }, ScopeIndex(436): { ScopeIndex(437), }, ScopeIndex(432): { ScopeIndex(433), }, ScopeIndex(438): { ScopeIndex(439), }, ScopeIndex(29): { ScopeIndex(30), }, ScopeIndex(440): { ScopeIndex(441), }, }, }, inheritance_relations: OneToNElementsMap { child_to_parent: { ScopeIndex(31): ( ScopeIndex(29), Inherits { references: { "bspwm-state", }, }, ), ScopeIndex(436): ( ScopeIndex(31), Inherits { references: {}, }, ), ScopeIndex(439): ( ScopeIndex(29), Inherits { references: { "bspwm-state", }, }, ), ScopeIndex(433): ( ScopeIndex(29), Inherits { references: { "bspwm-state", }, }, ), ScopeIndex(435): ( ScopeIndex(29), Inherits { references: { "bspwm-state", }, }, ), ScopeIndex(432): ( ScopeIndex(31), Inherits { references: {}, }, ), ScopeIndex(438): ( ScopeIndex(31), Inherits { references: {}, }, ), ScopeIndex(437): ( ScopeIndex(29), Inherits { references: { "bspwm-state", }, }, ), ScopeIndex(440): ( ScopeIndex(31), Inherits { references: {}, }, ), ScopeIndex(441): ( ScopeIndex(29), Inherits { references: { "bspwm-state", }, }, ), ScopeIndex(434): ( ScopeIndex(31), Inherits { references: {}, }, ), ScopeIndex(30): ( ScopeIndex(29), Inherits { references: {}, }, ), }, parent_to_children: { ScopeIndex(31): { ScopeIndex(440), ScopeIndex(432), ScopeIndex(436), ScopeIndex(438), ScopeIndex(434), }, ScopeIndex(29): { ScopeIndex(435), ScopeIndex(31), ScopeIndex(30), ScopeIndex(433), ScopeIndex(437), ScopeIndex(439), ScopeIndex(441), }, }, }, }, root_index: ScopeIndex(29), event_sender: UnboundedSender { chan: Tx { inner: Chan { tx: Tx { block_tail: 0x0000560a09062100, tail_position: 213, }, semaphore: 0, rx_waker: AtomicWaker, tx_count: 7, rx_fields: "...", }, }, }, }, eww_config: EwwConfig { widgets: { "desktop-label": WidgetDefinition { name: "desktop-label", expected_args: [ AttrSpec { name: "desktop", optional: false, span: 327..334, }, ], widget: Basic( BasicWidgetUse { name: "label", attrs: Attributes { span: 339..394, attrs: { "text": AttrEntry { key_span: 339..394, value: {((bspwm-state["focusedDesktopId"] == desktop["id"]) ? "Y" : "N")}, }, }, }, children: [], span: 339..394, name_span: 339..339, }, ), span: 301..395, args_span: 326..335, }, "desktops": WidgetDefinition { name: "desktops", expected_args: [], widget: Basic( BasicWidgetUse { name: "box", attrs: Attributes { span: 194..297, attrs: { "orientation": AttrEntry { key_span: 195..207, value: "v", }, }, }, children: [ Loop( LoopWidgetUse { element_name: "desktop", elements_expr: bspwm-state["desktops"], elements_expr_span: 234..255, body: Basic( BasicWidgetUse { name: "desktop-label", attrs: Attributes { span: 276..295, attrs: { "desktop": AttrEntry { key_span: 277..285, value: {desktop}, }, }, }, children: [], span: 262..296, name_span: 263..276, }, ), span: 216..297, }, ), ], span: 190..298, name_span: 191..194, }, ), span: 165..299, args_span: 185..187, }, }, windows: { "bar": WindowDefinition { name: "bar", geometry: Some( WindowGeometry { anchor_point: AnchorPoint { x: START, y: CENTER, }, offset: CoordsWithUnits(0, 0), size: CoordsWithUnits(0, 0), }, ), stacking: Foreground, monitor: None, widget: Basic( BasicWidgetUse { name: "desktops", attrs: Attributes { span: 161..161, attrs: {}, }, children: [], span: 152..162, name_span: 153..161, }, ), resizable: true, backend_options: BackendWindowOptions { wm_ignore: false, sticky: true, window_type: Dock, struts: StrutDefinition { side: Top, dist: 0, }, }, }, }, initial_variables: { "EWW_CMD": ""/home/tmthy/ext/eww/target/debug/eww" --config "/home/tmthy/code/eww-mini"", "EWW_CONFIG_DIR": "/home/tmthy/code/eww-mini", "EWW_EXECUTABLE": "/home/tmthy/ext/eww/target/debug/eww", }, script_vars: { "EWW_TEMPS": Poll( PollScriptVar { name: "EWW_TEMPS", run_while_expr: "true", command: Function( 0x0000560a07339880, ), initial_value: None, interval: 2s, name_span: DUMMY, }, ), "EWW_CPU": Poll( PollScriptVar { name: "EWW_CPU", run_while_expr: "true", command: Function( 0x0000560a073354b0, ), initial_value: None, interval: 2s, name_span: DUMMY, }, ), "bspwm-state": Listen( ListenScriptVar { name: "bspwm-state", command: "./desktops", initial_value: "{"desktops":[]}", command_span: 54..66, name_span: 11..22, }, ), "EWW_DISK": Poll( PollScriptVar { name: "EWW_DISK", run_while_expr: "true", command: Function( 0x0000560a07336aa0, ), initial_value: None, interval: 2s, name_span: DUMMY, }, ), "EWW_RAM": Poll( PollScriptVar { name: "EWW_RAM", run_while_expr: "true", command: Function( 0x0000560a07339840, ), initial_value: None, interval: 2s, name_span: DUMMY, }, ), "EWW_NET": Poll( PollScriptVar { name: "EWW_NET", run_while_expr: "true", command: Function( 0x0000560a07337320, ), initial_value: None, interval: 2s, name_span: DUMMY, }, ), "EWW_BATTERY": Poll( PollScriptVar { name: "EWW_BATTERY", run_while_expr: "true", command: Function( 0x0000560a07336ed0, ), initial_value: None, interval: 2s, name_span: DUMMY, }, ), }, run_while_mentions: {}, }, open_windows: { "bar": EwwWindow { name: "bar", scope_index: ScopeIndex(30), gtk_window: Window { inner: ObjectRef { inner: 0x0000560a092d2a60, type: GtkWindow, }, }, destroy_event_handler_id: Some( SignalHandlerId( 202, ), ), }, }, failed_windows: {}, paths: EwwPaths { log_file: "/home/tmthy/.cache/eww_78fce6bf40f2ad8.log", ipc_socket_file: "/run/user/1000/eww-server_78fce6bf40f2ad8", config_dir: "/home/tmthy/code/eww-mini", }, } ```
wu4 commented 5 months ago

I ran into a similar issue. I believe it has to do with iterating over arrays that are contained in listened-for objects. When I isolated the array from the object, only printing the array to the listener raw, the errors stopped.

w-lfchen commented 1 month ago

bumping this, this might be closed by #1189. feel free to test things out and report your findings there! update: the pr doesn't fix this. i'll investigate this if i find the time to do so

w-lfchen commented 1 month ago

found the problem: seems like something is not updated properly and the variable wants to access old listeners sometimes that have been removed already.

i'll see whether i can fix it, it's always this error

update: this is weird, according to my debug prints, the scope is removed after the error states that it's not in the graph. i'll have to investigate further

update 2: seems like a tokio select race condition of some kind

here's my debugging config:

(defpoll obj
  :interval "1s"
  :initial `{"i": 3, "arr":[0]}`
"echo {\\\"i\\\": 3,\\\"arr\\\": [0]}")

(defwindow broken
  :monitor 0
  (widg))

(defwidget widg []
  (box
    (for desktop in {obj.arr}
      (widg-label))))

(defwidget widg-label []
{obj.i})

funnily enough, the whole widget disappears if the initial array is left empty. that's probably a different edge case bug