Skip to content

fix(modrinth-sandbox): allow macOS Metal shader compiler cache access - #8561

Open
pparanoiidd wants to merge 1 commit into
modrinth:mainfrom
pparanoiidd:fix/macos-metal-cache-sandbox
Open

pparanoiidd wants to merge 1 commit into
modrinth:mainfrom
pparanoiidd:fix/macos-metal-cache-sandbox

Conversation

@pparanoiidd

Copy link
Copy Markdown

Fixes #8556

Allows sandboxed JVM processes on macOS to use Apple's Metal shader compiler (MTLCompilerService) cache under DARWIN_USER_CACHE_DIR. This fixes MTLLibraryErrorDomain / sandbox_extension_issue_file (Operation not permitted) failures in Metal-backed mods like mcopt, and restores persistent Metal shader caching for vanilla Minecraft 26.3's Vulkan (MoltenVK) backend.

Changes (packages/modrinth-sandbox/src/backend/macos/mod.rs)

Single Seatbelt rule addition inside if command.is_jvm:

  • Metal cache access: Allows file-read* and file-write* on <cache_root>(/<bundle-id>)?/com.apple.(metal|metalfe|gpuarchiver)(/.*)? (covers both bundled JDKs like com.azul.zulu.java and unbundled JDKs).
  • Clean-machine init: Allows file-write-create (vnode-type DIRECTORY only) on <cache_root>/<bundle-id> so Metal.framework can create the parent folder on a cold cache.
  • Scoped XPC extension: Allows file-issue-extension on those Metal cache paths, restricted strictly to com.apple.app-sandbox.read and com.apple.app-sandbox.read-write for MTLCompilerService.
  • Minimal surface: Exposes no user data or general app caches; file-link, file-map-executable, process-exec, and non-Metal writes remain denied.

Testing

Verified on macOS (Apple M3 Pro, Azul Zulu Java 25) via sandbox-exec with the rendered profile from mod.rs and a freshly cleared DARWIN_USER_CACHE_DIR/com.azul.zulu.java before each run:

  • Vanilla MC 26.3 Vulkan (MoltenVK 1.4.2) cold-cache A/B:
    • Unpatched: 434 file-write-create Seatbelt denials in ~9s; cache directory never created (shaders forced uncached in memory).
    • Patched: 0 java denials; com.apple.metal, com.apple.metalfe, and com.apple.gpuarchiver created and populated cleanly.
  • MC 26.3 + Fabric + mcopt-metal 0.3.0-alpha.2: Initialized Metal 3 (mcopt) cleanly and wrote com.apple.metalfe/.../monolithic_metal.pcm with 0 java denials.
  • Swift Metal helpers: Verified runtime makeLibrary(source:options:) compilation for both bundled and unbundled binaries, and confirmed non-Metal writes under DARWIN_USER_CACHE_DIR remain blocked.

@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Pull request changelog

App

Added

Changed

Deprecated

Removed

Fixed

Security

Website

Added

Changed

Deprecated

Removed

Fixed

Security

Hosting

Added

Changed

Deprecated

Removed

Fixed

Security

@mergify

mergify Bot commented Dec 5, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request once it meets the queue conditions

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

macOS sandbox blocks Metal shader compilation

1 participant