Skip to content

Fix Initialization in AcknowledgePossession, possible race condition#78

Open
linqen wants to merge 1 commit into
tranek:masterfrom
linqen:patch-1
Open

Fix Initialization in AcknowledgePossession, possible race condition#78
linqen wants to merge 1 commit into
tranek:masterfrom
linqen:patch-1

Conversation

@linqen
Copy link
Copy Markdown

@linqen linqen commented Apr 15, 2022

After a lot of debugging, I found that there is a possible race condition during bad network conditions (~200ms, 5% packet loss) with 5%~10% of repro chances.

If this happens, ASC will not be initialized properly and you will get LogAbilitySystem: Warning: Can't activate LocalOnly or LocalPredicted ability %s when not local!

This happens because during AcknowledgePossession, the pawn controller is not setup yet, and during FGameplayAbilityActorInfo::InitFromActor, PlayerController will be null forever, and then, when calling UAbilitySystemComponent::InternalTryActivateAbility, bool bIsLocal = AbilityActorInfo->IsLocallyControlled() will be false

I consider that OnRep_Pawn is a good place to call RefreshAbilityActorInfo, that will call FGameplayAbilityActorInfo::InitFromActor again, but the controller will be valid at that point.

…ition

After a lot of debugging, I found that there is a possible race condition during bad network conditions (~200ms, 5% packet loss) with 5%~10% of repro chances.

If this happens, ASC will not be initialized properly and you will get `LogAbilitySystem: Warning: Can't activate LocalOnly or LocalPredicted ability %s when not local!`

This happens because during AcknowledgePossession, the pawn controller is not setup yet, and during FGameplayAbilityActorInfo::InitFromActor, PlayerController will be null forever, and then, when calling UAbilitySystemComponent::InternalTryActivateAbility, bool bIsLocal = AbilityActorInfo->IsLocallyControlled() will be false

I consider that OnRep_Pawn is a good place to call RefreshAbilityActorInfo, that will call FGameplayAbilityActorInfo::InitFromActor again, but the controller will be valid at that point.
@linqen
Copy link
Copy Markdown
Author

linqen commented Oct 17, 2022

@tranek this issue is still reproduceable, and following the documentation examples will end in this issue sooner or later in any networked game.

If there is a way I can help you to repro this, and waste less time, let me know.

@SalahAdDin
Copy link
Copy Markdown

@linqen Is it reproducible yet?

@linqen
Copy link
Copy Markdown
Author

linqen commented Jul 13, 2023

@linqen Is it reproducible yet?

It is using UE 5.0. I don't have much free time right now, so I can't confirm on newer versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants