UWidgetComponent Crash in Add New FSlateFontAtlas
example Follow in our source code
UWidgetComponent Crash in Add New FSlateFontAtlas
example Follow in our source code
Hello,
The link that you have provided doesn’t seem to work for me. Could you provide an updated link for me to grab the test project?
Thank you
i am sorry, link is update
I have taken a look at the project, but I am not seeing a crash occurring. What steps do I need to take in your project in order to get the crash to occur? Also, what code am I looking at to see an example of where the crash is occurring in relation to the code?
sorry, i forget Setting Start Level
Open TestLevel, run Stand-alone, wait some time
if use Editor mode, font atlas texture is 2048x2048, need wait more time
in FSlateFontCache::AddNewEntry(
if( !NewSlot )
{
TSharedRef FontAtlas = FontAtlasFactory->CreateFontAtlas();
// Add the character to the texture
NewSlot = FontAtlas->AddCharacter( RenderData );
AtlasIndex = FontAtlases.Add( FontAtlas );
INC_DWORD_STAT_BY( STAT_SlateNumFontAtlases, 1 );
if( FontAtlases.Num() > 1 )
{
// There is more than one font atlas which means there is a lot of font data being cached
// try to shrink it next time
bFlushRequested = true;
}
when FontAtlases.Num() > 1
bFlushRequested = true;
then crash in Render Thread
I’ve reproduced the crash, but I don’t see the code you are adding. What file is this code in? Have you made changes to the source code?
in TestWidgetGameMode.h
UCLASS()
class TESTWIDGET_API UMyWidget : public UUserWidget
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintImplementableEvent, Category = "Blueprint Function")
void SetString(FString const& str);
virtual void NativeTick(const FGeometry& MyGeometry, float InDeltaTime) override;
virtual void NativeConstruct() override;
FString mStr;
wchar_t mChar;
};
in TestWidgetGameMode.cpp
void UMyWidget::NativeTick(const FGeometry& MyGeometry, float InDeltaTime)
{
mStr.Empty();
mStr.Append(&mChar, 1);
SetString(mStr);
++mChar;
}
void UMyWidget::NativeConstruct()
{
Super::NativeConstruct();
mChar = L'當';
}
other in blueprint
So I’ve taken a look at your project, and the crash seemed to be related to the character that you were passing in to your function. When you were displaying all of those different characters on the screen, one of them was causing the crash. I changed the display to just read “Hello” and there was no crash. However, this brought up a separate issue. You are spawning text blocks endlessly without deleting them, and after being open for about 20 minutes, the project jumped to over 30gb of memory usage. I’d highly recommend putting something in place that would delete the text blocks as they go off screen to prevent this sort of issue from occurring in the future.
crash happen, when the Font Atlas is Full
do TSharedRef FontAtlas = FontAtlasFactory->CreateFontAtlas();
so we need use different characters.
i change the source code, and now, the TextBlock is not spawning.
and let font size is bigger.
you can try the new code.
Where are you adding this code: TSharedRef FontAtlas = FontAtlasFactory->CreateFontAtlas();? Is this engine source code, or are you adding it to your GameMode class?
engine source code
in FSlateFontCache::AddNewEntry
This is a Resource Release Timing problem,
when the Font Atlas Texture is Full, Engine will try to shrink it next time.
Font Atlas Texture will be recreate.
It must recreate before render or after render, if not, crash has happen.
Hello,
I have been able to reproduce your issue, and have entered a bug report (UE-24760). Thank you for your report.
Have a great day,
Sean Flint
Hello,
This issue has been resolved in the 4.11 Preview. Thanks again for your report.
Have a great day
It’s a good news for me, thank your help.