Excesive computation using fort_character DamagedEvent

Summary

I track damage dealt and damage taken with my verse code. When the DamageEvent() or DamagedShieldEvent() is being triggered, it will update that amount in my array using PlayerStatsManager.UpdateIntStat().
This gives no issue when you hit somebody with an ar, it will call the Damaged event once for both players. But when you a shotgun which has 12 bullets it creates noticable lag. This seems due to excesive computation. As a result we are unable to track damage deal because a shotgun may cause (12+12 = 24) function calls which creates a hitch.
This bug has been present in our maps since 3 months.

I believe this can be prevented by allowing another way to track damage, right now the only way is using verse. I think the tracker_device should be able to track damage dealt and taken.

Relevant code:


GetData returns a player_stat_table which is pretty big


image

I also tested with a simpler function but the hitch still happens, though it was way less.
image

Please select what you are reporting on:

Unreal Editor for Fortnite

What Type of Bug are you experiencing?

Verse

Steps to Reproduce

  1. Create a code where you listen for Damage event and have a function that does quite some computation.
  2. Damage someone with a shotgun
  3. See a hitch

Expected Result

There is no hitch

Observed Result

When using a shotgun the function is being triggered 24 times. Verse cannot handle this if the function being called is slightly complicated, like doing all sorts of persistence things.

Platform(s)

PC

Island Code

6570-5231-1418

Video

Video (Calling PlayerStatsManager.UpdateIntStat() 2400 times per shotgun shot to intensify the effect I want to display in this bug report)


This is what I mean with intensifying the effect:

Video (How my map is right now, calling UpdateIntStat() once per function call, this gives about a 200ms delay when using the shotgun)

Vouch.

FORT-925940 has been created and its status is ‘Unconfirmed’. This is now in a queue to be reproduced and confirmed.

FORT-925939 has been added to our ‘To Do’ list. Someone’s been assigned this task.

Make a co routine that spawns the actual calculation event, see if that fixes it.

For example, make DamagedEvent spawn a method DamagedEventCo, that is suspendable so the calculation occurs on a different thread, then do your handling in the DamageEventCo method instead

So I should use suspends, eventhough I will not use a Sleep() in the function?

yes, you need suspends keyword in method signature to be able to call it via spawn

Thats kind of why you need this extra method, because the actual damagedEvent that we are subscribing to cant be used with suspends, so instead, you use this extra coroutine and just spawn it itself, and it is what is suspendable

So your method goes from just being

Damaged(DamageResult:damage_result):void=
  OLD CODE HERE

and becomes

Damaged(DamageResult:damage_result):void=
    spawn:
        DamagedCo(DamageResult)

DamagedCo(DamageResult:damage_result)<suspends>:void=
   OLD CODE NOW GOES IN HERE