Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Initialization in AcknowledgePossession, possible race condition #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

linqen
Copy link

@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
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

@linqen Is it reproducible yet?

@linqen
Copy link
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