Best (fastest) practice to display live 2D data

Dear all, Happy New Year!

I’d like to come back to this issue. In fact, I am back to streamlit, after giving dash/plotly a try. :slight_smile:

While plotly/dash being more flexible, I was not able to get a better performance, which might simply be a result from being a once in a while python scripter.

For my purposes, I find streamlit much easier to master. And I think the speed up we could achieve in this current use case is quite nice.

This brings me to my comment/question:

The speed up here is accomplished by using asyncio. However, the call of asyncio.run() at the end of the script prevents that control is going back to streamlit (though interaction is working).

But there is a (not so nice) side effect: when a given script changes the UI, say upon pressing some button some fields are to be removed, these fields get not removed completely, but remain visible, though grayed out (but still active!). I reckon this may relate to Ghost Elements in UI .

Would it be possible to provide a something like st.add_asyncio_run(my_func, args, kwargs), which is run after streamlit has finished rendering the web page?
With respect to the example above, something like

st.add_asyncio_run(run_app, 
    image_placeholder,
    queue_size_placeholder,
    st.session_state.queue,
    produce_delay,
    consume_delay)

?
Perhaps with some additional functionality to handle the event loop and one or more queues?

Best wishes
Markus