lf-lang / lingua-franca

Intuitive concurrent programming in any language
https://www.lf-lang.org
Other
235 stars 63 forks source link

After delays on pass through connections are rendered incorrectly #1624

Open cmnrd opened 1 year ago

cmnrd commented 1 year ago

The following minimal program uses a connection to parr outputs from its contained reactor through:

target Cpp;

reactor Src {
  output out: void
}

reactor Wrapper {
    src = new Src()
    output out: void
    src.out -> out after 0
}

main reactor {
    x = new Wrapper()
}

This program produces the following diagram: Screenshot_20230303_195756x

Notice that the after delay is rendered in the wrong place outside the Wrapper reactor. This also happens if a delay is specified or if we use a physical connection.

soerendomroes commented 1 year ago

@cmnrd This seems to be solved. image

Are there any special settings to replicate the problem?

cmnrd commented 1 year ago

I just happened to run into this issue again using the nightly build of VS Code. Which version did you use?

The following program

target Python

reactor Foo {
    input inp
    output out
    reaction(inp) -> out {==}
}

reactor Bar {
    foo = new Foo()
    input inp
    output out
    inp -> foo.inp after 1ms
    foo.out -> out after 5ms
}

reactor Baz {
    foo = new Bar()
    input inp
    output out
    inp -> foo.inp after 1ms
    foo.out -> out
}

produces this diagram Main

AFAIK, I don't have any special settings. I also played around with different settings, but nothing changed with respect to this issue.

cmnrd commented 1 year ago

The rendering of physical pass-through connections is also affected by this bug.

cmnrd commented 10 months ago

I keep stumbling across this issue. For me, it does not matter which synthesis and layout options I use. @soerendomroes, @a-sr do you have any idea what could be causing this? Is this likely to be an issue in the LF diagram synthesis, or is this rather a problem in the layout algorithm? If it is in the LF diagram synthesis, I am happy to try to investigate this myself, but I would need some pointers on where to start.

soerendomroes commented 10 months ago

This is a problem in ELK https://github.com/eclipse/elk/issues/953

A workaround would be to disable the disconnected component compaction. I am however sure that this will produce other undesired layouts.

cmnrd commented 10 months ago

Thanks for the pointer! I noticed that this is part of the "Release 0.9.1" milestone in ELK. Is there an expected time horizon for this release and for fixing the issue?

soerendomroes commented 10 months ago

There is no real horizon for this release, probably next year. But if you just need a picture for your thesis I can create that picture for you or at some point point you to a branch where this is fixed. You can also try to disable the compaction by setting org.eclipse.elk.layered.compaction.connectedComponents to false or by setting org.eclipse.elk.separateConnectedComponents to false and see if that helps.

cmnrd commented 10 months ago

Thanks for the offer, but I already used Inkscape to fix the diagrams for display in my thesis ;). I think this issue will come up more often when we promote the enclave feature, as wrapping a reactor and passing through connections with a delay or with physical connections is a common pattern.

Also thanks for the pointers to the concrete settings. I will try this once I finished my thesis (hopefully very soon). Perhaps it makes sense for us to expose this setting as part of the LF layout options in the IDE to give users access to the workaround.