Aylur / astal

Building blocks for creating custom desktop shells
https://aylur.github.io/astal/
GNU Lesser General Public License v2.1
287 stars 37 forks source link

`Hyprland.get_default()` assertion `'node != NULL'` failed #92

Closed 42willow closed 1 week ago

42willow commented 1 week ago

The following error is caused by setting the constant to Hyprland.get_default()

(gjs:676759): Json-CRITICAL **: 17:07:46.311: json_object_get_int_member: assertion 'node != NULL' failed

This error repeats 6 times every 10 seconds (including 6 as soon as ags run is executed) edit: I just changed to the simple bar config under astal/examples/js and now it repeats 3 times when ags run is executed but doesn't continue you can find my config here: https://github.com/42Willow/astal-ts-config


Workspaces.tsx

import Hyprland from "gi://AstalHyprland";
import { bind } from "astal";

export function Workspaces() {
  const hypr = Hyprland.get_default()

  return <box className="Workspaces" vertical={true}>
      {bind(hypr, "workspaces").as(wss => wss
          .filter(ws => ws.id > 0)
          .sort((a, b) => a.id - b.id)
          .map(ws => (
              <button
                  className={bind(hypr, "focusedWorkspace").as(fw =>
                      ws === fw ? "focused" : "")}
                  onClicked={() => ws.focus()}>
                  {ws.id}
              </button>
          ))
      )}
  </box>
}

(This is in the example config)

Aylur commented 1 week ago

What version of hyprland are you on? What are the outputs of hyprctl monitors -j, hyprctl clients -j and hyprctl workspaces -j when this error log occurs?

42willow commented 1 week ago

hyprctl version

Hyprland, built from branch main at commit 918d8340afd652b011b937d29d5eea0be08467f5  (flake.lock: update).
Date: 2024-06-25
Tag: v0.41.2, commits: 918d8340afd652b011b937d29d5eea0be08467f5

flags: (if any)

hyprctl monitors -j

[{
    "id": 0,
    "name": "eDP-1",
    "description": "Chimei Innolux Corporation 0x14F3",
    "make": "Chimei Innolux Corporation",
    "model": "0x14F3",
    "serial": "",
    "width": 1920,
    "height": 1080,
    "refreshRate": 60.00100,
    "x": 2560,
    "y": 0,
    "activeWorkspace": {
        "id": 1,
        "name": "1"
    },
    "specialWorkspace": {
        "id": 0,
        "name": ""
    },
    "reserved": [0, 45, 0, 0],
    "scale": 1.00,
    "transform": 0,
    "focused": false,
    "dpmsStatus": true,
    "vrr": false,
    "activelyTearing": false,
    "disabled": false,
    "currentFormat": "XRGB8888",
    "availableModes": ["1920x1080@60.00Hz"]
},{
    "id": 1,
    "name": "DP-1",
    "description": "Dell Inc. DELL S2722QC GWD9MD3",
    "make": "Dell Inc.",
    "model": "DELL S2722QC",
    "serial": "GWD9MD3",
    "width": 2560,
    "height": 1440,
    "refreshRate": 59.95100,
    "x": 0,
    "y": 0,
    "activeWorkspace": {
        "id": 2,
        "name": "2"
    },
    "specialWorkspace": {
        "id": 0,
        "name": ""
    },
    "reserved": [0, 45, 0, 0],
    "scale": 1.00,
    "transform": 0,
    "focused": true,
    "dpmsStatus": true,
    "vrr": false,
    "activelyTearing": false,
    "disabled": false,
    "currentFormat": "XRGB8888",
    "availableModes": ["3840x2160@60.00Hz","3840x2160@30.00Hz","3840x2160@29.97Hz","3840x2160@25.00Hz","3840x2160@24.00Hz","3840x2160@23.98Hz","1920x2160@59.99Hz","2560x1440@59.95Hz","2048x1280@59.99Hz","1920x1080@60.00Hz","1920x1080@60.00Hz","1920x1080@59.94Hz","1920x1080@50.00Hz","1920x1080@25.00Hz","1920x1080@24.00Hz","1920x1080@23.98Hz","1600x1200@60.00Hz","1600x900@60.00Hz","1280x1024@75.03Hz","1280x1024@60.02Hz","1152x864@75.00Hz","1280x720@60.00Hz","1280x720@59.94Hz","1280x720@50.00Hz","1024x768@75.03Hz","1024x768@60.00Hz","800x600@75.00Hz","800x600@60.32Hz","720x576@50.00Hz","720x576@50.00Hz","720x480@60.00Hz","720x480@60.00Hz","720x480@59.94Hz","720x480@59.94Hz","640x480@75.00Hz","640x480@60.00Hz","640x480@59.94Hz","640x480@59.94Hz","720x400@70.08Hz"]
}]

hyprctl clients -j

[{
    "address": "0x2bef5380",
    "mapped": true,
    "hidden": false,
    "at": [1288, 94],
    "size": [1257, 1331],
    "workspace": {
        "id": 2,
        "name": "2"
    },
    "floating": false,
    "pseudo": false,
    "monitor": 1,
    "class": "kitty",
    "title": "nu",
    "initialClass": "kitty",
    "initialTitle": "kitty",
    "pid": 781649,
    "xwayland": false,
    "pinned": false,
    "fullscreen": false,
    "fullscreenMode": 0,
    "fakeFullscreen": false,
    "grouped": [],
    "tags": [],
    "swallowing": "0x0",
    "focusHistoryID": 0
},{
    "address": "0x2bae9d50",
    "mapped": true,
    "hidden": false,
    "at": [53, 98],
    "size": [2454, 1289],
    "workspace": {
        "id": -98,
        "name": "special:btop"
    },
    "floating": false,
    "pseudo": false,
    "monitor": 1,
    "class": "kitty",
    "title": "btop",
    "initialClass": "kitty",
    "initialTitle": "kitty",
    "pid": 781746,
    "xwayland": false,
    "pinned": false,
    "fullscreen": false,
    "fullscreenMode": 0,
    "fakeFullscreen": false,
    "grouped": [],
    "tags": [],
    "swallowing": "0x0",
    "focusHistoryID": 4
},{
    "address": "0x2baf5c30",
    "mapped": true,
    "hidden": false,
    "at": [53, 132],
    "size": [2454, 1255],
    "workspace": {
        "id": -97,
        "name": "special:scratchpad"
    },
    "floating": false,
    "pseudo": false,
    "monitor": 1,
    "class": "kitty",
    "title": "nu",
    "initialClass": "kitty",
    "initialTitle": "kitty",
    "pid": 782442,
    "xwayland": false,
    "pinned": false,
    "fullscreen": false,
    "fullscreenMode": 0,
    "fakeFullscreen": false,
    "grouped": [],
    "tags": [],
    "swallowing": "0x0",
    "focusHistoryID": 2
},{
    "address": "0x2bb771d0",
    "mapped": true,
    "hidden": false,
    "at": [2575, 94],
    "size": [1890, 971],
    "workspace": {
        "id": 1,
        "name": "1"
    },
    "floating": false,
    "pseudo": false,
    "monitor": 0,
    "class": "vesktop",
    "title": "Vesktop",
    "initialClass": "vesktop",
    "initialTitle": "Vesktop",
    "pid": 759164,
    "xwayland": true,
    "pinned": false,
    "fullscreen": false,
    "fullscreenMode": 0,
    "fakeFullscreen": false,
    "grouped": [],
    "tags": [],
    "swallowing": "0x0",
    "focusHistoryID": 3
},{
    "address": "0x2baced70",
    "mapped": true,
    "hidden": false,
    "at": [15, 94],
    "size": [1257, 1331],
    "workspace": {
        "id": 2,
        "name": "2"
    },
    "floating": false,
    "pseudo": false,
    "monitor": 1,
    "class": "firefox",
    "title": "Mozilla Firefox",
    "initialClass": "firefox",
    "initialTitle": "Mozilla Firefox",
    "pid": 780921,
    "xwayland": true,
    "pinned": false,
    "fullscreen": false,
    "fullscreenMode": 0,
    "fakeFullscreen": false,
    "grouped": [],
    "tags": [],
    "swallowing": "0x0",
    "focusHistoryID": 1
}]

hyprctl workspaces -j

[{
    "id": 1,
    "name": "1",
    "monitor": "eDP-1",
    "monitorID": 0,
    "windows": 1,
    "hasfullscreen": false,
    "lastwindow": "0x2bb771d0",
    "lastwindowtitle": "Vesktop"
},{
    "id": 2,
    "name": "2",
    "monitor": "DP-1",
    "monitorID": 1,
    "windows": 2,
    "hasfullscreen": false,
    "lastwindow": "0x2bef5380",
    "lastwindowtitle": "nu"
},{
    "id": -98,
    "name": "special:btop",
    "monitor": "DP-1",
    "monitorID": 1,
    "windows": 1,
    "hasfullscreen": false,
    "lastwindow": "0x0",
    "lastwindowtitle": ""
},{
    "id": -97,
    "name": "special:scratchpad",
    "monitor": "DP-1",
    "monitorID": 1,
    "windows": 1,
    "hasfullscreen": false,
    "lastwindow": "0x2baf5c30",
    "lastwindowtitle": "nu"
}]
Aylur commented 1 week ago

The hyprland lib only supports >0.42, see 69866935f12150d54e42009b29124245659d8a53 I'm not sure how to handle hyprland breaking changes tbh. There are cases when its not possible to continue the support for legacy versions for example this time Client.fullscreen type changed from bool to int. I would prefer to follow their latest releases however.

We could release versions of AstalHyprland that follows hyprland, then in code you would have to pick a version

import Hyprland from "gi://AstalHyprland?version=0.42"

But I don't like this, since it would lock astal projects to hyprland versions and would cause headaches for project maintainers that are distributed

so what I'm thinking of is to add a simple ipc client object thats version independent and you have to handle the event signal yourself

Or we could still still follow the latest release but just simply mark properties that you should not read on legacy versions

42willow commented 1 week ago

Ah thanks, I will close this issue then.

Marking properties that shouldn't be read on legacy versions seems a nice simple way of doing it - as Hyprland normally only releases small breaking changes(?).... but I don't know what I'm doing, so it might be worth asking someone else's opinion if you need help deciding.

For what it's worth I haven't noticed any actual issues with AstalHyprland besides these error messages, although I guess I would if I were doing something with Client.fullscreen. I'll probably update soon anyway :+1: