진행중인 프로젝트에서 유저 테스트 및 피드백을 받아보았는데
그 중 한 피드백에 전투 중 프레임 드랍이 느껴졌다고 하는 피드백이 있어 프로파일링을 진행해보았다.

모든 스킬을 사용하여 전투를 한 부분

발견한 프레임 드랍
프레임 번호: 2790
1. 주요 관련 모듈
- Director.ProcessFrame: 32.9%
-
-
- Animators.Update: 애니메이션 업데이트 관련 작업 (32.8%).
- Animators.FireAnimationEventsAndBehaviours: 애니메이션 이벤트 처리.
- PlayerCombat.ExecuteAttack():
- 애니메이션 이벤트에서 호출되는 스킬을 사용하는 함수
- SoundManager.LoadFMODSound:
- AsyncReadManager.SyncRequest: 비동기 사운드 로드 작업.
- File.Read 및 File.Open 호출 다수.
- PlayerCombat.ExecuteAttack():
-
-
2. 해결
사운드 파일들의 Load In Background를 체크하여 메인스레드를 차단하지 않도록 해보았음.

많은 지표가 개선되었음

개선 후 약간이지만 주기적인 프레임 드랍 현상이 보임

PlayerStat의 Update에서 발생하고 있었고 확인 결과
private void Update()
{
// 마나 자동 회복
if (CurrentMP < MaxMP)
{
float regenAmount = ManaRegen * Time.deltaTime;
RestoreMana(regenAmount);
}
}
public float CurrentMP
{
get => currentMP;
private set
{
if (currentMP != value)
{
currentMP = Mathf.Clamp(value, 0f, MaxMP);
EventManager.Dispatch(GameEventType.PlayerStatChanged, null);
}
}
}
마나가 주기적으로 자동회복 되는 로직이 있었고, 이로 인해 마나가 회복될 때 마다 매 프레임 HUD 캔버스를 다시 그리고 있었음.
캔버스는 이벤트가 호출되면 캔버스를 다시 그리는 구조
코드를 개선하여, 오차범위 이내의 변화는 무시하도록 조건을 엄격히 설정하였음.
public float CurrentMP
{
get => currentMP;
private set
{
if (Mathf.Approximately(currentMP, value)) return;
float newValue = Mathf.Clamp(value, 0f, MaxMP);
if (Mathf.Approximately(currentMP, newValue)) return;
currentMP = newValue;
EventManager.Dispatch(GameEventType.PlayerStatChanged, null);
}
}
개선 후

이렇게 프로파일링을 통해 인지하지 못했던 성능저하를 쉽게 파악하고 해결할 수 있었음.