We saw some unusual behavior in debugging things with our local changes. We’re on Unreal 5.5.4 plus custom local changes. However, the function in question is unchanged from 5.5.4-stock, namely ULocalPlayer::CalcSceneView . That function calls “new FSceneView(ViewInitOptions);” and then returns that pointer.
There’s no usage notes in LocalPlayer.h that say that the pointer should be released by the caller. The 5.5.4 code only seems to call that function from AvaGameViewportClient.cpp and XRCreativeITFComponent.cpp, and neither of them release the memory.
Is this a function that should be avoided? Something else? Thanks.
`FSceneView* ULocalPlayer::CalcSceneView( class FSceneViewFamily* ViewFamily,
FVector& OutViewLocation,
FRotator& OutViewRotation,
FViewport* Viewport,
class FViewElementDrawer* ViewDrawer,
int32 StereoViewIndex)
// The allocation that doesn’t seem to have a matching release/destruction is line 860 in UE5.5.4
FSceneView* const View = new FSceneView(ViewInitOptions);`
Steps to Reproduce
This issue came from examining source code in UE5.5.4. See the other section of this post for more details.
Hi there,
Scene Views lifecycle is managed by the FSceneViewFamily object, usually within a subclass of FSceneViewFamily called FSceneViewFamilyContext, which deletes its views in its destructor when it goes out of scope.
Is this a function you are intending to use for something?
Are you looking to get the View Location & View Rotation?
There are a few other ways to achieve that
From a camera component:
virtual void GetCameraView(float DeltaTime, FMinimalViewInfo& OutDesiredView);
Player Controller
void APlayerController::CalcCamera(float DeltaTime, FMinimalViewInfo& OutResult)
Player->CalcCamera(0.f, MinimalViewInfo) // passing 0.0f to not update the camera
void APlayerController::GetPlayerViewPoint( FVector& out_Location, FRotator& out_Rotation ) const
Player->GetPlayerViewPoint(MinimalViewInfo.Location, MinimalViewInfo.Rotation);
Let me know if this helps,
Kind Regards
Keegan Gibson
Thanks, that resolves this. My mistake for not reading closely enough