Skip to content

Conversation

@arousta
Copy link

@arousta arousta commented Dec 27, 2023

This PR reproduces the current issue that we observe after a second call to the ReadFriendsList() functions, the GetFriends() won't return the list of friends.

The bug is here in the FUserManagerEOS::AddFriend() function:

	// Add this friend as a remote player if we haven't already (this will grab user info)
	if (!UniqueNetIdToAttributeAccessMap.Contains(FriendNetId))
	{
		AddRemotePlayer(LocalUserNum, EpicAccountId, FriendRef);
	}

The UniqueNetIdToAttributeAccessMap basically contains the cached information of friends which is populated during the first call to the ReadFriendsList().

During the second call, here we skip calling the AddRemotePlayer() function to avoid making unnecessary requests for obtainig the friends info which we already have in our cache.

However the problem is that we've forgotten to set the friend info using our cached values in the else block. The fix would be to move a piece of code from the FUserManagerEOS::ReadUserInfo() to here:

	// Add this friend as a remote player if we haven't already (this will grab user info)
	if (!UniqueNetIdToAttributeAccessMap.Contains(FriendNetId))
	{
		AddRemotePlayer(LocalUserNum, EpicAccountId, FriendRef);
	}
        else
        {
        // set user info from the cached info
            IAttributeAccessInterfaceRef AttributeAccessRef = UniqueNetIdToAttributeAccessMap[FriendNetId];
            FOnlineFriendEOSPtr FriendPtr = LocalUser.FriendsList->GetByNetId(FriendNetId);
            FriendPtr->UpdateInternalAttributes(AttributeAccessRef->GetInternalAttributes());
        }

@arousta
Copy link
Author

arousta commented Dec 27, 2023

@SebBergy Here's the minimal change that reproduces the issue. I have the log for running this on my local machin which shows after the second call to the ReadFriendsList() the GetFriendsList() returns zero friends.

@SebBergy
Copy link
Collaborator

This issue was due to a bug in UE that is now fixed in UE5.4 Closing this PR.

@SebBergy SebBergy closed this Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants