Closed SimonDanisch closed 3 days ago
Ok, I kind of didn't want to merge this, since (small) message processing is 2x slower...
But I just got reminded, that this solves a long standing issue with Makie not being able to do picking async (which relies on Bonito.eval_js_value
, which needs to send a message and wait for a reply) - and I just found out in https://github.com/MakieOrg/Makie.jl/pull/4317, that picking is pretty slow and not doing it async in e.g. DataInspector
is grinding the whole system to a halt.
I think it's also more correct, although it still doesn't solve that the observables are always triggered from the same thread as the session was created in, due to a subsession getting the messages from it's parent session, which can be created from a different thread. I think this will need solving in another PR, since this is a clear improvement over master in that regard.
Testing with WGLMakie also shows, that things actually run smoother with this PR, even though processing messages is slower... I guess it's because of the buffered nature of the channel and not blocking the websocket anymore for the time of processing the message.
This should make sure, that the message is processed in the same thread/task as the Session was created.