-
Notifications
You must be signed in to change notification settings - Fork 1.3k
addImage is slow (takes 3-4 ms for each icon) #10249
Comments
Thank you for writing up this analysis, will look into doing some bechmarking myself and see where we can improve performance. That said, have you tried adding these images as sprites to your style and reference those sprites as your icon image in a symbolLayer? |
@tobrun these are airport icons (with exact runway orientation) - there are thousands of them - but I can pre-render them for sure. I was not sure if they would fit in a spite. isn't sprite limited by size ? I was pleasantly surprised that I could add so many images with addImage and use then a symbol icons. Just little slower than expected. For now I have limited to 600 or so largest airports. But I will investigate sprite idea too. Thank you for your prompt response. |
Could this be the reason ? |
Been doing some tests related to exposing
Taking in account your data for 2000, this would result in 70ms improvement. This shows we aren't getting much improvement and the main reason is that a large part of the time is spend on the following code that is found in both implementations of addImage/addImages:
I'm going to benchmark some alternatives to the setup above. |
One idea I'm looking into is doing the heavy lifting of converting the Bitmap to a byte array in a background job and see if we get a better results, in any case it will limit blocking the main thread. |
Yes, if calls are moved to non-blocking thread it will be much better. |
fwiw the long term fix for this that would result in the best performance in #9333 |
This is fixed with #11111 |
Platform: Android
Mapbox SDK version: 5.2 Beta 1
Steps to trigger behavior
Expected behavior
addImage for 2000 icons should take no more than 500 ms.
Actual behavior
Takes 3400 ms on my fairly potent Moto Z Force (Snapdragon 620) phone.
First 100 or so icons take 1 ms or less - last few hundred are taking 3-4 ms each. Changing the size of icons does not change timings. So this is not due to any re-scaling etc.
Since we have now deprecated MarerView on android this is the only way to get a large number of icons on Map. SO it woud be important to get this fixed. Perhaps a bulk add API can be added or internal data structures improved.
The text was updated successfully, but these errors were encountered: