Speckle-Unity Slow Streaming of medium/big projects


I spent some time testing out the latest Speckle - Unity connector. The receiver on Unity side works smooth and fast, with smaller projects (~250 objects / total children count), but with medium/big projects (over 11500 objects) it says Receiving and the little progress bar is stuck at about 10% progress for around 15 minutes. (after 15 mins I stopped the process)

Now my question is, what could we do about this, and is there any work around for this issue? Right now even on the Speckle.xyz server’s web viewer this medium project takes more then 5 minutes to load, but at least it loads.

One thing I recognized is that on the Speckle web viewer, the streaming is done gradually, meaning that it loads and shows objects one by one, while in the Unity it looks like a buffering time and then the models just pops up.

Please correct me if I’m wrong!

Hey @dr.P ,

Ouch! 15 mins is clearly unacceptable :sweat_smile:. There’s a few things that could be going on, and first of all we should narrow it down and see if the problem is the download or the conversion.

Are you able to put some breakpoints around this line?

I’m not very experienced with unity, but I noticed some weird and unjustifiable performance issues when dealing with its API. For instance see these lines, I’m assuming you’re facing something similar and that it’s not really an issue with the streaming itself :slight_smile:

If you could also share the stream with me I’d be happy to investigate further next week!

Hey @teocomi ,

I tried to put some breakpoints around the line you suggested (line 148 at Receiver.cs) but I’m not able to reach that breakpoint which I put right before that line, in 15mins, so I guess it’s stuck at the beginning of the downloading probably?

I see the lines you are talking about, regarding the triangles, but I’m not sure how’s that speeding up any processes… It’s indeed interesting :thinking:

It’s stuck at this point

Alright, I’ll dive deep into this next week :slight_smile:
Cc @dimitrie since he has been debugging network issues recently.

1 Like

Ok, sounds good! :slight_smile:
BTW I sent you the stream link in DM, let me know if it works. :slight_smile:

1 Like

Hey @teocomi ! Any news on this? :slight_smile:

Not yet, sorry! Planning to look at it by the end of the week :slight_smile:

It’s ok @teocomi , no rush. Please let me know when you have any news on this. :slight_smile:

Hey @dr.P !

We started looking into this and have some preliminary findings (thanks dim & cristi):

  1. the model is actually huge ~800mb of data
  2. it seems some geometry in the model is extremely heavy, in particular, some chairs having ~300k vertices each!
  3. the Unity connector is much slower at receiving the model compared to other connectors (weird as they use the same code)

I’m still looking into (3), in the meantime, I’d suggest trying to replace/simplify those chairs or at least exclude them from the stream. It should make everything much faster!

1 Like

@pablothedolphin are you still around these parts? If so would really like to bump heads regarding this slowness issue, I just tried again and exactly the same code takes 25min in unity and 3min in Rhino…

Hey @teocomi and @dr.P,

This slowness is actually a result of the huge overhead involved in creating new instances of objects in Unity. This issue exists in any game engine and is beyond just rendering. This issue is made worse by the fact that Unity’s runtime aims to run at 60fps. Writing async code that plays nice with a game engine’s framerate is the challenge we’re dealing with here.

The solution would be to create the received objects between each batch that’s been downloaded then call await Task.Yield (); to yield to the next frame. From there, you can tweak how many objects you want to request per batch to get the best result.

Hope this helps!


Thanks for chiming in dude, appreciate it!

The slowness we’re experiencing happens before objects are converted and instantiated in Unity, it happens purely when data is being retrieved from the server.

I’ve described the issue more in detail here.

1 Like