zed-industries/zed · error
internal error: entered unreachable code
Error message
internal error: entered unreachable code
What it means
Metal atlas tile removal dispatches on the atlas texture kind to pick the right texture pool. `AtlasTextureKind::Subpixel` has no corresponding texture list in this atlas implementation, so the code hits an explicit `unreachable!()`. This means a tile with kind Subpixel was handed to an atlas that never allocates Subpixel textures — a caller/atlas mismatch.
Solutions
- Skip tiles of kind Subpixel in the removal path (or route them to the correct atlas) instead of removing them from this atlas.
- Extend the match to handle Subpixel with the correct texture pool if the atlas is supposed to support it.
- Verify where the tile originated; only remove tiles that this atlas instance allocated.
Example fix
// before AtlasTextureKind::Subpixel => unreachable!(), // after AtlasTextureKind::Subpixel => return, // subpixel tiles live in a different atlas
Defensive patterns
Strategy: type-guard
Validate before calling
// before removing, ensure this atlas owns the tile kind
if matches!(tile_texture_kind(&tile), AtlasTextureKind::Subpixel) {
return; // not managed by this atlas
} Type guard
fn is_removable_kind(kind: AtlasTextureKind) -> bool {
matches!(kind, AtlasTextureKind::Monochrome | AtlasTextureKind::Polychrome)
} Prevention
- Only remove tiles that the same atlas instance allocated.
- When adding an AtlasTextureKind variant, update every match in metal_atlas.rs (allocate and remove).
- Keep a single source of truth mapping kinds to texture pools.
When it happens
Trigger: Calling `remove(tile)` on a metal atlas with a tile whose `texture_id.kind` is `AtlasTextureKind::Subpixel`, typically because the tile was allocated by a different atlas/path or a kind was added without updating remove.
Common situations: Sprite/atlas eviction code that removes tiles regardless of kind, or a new AtlasTextureKind variant introduced without extending every match in metal_atlas.rs.
Related errors
- Only tool result should be extracted
- row grapheme cursor
- Too many consecutive GPU errors. Last error
- actions.json not found at
- Adapter (backend= , device= ) is not compatible with the…
AI-assisted analysis of zed-industries/zed@916fc2b8cb (2026-09-19).
Data as JSON: /api/errors/c515caaa30c3e74b.
Report an issue: GitHub.
Appendix: source
Thrown at crates/gpui_apple/src/metal_atlas.rs:69
fn insert(
&mut self,
kind: AtlasTextureKind,
size: Size<DevicePixels>,
bytes: &[u8],
) -> Result<AtlasTile> {
let tile = self.allocate(size, kind).context("failed to allocate")?;
let texture = self.texture(tile.texture_id);
texture.upload(tile.bounds, bytes);
Ok(tile)
}
fn remove(&mut self, tile: AtlasTile) {
let id = tile.texture_id;
let textures = match id.kind {
AtlasTextureKind::Monochrome => &mut self.monochrome_textures,
AtlasTextureKind::Polychrome => &mut self.polychrome_textures,
AtlasTextureKind::Subpixel => unreachable!(),
};
let Some(texture_slot) = textures
.textures
.iter_mut()
.find(|texture| texture.as_ref().is_some_and(|v| v.id == id))
else {
return;
};
if let Some(mut texture) = texture_slot.take() {
texture.allocator.deallocate(tile.tile_id.into());
texture.decrement_ref_count();
if texture.is_unreferenced() {
textures.free_list.push(id.index as usize);
} else {
*texture_slot = Some(texture);
}View on GitHub (pinned to 916fc2b8cb)