Skip to content

bug: text-freetype2: letters go missing once the glyph atlas fills (upstream #11819) #195

Closed

Description

@rdoupe

Upstream OBS bug, reported by iarspider in obsproject/obs-studio#11819 (confirmed upstream; a maintainer noted the log shows the source running out of glyph space). Code unchanged in this fork.

Location

plugins/text-freetype2/text-functionality.c:311-314 in cache_glyphs():

		if (dy + g_h >= texbuf_h) {
			blog(LOG_WARNING, "Out of space trying to render glyphs");
			break;
		}

and text-functionality.c:166-168 in fill_vertex_buffer(), which skips any character with no cached glyph.

Class

Logic error: text silently drawn with letters missing.

Cause

Each Text (FreeType 2) source keeps one 2048x2048 glyph atlas. It is only emptied when the font or antialiasing changes (text-freetype2.c:431-434, :466-473), never when the text changes. Every new character is packed into the atlas and stays there. Once it is full, cache_glyphs() gives up and fill_vertex_buffer() drops every character that isn't cached, so all new letters disappear until the font is changed. It isn't specific to Cyrillic; any text that cycles through enough distinct characters fills it, faster at bigger sizes.

How it is reached

A Text (FreeType 2) source with default settings (256 px) whose text keeps changing, for example a "now playing" file. Replaying the reporter's attached title list (1055 titles, 136 distinct characters) through the plugin's packing logic with real FreeType glyphs:

Proposed fix and failing test

Fix: when a glyph doesn't fit and the atlas holds glyphs from earlier texts, empty the atlas once and cache the current text again. A single text that can't fit even in an empty atlas still stops with the warning instead of retrying forever.

RED test (cmocka, test_glyph_atlas), with the packing logic moved into a small glyph-atlas.[ch] (FreeType rendering and the texture are callbacks, behaviour unchanged): fixed 10x10 glyphs in a 64x64 atlas.

  • new_text_after_full_atlas_is_drawn: fails today (a letter of the current text is never cached)
  • texts_keep_rotating_without_losing_letters: fails today
  • guards that pass: glyphs are packed without overlap, already-cached glyphs aren't re-rendered, and text_larger_than_atlas_is_not_retried_forever

With the fix all 5 pass, and the replay above loses no letters at 128, 256 or 400 px.

Not related to #121 (UTF-16 text files), which changes the file-loading code; the two merge cleanly.

Activity

  1. rdoupe commented on Oct 11, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: this issue.

    1. RED: test_glyph_atlas (2 of 5 failing), packing logic moved into glyph-atlas.[ch] with no behaviour change.
    2. GREEN: empty the atlas once and re-cache when the current text does not fit.
      First PR within a day.
  2. added 2 commits that reference this issue on Oct 11, 2026
    f586019
    d94bdbd
  3. rdoupe commented on Oct 11, 2026

    @rdoupe
    CollaboratorAuthor

    @iarspider @CyberRex0 you reported or hit this in obsproject/obs-studio#11819, so a heads-up: it's fixed here in obs-rust by #196.

    Cause: each Text (FreeType 2) source caches every character it has drawn in one fixed-size glyph texture, and only empties it when the font changes. Once enough different characters have gone through (sooner at bigger sizes, e.g. the default 256 px), every new letter is silently dropped. Replaying the titles from the original report, letters start vanishing at about the 17th title.

    Workaround on stock OBS: change the font (or toggle antialiasing) on the source, which empties the cache; a smaller font size makes it fill more slowly.

    obs-rust is an AI-assisted fork of OBS; on Arch it's obs-studio-rust-git in the AUR.

    If you get a chance to try it, a short reply here on whether it fixes it for you would really help, especially if it does not. Your distro, OBS version, font and size are the useful details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions