Hi there,
I have some questions regarding the speckle functions. Specifically centering around SpeckleReceiver.ReceiveAndConvert_Async
and SpeckleReceiver.ReceiveAndConvert_Routine
.
Some background:
I first started out using the ReceiveAndConvert_Async
version and basically followed in how it was used in the SpeckleReceiverTests
class. Everything worked, when loading test models. However, as we grew the test size, Unity is freezing every time this function is called, and ReceiveAndConvert_Async
seems to be not async.
Changing it as detailed below (in SpecklerReceiver
), allows Unity to not freeze during the receive period, however it does freeze after, during the convert period.
public async void ReceiveAndConvert_Async(
Transform? parent = null,
Predicate<TraversalContext>? predicate = null
)
{
try
{
BeginOperation();
//Base commitObject = await ReceiveAsync(CancellationToken).ConfigureAwait(true);
Base commitObject = await Task.Run( async () => await ReceiveAsync(CancellationToken).ConfigureAwait(true));
....
Consequently, I’ve tried SpeckleReceiver.ReceiveAndConvert_Routine
, and Unity doesn’t lock up, and everything is responsive. However there is a major drawback.
This is the timing for my model, using the first solution (with the edited async)
As you can see this takes less than 15 mins to load in. However the whole process using SpeckleReceiver.ReceiveAndConvert_Routine
is still going on after 1.5hrs. Clearly this is problematic and I am rather stumped.
Questions:
- Is the edited code alright? Am I missing something? Would you like a PR?
- Is there a way for
ReceiveAndConvert_Async
to convert async as well? (I suspect there are some unity threading limitations.) - Why is
ReceiveAndConvert_Routine
taking so long? Is there something that can be done about it?
If you need to, you can DM me and I can share the model for your testing. We have bigger projects as well and I am sure others do too, so I must be doing something wrong. Thanks for helping.