Page 1 of 1

FPS death with lots of map tags

Posted: Sun Jun 24, 2018 11:19 pm
by darklich14
I play on a server that uses a scenario that had a bug that generated a lot of map tags (say, 5000+). For whatever reason, the render is fine when zoomed out but as you zoom in to where the stacked tags were located, the FPS would drop lower and lower (to less than 1FPS eventually) when zooming in closer and closer. One thing in particular that seems odd is that it gets even worse when the map tag isn't even visible any more and you're viewing the main game rather than the map representation, suggesting that the tag icons are rendered but not displayed even when they shouldn't be rendered and displayed. On running a profiler, the functions consuming the most time are

Code: Select all

RealOrientation::RealOrientation
,

Code: Select all

SignalID::isZero
and

Code: Select all

SpriteDrawOrder::SpriteDrawOrder

I have an intermediate understanding of computer graphics and it seems as though scaling a sprite or raster would cost the same whether zoomed in or zoomed out when done properly so I'm not sure if maybe some OpenGL call is either not available or not used or the scaling is done in software.

Reproduce this by creating 8000 map tags with icons at {0,0} and zoom into the location in map view.

Re: FPS death with lots of map tags

Posted: Sun Jun 24, 2018 11:45 pm
by Rseding91
Can you please post a save file that shows the problem?

Re: FPS death with lots of map tags

Posted: Mon Jun 25, 2018 2:23 am
by darklich14
Hi Rseding. Thanks for considering this investigation-worthy.

Attached is a map and a few screenshots.
factorio chart tag bug.zip
(1.88 MiB) Downloaded 75 times
Screenshot from 2018-06-24 22-15-44.png
Screenshot from 2018-06-24 22-15-44.png (3.67 MiB) Viewed 1328 times
Screenshot from 2018-06-24 22-16-06.png
Screenshot from 2018-06-24 22-16-06.png (3.53 MiB) Viewed 1328 times
Here's the snippet to generate more:

Code: Select all

 /c for x=1,1000 do game.player.force.add_chart_tag(game.player.surface, {position={0,0}, text='Test', icon={type='item', name='electric-energy-interface'}}) end
The map was created by making a default map with all defaults and running the snippet above. you can see in the screenshots, 100 chart tags makes for a drop to 18 fps and 1000 tags drops it to 5 fps. I'll let you take it from there.

Re: FPS death with lots of map tags

Posted: Mon Jun 25, 2018 10:38 am
by posila
It's because in zoom-to-world view map is still rendered to offscreen buffer which it then used to cover areas out of radar range. In that zoom level the icon will cover pretty much whole screen, and redrawing screen-sized area 1000 times takes quite a lot of time even on high-end GPUs.

I am calling it minor issue for now. In the future the icons might not scale lineraly with map zoom, so that would not be as much of a problem.