Page 1 of 1

[1.1.x] Hidden script rendered shapes are still being checked in preparation loop

Posted: Mon May 10, 2021 2:41 pm
by DBotThePony
Not a bug, bug design oversight.

Rendering library shapes which are hidden (set_visible false) still checked in main render loop, which is pointless, because it is clear that they won't even get drawn until getting un-hidden by scripts, and to me looks like nobody bothered or even thought doing this tiny optimisation.

This raise "Script render preparation" time with my mod: https://mods.factorio.com/mod/shield-generators, despite 99% of shapes are being invisible.

If you want to test against my mod, grab version 0.1.2, because 0.1.4 destroy rendering objects (and recreate them later) instead of hiding them to workaround this issue.
factorio_zFDuyaZ6Me.png
factorio_zFDuyaZ6Me.png (62.9 KiB) Viewed 1929 times

Re: [1.1.x] Hidden script rendered shapes are still being checked in preparation loop

Posted: Mon May 10, 2021 8:11 pm
by KeepResearchinSpoons
same thing with alt-view;
if you go with a "custom grid", should you need a 3x3 one or something, I can give you the code, it is exactly as you say.
It does NOT change "script preparation" whether an alt view is enabled.
It is even more deadly if you have an alt view with a detail-augmented copy.

On a side note, this api is not ready for anything big anyways.
If you go for the said 3x3 or 2x2 grid charted on the ground, using lines is... somewhat fine. A bit costly but well still tolerable.
But should you want to have a void-padded rects that are a bit smaller than a 2x2/3x3 cell,
AND use "just" a lot of rectangles with an option "no fill"...
Welcome are all the lags.

And I am not even talking about per-player overlay level here, just a global fully static all-players one.
*Just* 256 rects per chunk (2x2 grid) is apparently enough to push the fps clock to its max and meet some first lags for my side.

((for a test, add a rendering.create_rect at x%2==0, y%2==0 to the on_chunk and you shall see how fast it degrades the fps))

And the worst part, it does not help to "clean" all the other part of the map player should no be able to see either.

Re: [1.1.x] Hidden script rendered shapes are still being checked in preparation loop

Posted: Wed May 12, 2021 4:56 pm
by Rseding91
Thanks for the report. This is known behavior and there's currently nothing we can do about it.