[PR #3998] [MERGED] Players and heads keep their skins on busy servers #5346

Closed
opened 2026-11-03 05:11:57 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3998
Author: @d3grando
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: fix-3829


📝 Commits (1)

  • 42ff9e6 Players and heads keep their skins on busy servers

📊 Changes

7 files changed (+242 additions, -54 deletions)

View changed files

📝 crates/horizon-client-render/src/hud.rs (+3 -3)
📝 crates/horizon-client-render/src/skins.rs (+135 -1)
📝 crates/horizon-client/src/game.rs (+2 -2)
📝 crates/horizon-client/src/game/block_entity_anims.rs (+1 -0)
📝 crates/horizon-client/src/game/remote.rs (+76 -41)
📝 crates/horizon-client/src/game/scoreboard.rs (+21 -6)
📝 crates/horizon-client/src/game/spectator.rs (+4 -1)

📄 Description

🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando personally.

What and why

On a busy server, players kept vanishing and coming back. Their name tags stayed in the air while they were gone, and player heads, including the ones in the inventory, flickered between their skin and the default one.

Downloaded skins and capes share 128 atlas slots (hud::SKIN_SLOTS). Once more skins were in use than there were slots, the slots changed hands every frame:

  • update_remote_skins asked for a slot for every player-list entry's skin each frame (again_skin on all of skin_textures), not only for the players being drawn. A server with more than 128 listed skins was enough, even with only a few players in view.
  • store_skin always pushed out the least recently shown skin, even one drawn in the previous frame. That skin then asked again (Downloader::again), was stored the next frame, and pushed out another one.
  • While its skin was out of the atlas, a player's mob.skin named a texture that wasn't there, so the model didn't draw for that frame but its name tag did. Heads (head_skin, skull blocks) never counted as shown, so they were pushed out first and fell back to the default head.

The fix:

  • skins::SkinSlots manages the slots. A new skin takes a free slot, or else the slot of the least recently drawn skin, but never one drawn in the last frame. If every slot was drawn, the new skin waits and its player keeps the default skin. Nothing gets pushed out while it is still in use.
  • Downloader::drawn / take_drawn record what each frame draws: the level's players and their capes, the local player, mannequins, the faces the player list (the 80 it shows) and the spectator menu show, skull blocks, item heads and text heads.
  • Only drawn skins ask for a slot. A skin that isn't in the atlas yet draws the profile's default skin instead of a missing texture, as vanilla's lookup does before the texture loads.

Fixes #3829. #3807 (players disappearing and reappearing on a server) looks like the same cause.

Vanilla keeps a texture per skin and never evicts one. This keeps the shared slots but stops them from changing hands. If more than 128 different skins are drawn at once, the extra ones show the default skin and stay that way; they no longer flicker. Before, every skin flickered in turn.

Overlaps: #3960 turns the skin slot table into a shared AtlasSlots type and #3792 edits update_remote_skins, so whichever lands second needs a small rebase. Neither changes which skins keep their slots.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

  • SkinManager.TextureCache.getOrLoad / registerTexture: one texture per skin hash, kept in a map and never evicted (checked with javap on the 26.3 client jar).
  • SkinManager.createLookup: CompletableFuture.getNow(DefaultPlayerSkin.get(profile)), so a player is drawn with the default skin until its texture is ready, never without one.
  • PlayerTabOverlay.getPlayerInfos: at most 80 entries (tab_list::sorted_players), so those are the only faces the list draws.

No parity harness covers skin textures. The unit test skins::tests::skins_drawn_last_frame_keep_their_slots checks the slot rule.

Self-check

Run on Windows 11. tools/pr_ready.py doesn't run on Windows, so the steps were run by hand:

  • cargo fmt --all -- --check: clean
  • cargo clippy -p horizon-client-render --all-targets -- -D warnings: clean
  • cargo clippy -p horizon-client --all-targets -- -D warnings: clean
  • cargo test -p horizon-client-render --lib -- skins:: hud:: tab_list::: 29 passed
  • cargo test -p horizon-client --lib -- skin mannequin tab_list spectator: 3 passed
  • The new test skins_drawn_last_frame_keep_their_slots runs six skins drawn every frame through four slots, the way draw_tab_list and update_remote_skins drive them:
    • With the old eviction rule restored in SkinSlots::place (always the least recently shown slot): FAILED, frame 2 uploaded again (left: 2, right: 0).
    • With the fix: ok.
  • In game, single player (server thread), fast build, 160 player-head blocks with 160 different skins (unsigned textures properties, images in the skin cache), all in view:
    • Before: about 30 heads showed the default head in each screenshot, a different set each time; 56–57 heads changed between consecutive screenshots.
    • After: 32 heads (160 − 128) show the default head and the same ones stay that way; 0 changed between screenshots.
    • After removing 48 of the heads, all of the remaining 112 showed their own skins.
  • Not tested in game: a real server with more than 128 online players. The player-list and level-player path needs signed skins from online accounts; it uses the same SkinSlots rule the heads test above exercises.

Screenshots

before: 160 player heads, a different ~30 drawn with the default head in each frame

after: 112 heads, every one keeps its skin

Before: in a 16×10 grid of player heads seen from above, a different set of about 30 heads shows the default (brown hair) head in each frame, so the grid flickers.

After: the same 32 heads show the default head steadily and the other 128 keep their skins. With 112 heads, every one shows its skin.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/3998 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3829` --- ### 📝 Commits (1) - [`42ff9e6`](https://github.com/horizon-rust/horizon/commit/42ff9e64825c169364cf3ea98d1a481cdcee733d) Players and heads keep their skins on busy servers ### 📊 Changes **7 files changed** (+242 additions, -54 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/hud.rs` (+3 -3) 📝 `crates/horizon-client-render/src/skins.rs` (+135 -1) 📝 `crates/horizon-client/src/game.rs` (+2 -2) 📝 `crates/horizon-client/src/game/block_entity_anims.rs` (+1 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+76 -41) 📝 `crates/horizon-client/src/game/scoreboard.rs` (+21 -6) 📝 `crates/horizon-client/src/game/spectator.rs` (+4 -1) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando personally. ## What and why On a busy server, players kept vanishing and coming back. Their name tags stayed in the air while they were gone, and player heads, including the ones in the inventory, flickered between their skin and the default one. Downloaded skins and capes share 128 atlas slots (`hud::SKIN_SLOTS`). Once more skins were in use than there were slots, the slots changed hands every frame: - `update_remote_skins` asked for a slot for **every player-list entry's** skin each frame (`again_skin` on all of `skin_textures`), not only for the players being drawn. A server with more than 128 listed skins was enough, even with only a few players in view. - `store_skin` always pushed out the least recently shown skin, even one drawn in the previous frame. That skin then asked again (`Downloader::again`), was stored the next frame, and pushed out another one. - While its skin was out of the atlas, a player's `mob.skin` named a texture that wasn't there, so the model didn't draw for that frame but its name tag did. Heads (`head_skin`, skull blocks) never counted as shown, so they were pushed out first and fell back to the default head. The fix: - `skins::SkinSlots` manages the slots. A new skin takes a free slot, or else the slot of the least recently drawn skin, but never one drawn in the last frame. If every slot was drawn, the new skin waits and its player keeps the default skin. Nothing gets pushed out while it is still in use. - `Downloader::drawn` / `take_drawn` record what each frame draws: the level's players and their capes, the local player, mannequins, the faces the player list (the 80 it shows) and the spectator menu show, skull blocks, item heads and text heads. - Only drawn skins ask for a slot. A skin that isn't in the atlas yet draws the profile's default skin instead of a missing texture, as vanilla's lookup does before the texture loads. Fixes #3829. #3807 (players disappearing and reappearing on a server) looks like the same cause. Vanilla keeps a texture per skin and never evicts one. This keeps the shared slots but stops them from changing hands. If more than 128 different skins are drawn at once, the extra ones show the default skin and stay that way; they no longer flicker. Before, every skin flickered in turn. Overlaps: #3960 turns the skin slot table into a shared `AtlasSlots` type and #3792 edits `update_remote_skins`, so whichever lands second needs a small rebase. Neither changes which skins keep their slots. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [x] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference - `SkinManager.TextureCache.getOrLoad` / `registerTexture`: one texture per skin hash, kept in a map and never evicted (checked with javap on the 26.3 client jar). - `SkinManager.createLookup`: `CompletableFuture.getNow(DefaultPlayerSkin.get(profile))`, so a player is drawn with the default skin until its texture is ready, never without one. - `PlayerTabOverlay.getPlayerInfos`: at most 80 entries (`tab_list::sorted_players`), so those are the only faces the list draws. No parity harness covers skin textures. The unit test `skins::tests::skins_drawn_last_frame_keep_their_slots` checks the slot rule. ## Self-check Run on Windows 11. `tools/pr_ready.py` doesn't run on Windows, so the steps were run by hand: - `cargo fmt --all -- --check`: clean - `cargo clippy -p horizon-client-render --all-targets -- -D warnings`: clean - `cargo clippy -p horizon-client --all-targets -- -D warnings`: clean - `cargo test -p horizon-client-render --lib -- skins:: hud:: tab_list::`: 29 passed - `cargo test -p horizon-client --lib -- skin mannequin tab_list spectator`: 3 passed - The new test `skins_drawn_last_frame_keep_their_slots` runs six skins drawn every frame through four slots, the way `draw_tab_list` and `update_remote_skins` drive them: - With the old eviction rule restored in `SkinSlots::place` (always the least recently shown slot): **FAILED**, `frame 2 uploaded again` (left: 2, right: 0). - With the fix: **ok**. - In game, single player (server thread), `fast` build, 160 player-head blocks with 160 different skins (unsigned `textures` properties, images in the skin cache), all in view: - Before: about 30 heads showed the default head in each screenshot, a different set each time; 56–57 heads changed between consecutive screenshots. - After: 32 heads (160 − 128) show the default head and the same ones stay that way; 0 changed between screenshots. - After removing 48 of the heads, all of the remaining 112 showed their own skins. - Not tested in game: a real server with more than 128 online players. The player-list and level-player path needs signed skins from online accounts; it uses the same `SkinSlots` rule the heads test above exercises. ## Screenshots ![before: 160 player heads, a different ~30 drawn with the default head in each frame](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/3829-1.png) ![after: 112 heads, every one keeps its skin](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/3829-2.png) Before: in a 16×10 grid of player heads seen from above, a different set of about 30 heads shows the default (brown hair) head in each frame, so the grid flickers. After: the same 32 heads show the default head steadily and the other 128 keep their skins. With 112 heads, every one shows its skin. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:11:57 +07:00
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#5346
No description provided.