Pose Search Crash when searching continuing pose since update to 5.7

Callstack

UE::PoseSearch::FSearchContext::UpdateContinuingPoseSearchResult (PoseSearchContext.cpp:945)

UPoseSearchLibrary::MotionMatch (PoseSearchLibrary.cpp:1478)

FAnimNode_MotionMatching::UpdateAssetPlayer (AnimNode_MotionMatching.cpp:204)

FPoseLinkBase::Update (AnimNodeBase.cpp:343)

FAnimNode_ApplyMeshSpaceAdditive::Update_AnyThread (AnimNode_ApplyMeshSpaceAdditive.cpp:41)

FPoseLinkBase::Update (AnimNodeBase.cpp:343)

FAnimNode_ApplyMeshSpaceAdditive::Update_AnyThread (AnimNode_ApplyMeshSpaceAdditive.cpp:41)

Looking at the callstack and the code, we end up in UpdateContinuingPoseSearchResult with an invalid SchemaContinuingPoseSearchResult.

issue seems to be in PoseSearchLibrary when iterating on the Continuing poses, we try to save the first pose search from each schema, but that first one could be invalid. Then if in a different loop we have a valid pose search result we still use the invalid one from earlier.

see

void UPoseSearchLibrary::MotionMatch

...
	FCachedContinuingPoseSearchResults CachedContinuingPoseSearchResults;
	for (const FAssetsToSearchPerDatabasePair& AssetsToSearchPerDatabasePair : ContinuingPoseAssetsToSearchPerDatabase)
	{
		const UPoseSearchDatabase* Database = AssetsToSearchPerDatabasePair.Key;
		check(Database);
 
		const bool bInvalidatingContinuingPose = IsInvalidatingContinuingPose(ContinuingProperties.InterruptMode, Database, AssetsToSearchPerDatabase);
		if (!bInvalidatingContinuingPose)
		{
			// reconstructing and caching all the required continuing pose search results
			FSearchResult DatabaseContinuingPoseSearchResult;
			DatabaseContinuingPoseSearchResult.SetAssetTime(ContinuingProperties.PlayingAssetAccumulatedTime);
			DatabaseContinuingPoseSearchResult.PoseIdx = Database->GetPoseIndex(ContinuingProperties.PlayingAsset.Get(), ContinuingProperties.PlayingAssetAccumulatedTime, ContinuingProperties.bIsPlayingAssetMirrored, ContinuingProperties.PlayingAssetBlendParameters);
			DatabaseContinuingPoseSearchResult.Database = Database;
			CachedContinuingPoseSearchResults.CheckedAdd(Database, DatabaseContinuingPoseSearchResult);
 
			// EDITED COMMENT
			//Here we save using the schema, but we save even if its invalid and canAdvance will later be false
			//Then if we have a valid pose search result with the same Schema in a later loop, it will not override because we use find or add.
			const FSearchResult& SchemaContinuingPoseSearchResult = CachedContinuingPoseSearchResults.FindOrAdd(Database->Schema, DatabaseContinuingPoseSearchResult);
 
			const bool bForceInterrupt = IsForceInterrupt(ContinuingProperties.InterruptMode, Database, AssetsToSearchPerDatabase);
			const bool bCanAdvance = DatabaseContinuingPoseSearchResult.PoseIdx != INDEX_NONE;
			if (bCanAdvance && !bForceInterrupt)
			{
				SearchContext.UpdateContinuingPoseSearchResult(DatabaseContinuingPoseSearchResult, SchemaContinuingPoseSearchResult);
				Database->SearchContinuingPose(SearchContext, SearchResults);
			}
		}
	}

[Attachment Removed]

Steps to Reproduce
Since syncing 5.7 we have a rare crash in pose search.

We dont have repro steps as it seems to just randomly occur once in a while.

Looking at the code it looks like there might be an issue, but I’m not sure what is the intention of this piece of code.

[Attachment Removed]

Thank you for reporting this. We’ve had this reported by other users too. We’ll attempt to find a fix in the next hotfix. Reassigning this to [mention removed]​ to update the ticket. We might not get to it until the New Year.

-Jose

[Attachment Removed]

CL 49607910 in UE5/Main should fix the issue. Thanks!

[Attachment Removed]