cables-gl / cables_docs

cables documentation docs.cables.gl
https://cables.gl/docs/docs
45 stars 16 forks source link

Exception after dragging input of custom operator to sub-patch input area #807

Open pixtur opened 4 months ago

pixtur commented 4 months ago

Describe the bug

Exception after dragging input of custom operator to sub-patch input area (see log and screenshot below).

Sub-Patch is broken:

image

After reloading the main patch, the port has been created but the graph extend is so extreme that no operators are shown. Please see the following screen capture:

https://github.com/user-attachments/assets/33a63a7c-9dbb-4afa-8b58-2f201efe1d40

How To Reproduce

  1. Open Editor
  2. Click on "crash" button

Platform dev.cables.gl / Chrome / Win10

Dev Tools If possible, check the devtools of your browser (chrome, firefox) and include any messages that seem relevant.

image

dev.cables.gl-1721820260647.log

pixtur commented 4 months ago

A quick update: I think there are multiple problems overlapping here. I couldn't reproduce the exception. But the disappearing sub-patch operators are a major issue IMHO.

After further experimentation I found the following:

I believe this problem is severe because it happens very frequently and might be related to artifacts in curved connect line display. Ideally the ops should be centered on the infinite canvas if their bounding box center exceeds a threshold.

Here is a capture of me looking for my ops:

https://github.com/user-attachments/assets/dfb20586-4008-4760-bc69-110cdf3633ab

pixtur commented 4 months ago

And sure enough op positions are somewhat extreme: image

pixtur commented 4 months ago

After manually adjusting the positions to a valid range I found that the subpatch contained multiple input and output regions which might be the cause or the result of the above mentioned exception: image

here is the definition for reference

ports:

{
    "ports": [
        {
            "id": "66jkwxe50",
            "title": "exe",
            "dir": 0,
            "type": 1,
            "order": 0
        },
        {
            "id": "5yz7hdjub",
            "title": "DefaultX",
            "dir": 0,
            "type": 0,
            "value": 2.5,
            "order": 1
        },
        {
            "id": "hrls3ml75",
            "title": "trigger",
            "dir": 1,
            "type": 1,
            "order": 1002
        }
    ]
}

gen-ports:

const port_66jkwxe50=op.inTrigger("66jkwxe50");
port_66jkwxe50.setUiAttribs({title:"exe",});

const port_5yz7hdjub=op.inFloat("5yz7hdjub",2.5);
port_5yz7hdjub.setUiAttribs({title:"DefaultX",});

const port_hrls3ml75=op.outTrigger("hrls3ml75");
port_hrls3ml75.setUiAttribs({title:"trigger",});

op.initInnerPorts=function(addedOps)
{
  for(let i=0;i<addedOps.length;i++)
  {
    if(addedOps[i].innerInput)
    {
const innerOut_66jkwxe50 = addedOps[i].outTrigger("innerOut_66jkwxe50");
innerOut_66jkwxe50.setUiAttribs({title:"exe"});
port_66jkwxe50.onTriggered = () => { innerOut_66jkwxe50.trigger(); };

const innerOut_5yz7hdjub = addedOps[i].outNumber("innerOut_5yz7hdjub");
innerOut_5yz7hdjub.set(port_5yz7hdjub.get() );
innerOut_5yz7hdjub.setUiAttribs({title:"DefaultX"});
port_5yz7hdjub.on("change", (a,v) => { innerOut_5yz7hdjub.set(a); });

    }
if(addedOps[i].innerOutput)
{
const innerIn_hrls3ml75 = addedOps[i].inTrigger("innerIn_hrls3ml75");
innerIn_hrls3ml75.setUiAttribs({title:"trigger"});
innerIn_hrls3ml75.onTriggered = () => { port_hrls3ml75.trigger(); };

}
}
};

Saving the actual sub-patch content wasn't straight forward, because the filetab layout seems to be broken with too many tabs? See the following screen-capture:

https://github.com/user-attachments/assets/fe9c2dbd-8c1e-49d0-97c3-f0b51fc17088

att_subpatch_json.json