TheSuperHackers / GeneralsGamePatch

Community Patch to fix and improve original Generals Zero Hour 1.04
Other
53 stars 19 forks source link

GLA Demo particle effects performance degradation #2425

Open xezon opened 3 weeks ago

xezon commented 3 weeks ago

I've noticed that there's a continuous effects performance degradation the longer the game goes vs demo. Some visual & transition effects stop displaying the more demo units you kill & the more explosion they produce. I've tried playing with ParticleSystems Priority - changing from CRITICAL & WEAPON_EXPLOSION to DEATH_EXPLOSION but that didn't solve the issue.

Seems like effects are accumulating and prevent other effects from displaying fully. Similar to when you have too many firestorms simultaneously.

Originally posted by @Float1ngFree in https://github.com/TheSuperHackers/GeneralsGamePatch/issues/2311#issuecomment-2168126512

Float1ngFree commented 3 weeks ago

Might be related to Demo_BombTruck explosions as Demo_BombTruckDefaultExplosionTrail and Demo_BombTruckDefaultExplosionTrailSmoke have SystemLifetime = 0.

It degrades the most when you hit a multiple units & structures with something big, like MOAB. BombTrucks are usually at Demo's base.

Also, I've noticed that most of the structures have multiple SmolderingSmoke & SmolderingFire effects which also have SystemLifetime = 0 and become more flaky as effects accumulate. They should be tied to ConditionState changes, but they could be leaking...

Overall, I suspect that there are lots of minor leaks that accumulate and degrade the performance. As the game goes, the number of units/buildings can reduce, but the memory usage of the game only continues to raise with each killed/destroyed object.

xezon commented 3 weeks ago

It is a good lead. Can you download test map https://github.com/TheSuperHackers/GeneralsGameData/tree/main/Maps/Any/!TestAllFactions and build many units, kill them, and confirm the findings? If we narrow it to the specific unit(s), then we can go from there.

Bomb Truck did have a number of particle changes yes.

Float1ngFree commented 3 weeks ago

I've run a number of tests and wasn't able to reproduce this on a test map. I guess this was due to overall laggy nature of original Twilight Flame (although I haven't seen it previously eat into effects) and maybe the matchup of Demo vs SW producing lots of effects.

This is what it looks like:

https://github.com/TheSuperHackers/GeneralsGamePatch/assets/17320562/0cbc325f-f4d3-4c97-8745-6883d4f32621

Memory wise both testing and the game above looked the same. Maybe you have any idea what this could be? I've also uncovered an actual issue with structures' damage effects, I'll create a new issue for that later.

MTKing4 commented 3 weeks ago

I've seen this before on large FFA games, tends to happen when there's too many particle effects on the screen, i suspect it gets highlighted with demo due to the fact that all the units of demogen generate extra effects due to the demo upgrade detonation effect

xezon commented 3 weeks ago

The evidence from the video implies that the particle pool is exhausted. It is possible that there are lingering particle instances that are never deleted. We need to isolate which they are and then look at their setup.

Float1ngFree commented 3 weeks ago

I'd say that this probably goes beyond the title of this issue and doesn't relate solely to https://github.com/TheSuperHackers/GeneralsGamePatch/pull/2311 -- the added effects are copies of existing ones and differ in size and colors mostly. Replacing them with original effect produces the same outcome.

If I understand correctly, the SystemLifetime is the minimum number of frames the particleSystem should be executed, so that if it is less then Lifetime - it can be stopped & overridden by other effects. While if Lifetime < SystemLifetime - it is how many times the effect should be repeated (for example - TankFire). Correct?

xezon commented 3 weeks ago

I think SystemLifetime means life time of the ParticleSystem in frames, with 0=forever or bound to its owner. Lifetime means the lifetime of the effect(s) that the ParticleSystem creates.

In #1519 I have noted:

In my understanding, SystemLifetime = 0 is only ok if the parent object is short lived. If lifetime is uncapped, then particle will spawn every frame and live forever.

On quick inspection, there are at least 2 suspicious effects:

JetBurning WaterSpraySplash

I do not know if this is relevant for this issue. But my suspicion is that a ParticleSystem with SystemLifetime=0 is at fault.

Float1ngFree commented 3 weeks ago

@xezon I've actually noted another thing I'm suspicious of - BurstDelay:

Quite a lot of effects have 99999 with a large number of BurstCount. I've played with numbers and it doesn't seem to affect anything. It would imply that it is a delay between firing each burst, but it doesn't seem to.

Here is the test with two demo rebels, both using only RedDonuteCloudLite with BurstCount = 75.00 75.00, but one on the right (that is being killed) has BurstDelay = 0.00 0.00, while the left one suicides with BurstDelay = 99999.00 99999.00

https://github.com/TheSuperHackers/GeneralsGamePatch/assets/17320562/a0e5cfb0-c23d-4439-9bfa-ee7c41983af9

I can't tell any difference (apart from Suicide hit effect). I then went to game and played vs Demo and haven't noticed any effect degradation!

In some of your changes, I think for tanks muzzle effects, you've changed it from 99999 to 0 quoting BurstDelay = 0.00 0.00 ; Patch104p @tweak from infinite to spawn more than one puff -- have you observed any actual change?

xezon commented 3 weeks ago

BurstDelay is min..max frame delay until next particle burst. BurstCount is min..max number of particle spawns on this frame burst.

BurstDelay=99999 means that we have an initial particle spawn, and then wait 99999 frames (3333 minutes) until the next spawn - if the particle system remains alive.

Float1ngFree commented 3 weeks ago

BurstDelay=99999 means that we have an initial particle spawn, and then wait 99999 frames (3333 minutes) until the next spawn - if the particle system remains alive.

So basically 99999 is meaningless, effectively 0, correct?

xezon commented 3 weeks ago

BurstDelay = 99999 means that effect will effectively spawn once. I think it is synonymous for SystemLifetime = 1

Float1ngFree commented 3 weeks ago

Thanks for explanations. Well, then that's out of the way... Must be something else.

ThePredatorBG commented 1 week ago

I think the game skips particle effects by taking into account all of them on the map no matter if they are in player's view or not. That's what could be causing it, especially if the particle cap is set to a low number.

xezon commented 1 week ago

I have now tested Demo General, building very many Bomb Trucks, Scud Launchers, Quads, Scorpions, Bikes, Busses, RPG, Mobs, Terrorist, etc, then shooting, suiciding them. I have observed no performance degradation or particle issues.

@Float1ngFree Please upload a replay where the issue occured and note the commit hash you used for it.