Repository navigation
Return Metal renderer creation failures instead of panicking - #16
Merged
chris-addison merged 2 commits intoOct 18, 2026
Merged
chris-addison merged 2 commits into
chris-addison merged 2 commits into
Conversation
Building the Metal renderer compiles the generated MSL with the driver's
runtime compiler and creates one pipeline state per primitive. Some drivers
refuse a step ("Compiler encountered an internal error" on an Intel MacBook
Air), and the renderer panicked with "error building metal library", "error
locating <entry>" or "could not create render pipeline state". A missing
Metal device called std::process::exit(1).
MetalRenderer::new, new_headless and MetalHeadlessRenderer::new now return
Result<_, MetalRendererError>. The error carries the device name, the step
that failed and Metal's own message, and new_renderer passes it to
open_window's Result, so an application can report it and exit. gpui_platform
re-exports the type on macOS for downcast_ref. The headless renderer factory
used by tests keeps panicking, as the WGPU one does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chris-addison
marked this pull request as ready for review
October 18, 2026 15:41
windows_default_renderer_has_no_wgpu_path failed on unity/hub-consolidated itself: it required crates/gpui_windows/Cargo.toml to never mention gpui_wgpu, and window.rs to hold no wgpu path, but the branch carries an optional, non-default `wgpu` feature (the per-window WGPU renderer). The audit now allows gpui_wgpu only as an optional dependency that the `wgpu` feature enables, fails when `default` or any other feature turns it on, and checks that a build without the feature creates the DirectX renderer. Mutation-checked: adding `wgpu` to `default`, or dropping `optional = true`, fails it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A Metal driver that refuses to build the renderer now returns an error from
open_windowinstead of panicking. Found in the native Unity Hub: Sentry issue UNITY-HUB-37DK shows Hub 4.0.0-beta.2 dying at startup on an Intel MacBookAir5,1 (macOS 26.7.2) with "Compiler encountered an internal error".MetalRenderer::newwas infallible. A refused MSL compile panicked with "error building metal library", a missing entry point with "error locating …", a refused pipeline with "could not create render pipeline state", and a missing Metal device calledstd::process::exit(1).new_rendereralready returned aResult, but it could only ever beOk.MetalRenderer::new,new_headlessandMetalHeadlessRenderer::newreturnResult<_, MetalRendererError>. The error carries the device name, the step that failed (for example "compiling the quads shader library") and Metal's own message.new_rendererpasses it up throughopen_window, so an application can report it and exit.gpui_platformre-exports the type on macOS, so callers candowncast_refit without depending ongpui_apple.current_headless_rendererkeeps panicking when Metal fails, the same way the WGPU headless renderer does on the other platforms. It is test and bench support only.No fallback renderer: the macOS
wgpurenderer is a compile-time feature, not a runtime choice, and it runs Naga's MSL through the same driver compiler, so it would most likely fail the same way.Testing
Two new tests in
metal_renderer::testsrun on a real Metal device, like the existing ones (thetest-macCI job runs them):a_shader_library_the_device_refuses_is_an_errorhands the device an invalid source for the quads shader and checks that construction returns an error naming the device, the step and the compiler's text.a_missing_shader_entry_point_is_an_errorchecks the entry-point lookup the same way.Locally on an Apple Silicon Mac:
cargo test -p gpui_ce_apple --libpasses (15 tests), and clippy with-D warningsis clean ongpui_ce_apple,gpui_ce_platformandgpui_ce_macos(all targets).A second commit fixes CI that was already broken on
unity/hub-consolidated:renderer_source_audit::windows_default_renderer_has_no_wgpu_pathfailed on every platform, because it requiredgpui_windows/Cargo.tomlto never mentiongpui_wgpu, while the branch carries an optional, non-defaultwgpufeature for the per-window WGPU renderer. The audit now allowsgpui_wgpuonly as an optional dependency that thewgpufeature enables, fails whendefaultor any other feature turns it on, and checks that a build without the feature creates the DirectX renderer. Addingwgputodefault, or droppingoptional = true, makes it fail again (checked locally).defaultis["gpui/default"]today.This branch is
unity/hub-consolidated(the Hub's current pin,02e408c456) plus these two commits.🤖 Generated with Claude Code