TakeScreenshot() function not working

Here is my code:

	TSharedRef<FApplicationScreenshot> Screenshot = MakeShared<FApplicationScreenshot>();
	FSlateApplication::Get().TakeScreenshot(TimingProfilerWindow.ToSharedRef(), Screenshot->ScreenshotData,
		ScreenshotSize);

after calling TakingScreenshot(), the Screenshot->ScreenshotData remains empty. I tried to debug but end up with a function:

virtual void PrepareToTakeScreenshot(const FIntRect& Rect, TArray<FColor>* OutColorData, SWindow* InScreenshotWindow) {}
in SlateRenderer.h. I believe the function implementation is somewhere else.

The same code can work on UE4, I am just migrating to UE5. Does anyone know how to solve the problem?