Skip to content

fix(sidebar): bound keyboard backlight scale marks - #31

Open
perlowja wants to merge 1 commit into
singularityos-lab:mainfrom
perlowja:fix/kbd-backlight-scale-marks
Open

perlowja wants to merge 1 commit into
singularityos-lab:mainfrom
perlowja:fix/kbd-backlight-scale-marks

Conversation

@perlowja

@perlowja perlowja commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The keyboard-backlight brightness slider in SystemView created one GtkScale mark per raw hardware brightness level. On boards with a high-resolution backlight controller (Apple T2 reports max_brightness=14660), that's 14,661 marks, which made GTK compute a ~14,662px minimum widget width.
  • That propagated to a ~14,794px sidebar width, and at 2x HiDPI scale the compositor attempted a 29588x1406px EGL surface -- past Mesa's max texture size. The allocation failed, leaving Mesa's Wayland EGL back-buffer image null, and dri2_query_image_common() crashed dereferencing it.
  • Scope: bound the number of decorative tick marks to a small constant (10), keeping all 14,660 real brightness increments via set_increments() -- only the number of drawn marks changes, not slider precision or behavior.
  • Blast radius: system_view.vala's keyboard-backlight slider only; no other sidebar widgets touched.

Validation Evidence

Root-caused from real coredumps on a MacBookPro16,1 (T2, AMD Navi14) running this shell:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  dri2_query_image_common (image=0x0, attrib=8196 [__DRI_IMAGE_ATTRIB_WIDTH], ...)
    at ../src/gallium/frontends/dri/dri2.c:1046

Six independent coredumps all showed the identical 29588x1406 EGL buffer request. Confirmed the keyboard-backlight slider as the source by reading this file's mark-generation loop against the real hardware's reported max_brightness=14660.

Built and installed the patched binary on the same real hardware:

  • Ran across 2 full compositor/login restarts.
  • Opened the sidebar (activating the keyboard-backlight slider) 12 times per session.
  • Zero new coredumps in either session; the shell process stayed alive throughout.

This is a genuine upstream Mesa robustness gap too (missing NULL check after a failed EGL Wayland back-buffer allocation) -- already tracked as Mesa issue #15913 with an open, unmerged fix (MR !44569). This PR avoids generating the invalid surface in the first place, which is the fix within this repo's control; the Mesa MR remains valuable defense-in-depth regardless.

Security & Privacy

No security or privacy impact -- pure UI layout bound, no new data handling.

Compatibility

No behavior change for normal (low-resolution) brightness controllers. Preserves exact slider precision/increments for high-resolution controllers; only the number of visual tick marks is reduced.

Rollback

Revert this commit; no migrations or state changes involved.

AI assistance: disclosed

High-resolution LED drivers can expose thousands of raw brightness
levels. Creating one GtkScale mark per raw level makes the sidebar
request a surface wider than GPU limits.

Assisted-by: Claude Code:claude-sonnet-5
AI-Scope: Diagnosed an oversized sidebar surface from crash analysis on real T2 hardware and bounded keyboard-backlight tick marks while preserving all real brightness increments.
@perlowja
perlowja force-pushed the fix/kbd-backlight-scale-marks branch from a95bba6 to 1e7b0c1 Compare September 21, 2026 00:29
@perlowja

Copy link
Copy Markdown
Contributor Author

@mirkobrombin bumping this one too - it's a real crash fix (keyboard-backlight GtkScale allocating a 29588x1406 EGL surface on high-resolution backlight controllers), metal-confirmed fixed.

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.

1 participant