[PR #2107] [MERGED] Resource packs: keep the window surface across a reload (crash on Wayland/RADV) #4011

Closed
opened 2026-11-03 04:14:01 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2107
Author: @kacpherek
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @ludovic111

Base: main ← Head: fix/1959-pack-reload-surface


📝 Commits (2)

  • 858eeba Resource packs: hand the window surface to the reloaded renderer instead of creating a new one
  • 06a45d8 Merge main into fix/1959-pack-reload-surface

📊 Changes

2 files changed (+34 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/game/packs.rs (+1 -1)
📝 crates/horizon-client/src/gfx.rs (+33 -6)

📄 Description

What and why

Applying resource packs crashed the game on Linux with Wayland and an AMD GPU (RADV). From the reporter's log:

get_physical_device_surface_capabilities: ERROR_SURFACE_LOST_KHR
...
In Surface::configure
  Surface does not support the adapter's queue family
  at Renderer::recreate_surface
  at Game::reload_selected_packs

reload_selected_packs builds the new renderer on the same device, but it dropped the window surface first (release_surface) and the new renderer created a fresh one for the window. On this driver the fresh surface came back lost, so get_default_config found no configuration and the new renderer failed. The fallback then created yet another surface for the old renderer, and configuring that one failed validation, which is fatal.

The renderer keeps the same instance, adapter and device across the reload, so it can keep the same surface. Now release_surface sets the surface aside (spare_surface), the replacing renderer takes it instead of creating one, and recreate_surface reuses it too when a replacement fails. A surface is only created when there is none to reuse (startup, or a surface the driver reported lost while drawing). The same handover now also covers the two startup swaps (loading screen to menu, menu to game), which went through the same release-and-create.

I couldn't reproduce this here (macOS): the cause is read from the log and the code.

Fixes #1959.

Vanilla reference

Horizon-only: vanilla's window and swapchain live for the whole session, and a resource reload never touches them (Minecraft.reloadResourcePacks only reloads textures and shaders).

Self-check

cargo check -p horizon-client passes.


🔄 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/2107 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/1959-pack-reload-surface` --- ### 📝 Commits (2) - [`858eeba`](https://github.com/horizon-rust/horizon/commit/858eeba1b850716e5779e1bea6c47d7908e713ad) Resource packs: hand the window surface to the reloaded renderer instead of creating a new one - [`06a45d8`](https://github.com/horizon-rust/horizon/commit/06a45d86a19748abaf9f7df656e2f7f30d4277d7) Merge main into fix/1959-pack-reload-surface ### 📊 Changes **2 files changed** (+34 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/packs.rs` (+1 -1) 📝 `crates/horizon-client/src/gfx.rs` (+33 -6) </details> ### 📄 Description ## What and why Applying resource packs crashed the game on Linux with Wayland and an AMD GPU (RADV). From the reporter's log: ``` get_physical_device_surface_capabilities: ERROR_SURFACE_LOST_KHR ... In Surface::configure Surface does not support the adapter's queue family at Renderer::recreate_surface at Game::reload_selected_packs ``` `reload_selected_packs` builds the new renderer on the same device, but it dropped the window surface first (`release_surface`) and the new renderer created a fresh one for the window. On this driver the fresh surface came back lost, so `get_default_config` found no configuration and the new renderer failed. The fallback then created yet another surface for the old renderer, and configuring that one failed validation, which is fatal. The renderer keeps the same instance, adapter and device across the reload, so it can keep the same surface. Now `release_surface` sets the surface aside (`spare_surface`), the replacing renderer takes it instead of creating one, and `recreate_surface` reuses it too when a replacement fails. A surface is only created when there is none to reuse (startup, or a surface the driver reported lost while drawing). The same handover now also covers the two startup swaps (loading screen to menu, menu to game), which went through the same release-and-create. I couldn't reproduce this here (macOS): the cause is read from the log and the code. Fixes #1959. ## Vanilla reference Horizon-only: vanilla's window and swapchain live for the whole session, and a resource reload never touches them (`Minecraft.reloadResourcePacks` only reloads textures and shaders). ## Self-check `cargo check -p horizon-client` passes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:14:01 +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#4011
No description provided.