Skip to content

Conversation

Tbaile
Copy link
Contributor

@Tbaile Tbaile commented Mar 9, 2025

Using graphql client provided in the project, subscriptions, mutations and queries works through ComposeUI.

For each node inside the simulation a subscriptor is being instantiated so that data can be followed for each node, however the node to pos entry returns a pretty long list of empty nodes, backend API might need to be adjusted.

Found with @AngeloFilaseta a non-reproducible issue while subscripting to the simulation data, sometimes the returned value is nullable where it isn't and that throws GraphQL completely mad, an alert has been provided that restarts the subscription. We might have a workaround, I'll leave the word to him tho.

As the video shows, the issue where data is being still processed is there, the backend keeps sending too many events.

Screencast.From.2025-05-11.23-12-20.mp4

Copy link

sonarqubecloud bot commented Mar 9, 2025

Copy link
Contributor

mergify bot commented May 6, 2025

Hi @Tbaile! 👋
This pull request has conflicts 😖
Could you fix it? 🔧
Thank you! 🙏

@Tbaile Tbaile force-pushed the master branch 2 times, most recently from 4570144 to 5bbd084 Compare May 11, 2025 20:20
@Tbaile Tbaile marked this pull request as ready for review May 11, 2025 21:17
@DanySK
Copy link
Member

DanySK commented May 14, 2025

@nicolasfara @cric96 you are the Compose experts. See if you can have a look to this one.

Copy link
Contributor

@cric96 cric96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minors on Composable function coding style

val errors = _errors.asStateFlow()

// TODO: parameterize the host and port and separate client in different file
private val client = GraphQLClientFactory.subscriptionClient(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to add URL and port as configuration/parameter of NodeViewModel

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I've actually left this as is for a couple of reasons:

  1. When launching the GUI through the ComposeMonitor, the simulation file provides the fields for the connection, these fields then can be used to generate a client inside a Dependency Injection mechanism (or simply a Factory) that then provides the the dependency to every ViewModel
  2. This in fact is not the case for the WASM/JS build, that probably needs an additional View to allow the user to set the data.

@DanySK DanySK force-pushed the master branch 10 times, most recently from 9210dba to b45cc95 Compare May 16, 2025 20:54
Comment on lines +25 to +28
thread(
name = "ComposeMonitor",
isDaemon = true,
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of launching a thread, have you considered using a different dispatcher in the launch?
Dealing with dispatchers is the usual way to go if you do not have strong reasons to spawn platform threads.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already tried, my first attempt was to use the compose-provided method of spawning the UI, however this forked the main process and halted all the other processes (simulation included). This is the only way I've found that don't fork processes and still manages all the UI on it's own.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear to me the attempt you performed. Could you paste here an MRE?
AFAIK spawning a coroutine does not fork the main process, instead, it schedules the coroutine into a different thread pool (if used a dispatcher)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was aware of this too. However it seems that issue resides on how the Monitors get spawned.

class ComposeMonitor : OutputMonitor<Any, Nothing> {
    override fun initialized(environment: Environment<Any, Nothing>) {
        application {
            Window(onCloseRequest = ::exitApplication, title = "Alchemist") { App() }
        }
    }
}

Launching this snippet, the simulation freezes, haven't been able to figure out why.

@DanySK DanySK force-pushed the master branch 3 times, most recently from f0ff956 to 3994856 Compare May 19, 2025 18:39
@DanySK DanySK force-pushed the master branch 9 times, most recently from 22322e6 to 3b697c7 Compare May 31, 2025 19:18
@Tbaile Tbaile requested review from DanySK, cric96 and nicolasfara June 1, 2025 08:37
Copy link

sonarqubecloud bot commented Jun 4, 2025

Copy link
Contributor

mergify bot commented Aug 17, 2025

Hi @Tbaile! 👋
This pull request has conflicts 😖
Could you fix it? 🔧
Thank you! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants