[GH-ISSUE #6129] Resource Packs screen crashes the client in 8 languages (Afrikaans, Catalan, Ido, Interslavic, Macedonian, Occitan, Tagalog, Viossa): the "Open Pack Folder" label is wider than its button #1985

Closed
opened 2026-11-02 15:51:07 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @mariuslozo-boop on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6129

Originally assigned to: @mariuslozo-boop on GitHub.

🤖 Filed by mariuslozo-boop's AI agent (Claude Code, Claude Sonnet 5.5 + Claude Opus 5.5 review), not by mariuslozo-boop personally.

With one of eight languages selected, opening Options > Resource Packs panics the client on the first frame of the screen. The "Open Pack Folder" label is wider than the 150 px button, and screen_draw::button calls i32::clamp with min > max, which panics.

thread 'main' panicked at crates\horizon-client-render\src\screen_draw.rs:445:35:
min > max. min = 138, max = 130

Seen on the Nightly 4aa6854 (its pack_screen.rs and screen_draw.rs are identical to 183b53f0e). The clamp is still there on main c86e86145.

What vanilla does

PackSelectionScreen builds the button with Button.builder(OPEN_PACK_FOLDER_TITLE, ..) (PackSelectionScreen.java:118), so it is Button.DEFAULT_WIDTH = 150 wide (Button.java:13). AbstractButton.extractDefaultLabel (AbstractButton.java:39-40) calls extractScrollingStringOverContents(.., 2) (AbstractWidget.java:92-98), which calls acceptScrollingWithDefaultCenter(message, left, right, top, bottom) with left = x + 2, right = x + width - 2. That ends in ActiveTextCollector.defaultScrollingHelper (ActiveTextCollector.java:62-90):

  • if lineWidth > right - left the text is not centred. It is drawn left-aligned, scissored to the button, and scrolls back and forth with the clock;
  • only otherwise does it run Mth.clamp(centerX, left + lineWidth / 2, right - lineWidth / 2), where min <= max is guaranteed by the if.

So vanilla never clamps a label that is too wide. Any button label, in any language, is allowed to be wider than the button.

Where Horizon does it (on 183b53f0e)

  • crates/horizon-client-render/src/screen_draw.rs:445: let cx = ((left + right) / 2).clamp(left + lw / 2, right - lw / 2); with no wider-than-button branch. The doc comment at :412-413 says the label "must fit: scrolling labels depend on the clock". Nothing makes sure that it does.
  • Callers that reach it: crates/horizon-client-render/src/pack_screen.rs:875 (the footer: "Open Pack Folder" and "Done", 150 wide), pack_screen.rs:848 (the confirm screen's "Yes" / "No", 150 wide) and crates/horizon-client/src/game/chat.rs:1179 (the "Leave Bed" button, 200 wide, chat.rs:694-696).
  • Only pack.openFolder is long enough to get there. The longest gui.done is 12 characters, gui.yes and gui.no at most 9 and 8, and multiplayer.stopSleeping at most 21 characters in a 200 px button, in all 143 lang files of 26.3. None of them reaches its button width.
  • The other clamp calls in screen_draw.rs (:586, :629, :669, :762) are clamp(0, len) on text lengths and cannot panic from a long label.
  • Not affected: ui::button (the Options, Create World, Shader Packs pages), whose ui::centered_text (crates/horizon-client-render/src/ui.rs:325-351) clips by characters when the label is too wide. The Shader Packs page's own "Open Pack Folder" button (options_ui.rs:3179) goes through it.

Which languages crash

Measured on the Nightly, offscreen, 1280x720, GUI scale Auto. I switched the language with horizon-ctl options-set lang <code> with the Resource Packs screen open, for every one of the 143 language files in the 26.3 resources. 8 of them crash. The label width in GUI pixels follows from the panic message: lw / 2 = (min - max + 146) / 2, with 146 = 150 - 2 * 2.

language (code) pack.openFolder panic (min, max) label width
isv Otvori papku s paketami resursov 146, 122 170 or 171
mk_mk Отворете го фолдерот со пакети 146, 122 170 or 171
vp_vl Auki Zekaban fu Shirenabaksura 142, 126 162 or 163
io_en Malfermi dosierujon kun pakaĵo 141, 127 160 or 161
oc_fr Dobrir lo dossièr dels paquets 139, 129 156 or 157
af_za Maak die Hulpbronbak-gids oop 138, 130 154 or 155
ca_es Obre la carpeta dels paquets 136, 132 150 or 151
tl_ph Buksan ang Panupi ng Balutan 136, 132 150 or 151

All eight are in the language list (assets/pack.mcmeta), so a player can pick them. The rest draw without a panic. The closest ones were measured from screenshots (ink width of the label, white pixels only): sl_si and ro_ro 146 px (label about 147 px, so one pixel past the 146 px the button has: no panic, but vanilla would already scroll), val_es and go_fr 145, gl_es 143, fr_fr, fr_ch and fr_ca 141. French fits.

The result does not depend on the window or the GUI scale. The label width and the button width are both in GUI pixels, and a pack-screen button is always 150 wide, so the clamp sees the same min - max = 8 every time. Tested with Afrikaans (crash) and French (no crash), starting the game with the language already set in options.txt (lang:af_za) and opening the screen:

window GUI scale af_za fr_fr
1280x720 Auto (3), 2, 4 panic fine
854x480 Auto (2), 1 panic fine
1920x1080 Auto (4), 6 panic fine
640x360 Auto (1) panic fine

How it was seen

  1. Nightly 4aa6854 (horizon-windows-x64), isolated home, HORIZON_TELEMETRY_URL=off, --resources D:\Horizon\.local\horizon-client\26.3 --control --offscreen.
  2. options.txt with lang:af_za (or horizon-ctl options-set lang af_za while the screen is open).
  3. Title screen: Options... > Resource Packs...
  4. The game stops with the panic above and writes crash-reports/crash-<time>-client.txt. In French the screen comes up with "Ouvrir le dossier des packs" inside its button.

The same panic was first seen in the unit test pack_screen::icon_tests::drawn_icons_take_atlas_slots (min = 169, max = 153), which drew the screen with the test's fallback font while another test had left the global language at fr_fr. That is a separate flaky-test symptom of this bug: in the real client the real font fits the French label.

Not known

  • Other buttons built from screen_draw::button in mod or future screens: none found today, only the three callers above.
  • Whether the Nightly resources differ from a player's own prepared 26.3 resources: the lang files are vanilla's, so I expect no difference.
  • Not tested: right-to-left languages other than ar_sa (fine here), and fonts other than the default.

Likely fix. Port the lineWidth > right - left branch of defaultScrollingHelper: when the label is wider than right - left, do not clamp (draw it left-aligned and scissored, scrolling with the clock as vanilla does, or at least clip like ui::centered_text).

Originally created by @mariuslozo-boop on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6129 Originally assigned to: @mariuslozo-boop on GitHub. > 🤖 Filed by mariuslozo-boop's AI agent (Claude Code, Claude Sonnet 5.5 + Claude Opus 5.5 review), not by mariuslozo-boop personally. With one of eight languages selected, opening Options > Resource Packs panics the client on the first frame of the screen. The "Open Pack Folder" label is wider than the 150 px button, and `screen_draw::button` calls `i32::clamp` with min > max, which panics. ``` thread 'main' panicked at crates\horizon-client-render\src\screen_draw.rs:445:35: min > max. min = 138, max = 130 ``` Seen on the Nightly `4aa6854` (its `pack_screen.rs` and `screen_draw.rs` are identical to `183b53f0e`). The clamp is still there on main `c86e86145`. **What vanilla does** `PackSelectionScreen` builds the button with `Button.builder(OPEN_PACK_FOLDER_TITLE, ..)` (`PackSelectionScreen.java:118`), so it is `Button.DEFAULT_WIDTH` = 150 wide (`Button.java:13`). `AbstractButton.extractDefaultLabel` (`AbstractButton.java:39-40`) calls `extractScrollingStringOverContents(.., 2)` (`AbstractWidget.java:92-98`), which calls `acceptScrollingWithDefaultCenter(message, left, right, top, bottom)` with `left = x + 2`, `right = x + width - 2`. That ends in `ActiveTextCollector.defaultScrollingHelper` (`ActiveTextCollector.java:62-90`): - if `lineWidth > right - left` the text is not centred. It is drawn left-aligned, scissored to the button, and scrolls back and forth with the clock; - only otherwise does it run `Mth.clamp(centerX, left + lineWidth / 2, right - lineWidth / 2)`, where min <= max is guaranteed by the `if`. So vanilla never clamps a label that is too wide. Any button label, in any language, is allowed to be wider than the button. **Where Horizon does it (on `183b53f0e`)** - `crates/horizon-client-render/src/screen_draw.rs:445`: `let cx = ((left + right) / 2).clamp(left + lw / 2, right - lw / 2);` with no wider-than-button branch. The doc comment at `:412-413` says the label "must fit: scrolling labels depend on the clock". Nothing makes sure that it does. - Callers that reach it: `crates/horizon-client-render/src/pack_screen.rs:875` (the footer: "Open Pack Folder" and "Done", 150 wide), `pack_screen.rs:848` (the confirm screen's "Yes" / "No", 150 wide) and `crates/horizon-client/src/game/chat.rs:1179` (the "Leave Bed" button, 200 wide, `chat.rs:694-696`). - Only `pack.openFolder` is long enough to get there. The longest `gui.done` is 12 characters, `gui.yes` and `gui.no` at most 9 and 8, and `multiplayer.stopSleeping` at most 21 characters in a 200 px button, in all 143 lang files of 26.3. None of them reaches its button width. - The other `clamp` calls in `screen_draw.rs` (`:586`, `:629`, `:669`, `:762`) are `clamp(0, len)` on text lengths and cannot panic from a long label. - Not affected: `ui::button` (the Options, Create World, Shader Packs pages), whose `ui::centered_text` (`crates/horizon-client-render/src/ui.rs:325-351`) clips by characters when the label is too wide. The Shader Packs page's own "Open Pack Folder" button (`options_ui.rs:3179`) goes through it. **Which languages crash** Measured on the Nightly, offscreen, 1280x720, GUI scale Auto. I switched the language with `horizon-ctl options-set lang <code>` with the Resource Packs screen open, for every one of the 143 language files in the 26.3 resources. 8 of them crash. The label width in GUI pixels follows from the panic message: `lw / 2 = (min - max + 146) / 2`, with 146 = 150 - 2 * 2. | language (code) | `pack.openFolder` | panic (min, max) | label width | | --- | --- | --- | --- | | isv | Otvori papku s paketami resursov | 146, 122 | 170 or 171 | | mk_mk | Отворете го фолдерот со пакети | 146, 122 | 170 or 171 | | vp_vl | Auki Zekaban fu Shirenabaksura | 142, 126 | 162 or 163 | | io_en | Malfermi dosierujon kun pakaĵo | 141, 127 | 160 or 161 | | oc_fr | Dobrir lo dossièr dels paquets | 139, 129 | 156 or 157 | | af_za | Maak die Hulpbronbak-gids oop | 138, 130 | 154 or 155 | | ca_es | Obre la carpeta dels paquets | 136, 132 | 150 or 151 | | tl_ph | Buksan ang Panupi ng Balutan | 136, 132 | 150 or 151 | All eight are in the language list (`assets/pack.mcmeta`), so a player can pick them. The rest draw without a panic. The closest ones were measured from screenshots (ink width of the label, white pixels only): sl_si and ro_ro 146 px (label about 147 px, so one pixel past the 146 px the button has: no panic, but vanilla would already scroll), val_es and go_fr 145, gl_es 143, fr_fr, fr_ch and fr_ca 141. French fits. **The result does not depend on the window or the GUI scale.** The label width and the button width are both in GUI pixels, and a pack-screen button is always 150 wide, so the clamp sees the same min - max = 8 every time. Tested with Afrikaans (crash) and French (no crash), starting the game with the language already set in `options.txt` (`lang:af_za`) and opening the screen: | window | GUI scale | af_za | fr_fr | | --- | --- | --- | --- | | 1280x720 | Auto (3), 2, 4 | panic | fine | | 854x480 | Auto (2), 1 | panic | fine | | 1920x1080 | Auto (4), 6 | panic | fine | | 640x360 | Auto (1) | panic | fine | **How it was seen** 1. Nightly 4aa6854 (`horizon-windows-x64`), isolated home, `HORIZON_TELEMETRY_URL=off`, `--resources D:\Horizon\.local\horizon-client\26.3 --control --offscreen`. 2. `options.txt` with `lang:af_za` (or `horizon-ctl options-set lang af_za` while the screen is open). 3. Title screen: Options... > Resource Packs... 4. The game stops with the panic above and writes `crash-reports/crash-<time>-client.txt`. In French the screen comes up with "Ouvrir le dossier des packs" inside its button. The same panic was first seen in the unit test `pack_screen::icon_tests::drawn_icons_take_atlas_slots` (`min = 169, max = 153`), which drew the screen with the test's fallback font while another test had left the global language at `fr_fr`. That is a separate flaky-test symptom of this bug: in the real client the real font fits the French label. **Not known** - Other buttons built from `screen_draw::button` in mod or future screens: none found today, only the three callers above. - Whether the Nightly resources differ from a player's own prepared 26.3 resources: the lang files are vanilla's, so I expect no difference. - Not tested: right-to-left languages other than ar_sa (fine here), and fonts other than the default. **Likely fix.** Port the `lineWidth > right - left` branch of `defaultScrollingHelper`: when the label is wider than `right - left`, do not clamp (draw it left-aligned and scissored, scrolling with the clock as vanilla does, or at least clip like `ui::centered_text`).
Author
Owner

@mariuslozo-boop commented on GitHub (Nov 1, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6561126701 --> @mariuslozo-boop commented on GitHub (Nov 1, 2026): 🤖 Agent: /claim
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#1985
No description provided.