summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2026-05-21 22:50:34 +0300
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2026-05-22 17:14:48 +0300
commite88380e464d7a0275556f99e38bd0f67358bcd4e (patch)
tree1fa0d4fae6882b0cf688345ab960229ec21b2911
parent9a8aacf05583af57cb007cd049d5562157f4ae90 (diff)
#5858 Crash at LLFontFreetype::renderGlyph
-rw-r--r--indra/llrender/llfontfreetype.cpp45
1 files changed, 44 insertions, 1 deletions
diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp
index 075c496ec5..3c5682dfc9 100644
--- a/indra/llrender/llfontfreetype.cpp
+++ b/indra/llrender/llfontfreetype.cpp
@@ -720,7 +720,50 @@ void LLFontFreetype::renderGlyph(EFontGlyphType bitmap_type, U32 glyph_index, ll
llassert_always_msg(FT_Err_Ok == error, message.c_str());
}
- llassert_always(! FT_Render_Glyph(mFTFace->glyph, gFontRenderMode) );
+ // TODO: Make this more sturdy, make asserts/ll_errs conditional
+ // to non-critical characters.
+ // Temporarily leaving them for data gathering, but unicode chars
+ // like emojis should not cause the app to crash and should either
+ // fallback to some predetermined bitmap or simply return.
+
+ // Verify glyph slot is valid
+ if (!mFTFace->glyph)
+ {
+ LL_ERRS() << "FT_Load_Glyph succeeded but glyph slot is null for wchar " << llformat("U+%xu", U32(wch)) << LL_ENDL;
+ return;
+ }
+
+ // Check if bitmap buffer is already allocated
+ // It can potentially be preallocated for:
+ // 1. SVG/color glyphs rendered by FreeType's SVG_RendererHooks
+ // 2. Embedded bitmap fonts
+ // 3. Some Color emoji that use FT_LOAD_COLOR
+ if (!mFTFace->glyph->bitmap.buffer)
+ {
+ error = FT_Render_Glyph(mFTFace->glyph, gFontRenderMode);
+ if (error != FT_Err_Ok)
+ {
+ std::string render_message = llformat(
+ "Error %d (%s) rendering wchar %u glyph %u: format=%lu, pixel_mode=%d, render_mode=%d",
+ error, FT_Error_String(error), wch, glyph_index,
+ (unsigned long)mFTFace->glyph->format, mFTFace->glyph->bitmap.pixel_mode, gFontRenderMode);
+
+ // Try with FT_RENDER_MODE_NORMAL as fallback
+ if (gFontRenderMode != FT_RENDER_MODE_NORMAL)
+ {
+ LL_WARNS_ONCE() << render_message << LL_ENDL;
+ error = FT_Render_Glyph(mFTFace->glyph, FT_RENDER_MODE_NORMAL);
+ if (error != FT_Err_Ok)
+ {
+ LL_ERRS() << "Fallback to FT_RENDER_MODE_NORMAL failed. " << render_message << LL_ENDL;
+ }
+ }
+ else
+ {
+ LL_ERRS() << render_message << LL_ENDL;
+ }
+ }
+ }
mRenderGlyphCount++;
}