cesium-performance parsing json objects and adding to map

1. A concise explanation of the problem you're experiencing.
Actually this is not about cesium totally in fact. But the part of it is. Let's say there are many data comes from web service. We create cesium objects from json data, then add these objects to the cesium. The problem has 2 parts, first one is converting objects from json to cesium primitives takes time (in fact our cesium objects has composite primitives and such things, they are a bit complex objects) and the second problem is adding xk number of objects to cesium at once also takes time, I guess also locking the ui thread. Once you add the objects, modifying the positions etc. doesn't require resource but at initial state, this causes ui thread to be locked.

I tryed web workers to parse the data but unfortunately sending and receiving objects with functions is not possible. So right the process works with asyncron function calls with setTimeout. But since the data is large, it locks the render thread anyways. My question is:

a- Is there a way to easy serialize json objects to cesium primitives beforehand? If there is a way to make the service data more processable at backend this can also work. Any suggestion is okay.
b- What is the optimum way to put let's say 40000 billboards to the map at once? If it is possible without doing it at once, it will be also okay. The problem is they should be @map before next service call result comes to client which gives only 1 second or such.

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

function main(){
console.log("hello workd");
}

main();

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
To be able to visualize the data movement. The agents move from here to there with limited time intervals. To be able to show their movement on the time, positions should be changed. Not only positions but also colors, icons, lines between icons etc. will be updated as well.

4. The Cesium version you're using, your operating system and browser.

Latest cesium version always. os is windows 7 - 10, linux ubuntu latest. Browser is chrome 70+, firefox 50+

I think Cesium does already use web workers in constructing Primitives. The asynchronous flag controls this, which by default is true.

If you haven’t already, I’d use something like a Chrome/Firefox profiler to see where the bottleneck is. You could use CZML but if the bottleneck is just in parsing the JSON I think it’ll have the same issue.

This is a good example of showing how you can have 100,000 billboards quickly. It uses Billboard Instancing (https://cesium.com/blog/2015/10/28/billboard-instancing/) but I think this only works when they’re all using the same icon or a texture atlas.

My last suggestion to alleviate the blocking of the main thread is if you can somehow split the work over multiple frames, instead of trying to create them all in a single frame. Cesium’s Model class does something similar when initializing models so as not to block the main thread.

Hello,

Thanks for the fast answer. I didn't know about CZML, it seems promising that I will consider. However, like you said my main problem is still parsing json. Yeah, splitting big functions and making them async could help that I was also thinking about. Right now I found that the initial burst is the first problem and I splitted parsing and adding to map jobs to 2 different async functions. Parser pushes to queue and the other function gets features from queue and adds to map. Then updating features takes little time and I can catch interval well. I will dig dev tools and finding the bottlenecks further.

Thanks again for the suggestions,

30 Ocak 2019 Çarşamba 17:22:32 UTC+3 tarihinde Omar Shehata yazdı: