Skip to content

applib/text_layout: pre-load glyph bitmaps in RTL rendering path#1547

Draft
pebble-aibot wants to merge 1 commit into
mainfrom
fix/text-render-preload-rtl-glyphs
Draft

applib/text_layout: pre-load glyph bitmaps in RTL rendering path#1547
pebble-aibot wants to merge 1 commit into
mainfrom
fix/text-render-preload-rtl-glyphs

Conversation

@pebble-aibot

Copy link
Copy Markdown

Summary

  • The BiDi (RTL) rendering path in walk_line() was missing glyph bitmap pre-loading before render_glyph() calls, unlike the standard LTR path which pre-loads via text_resources_get_glyph() to ensure cache hits
  • Without pre-loading, the RTL path triggers the full flash I/O call chain (text_resources_get_glyph → prv_load_glyph_bitmap → sys_resource_load_range) from deep in the stack, on top of 256 bytes of RTL shaping/reversal buffers already allocated on the stack
  • This contributes to KernelMain stack overflows during notification text rendering (FIRM-2575/FIRM-2643 crash family)
  • Adds text_resources_get_glyph() pre-load calls before every render_glyph() in the BiDi rendering block — for RTL segments, LTR segments within mixed text, and the trailing suffix glyph

Fixes FIRM-2643
Fixes FIRM-2575

Test plan

  • Verify text rendering with RTL text (Arabic, Hebrew) in notifications
  • Verify text rendering with mixed LTR/RTL text
  • Verify no regression in standard LTR notification rendering
  • Monitor KernelMain stack high-water mark during notification rendering with RTL content

🤖 Generated with Claude Code

The BiDi (RTL) rendering path in walk_line() calls render_glyph()
without first pre-loading glyph bitmaps into the font cache.  Unlike
the standard LTR path — which calls text_resources_get_glyph() before
the visitor callback so that render_glyph() hits a warm cache — the
RTL path lets render_glyph() trigger the full flash I/O call chain
(text_resources_get_glyph → prv_load_glyph_bitmap →
sys_resource_load_range) from deep in the stack.

Combined with the 256 bytes of RTL shaping/reversal buffers already on
the stack, this makes the RTL rendering path significantly more
stack-hungry than the LTR path and contributes to KernelMain stack
overflows during notification text rendering (FIRM-2575 crash family).

Add text_resources_get_glyph() pre-load calls before every
render_glyph() in the BiDi rendering block — for RTL segments, LTR
segments within mixed text, and the trailing suffix glyph — matching
the pattern the standard path already uses.

Fixes FIRM-2643
Fixes FIRM-2575

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Pebble AI Bot <pebbleaibot@repebble.com>
@gmarull

gmarull commented Jun 17, 2026

Copy link
Copy Markdown
Member

@pebble-aibot please, open a PR from a branch in your fork

Copy link
Copy Markdown
Collaborator

I think it only works in linear not in github

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants