Summary
On Apple silicon, a packaged open-world game (World Partition, Nanite, Nanite Landscape, Lumen) running full screen at 4K output falls from ~30 ms to 150-300 ms a frame about 2 minutes after a level loads. It also happens soon after a large batch of resources is released and re-created, e.g. rebuilding a vehicle actor. It stays slow for 30-120 s and recovers on its own.
During the slowdown, ProfileGPU shows every pass slowed, including trivial ones: a ~5 ms buffer clear, a 64x64 cloud pass at 3.9 ms, CanvasBatchedElements at 8.8 ms. This is the signature of the GPU faulting memory back in, not of one expensive pass.
Metal’s currentAllocatedSize is only ~7.9 GB against a recommendedMaxWorkingSetSize of 28.7 GB, and system memory is ~45% free. A sample during the stall showed the submission path waiting in AGXCommandBuffer::nextCommandBufferState / IOGPUEventMachine::waitForStamp.
What points at the Metal RHI’s residency
sudo sysctl iogpu.disable_wired_collector=1, macOS’s GPU wired-memory collector off, stops it.- The Metal RHI declares residency per encoder (useResource / useHeaps).
MetalCommandEncoder.cpp,FMetalCommandEncoder::UseResource, line 1584:// TODO: Rework residency caching (current one is broken). It never uses MTLResidencySet. - Fix, verified: add every buffer, texture and heap the device creates to one MTLResidencySet attached to the RHI’s command queues (addResidencySet), with commit plus requestResidency every 0.5 s, and drop allocations once released. That covered 99.6% of the app’s GPU allocations and stopped it in every test drive since: 2 with hardware ray tracing off, 2 with it on. Before the fix it happened on almost every drive.
- A first version without requestResidency, and missing IOSurface-backed textures, made it milder: it recovered in 30-60 s.
- Hardware ray tracing on (r.RayTracing, r.Lumen.HardwareRayTracing) makes it more likely but isn’t required.
- Other factors that raise the odds: higher render resolution, full screen at the panel’s native resolution, and large release/re-create bursts.
What Type of Bug are you experiencing?
Rendering (Graphics / Niagara)
Steps to Reproduce
- On an Apple silicon Mac (macOS 15 or later), package a large World Partition level with Nanite Landscape, Lumen (hardware ray tracing on makes it likelier) and Nanite meshes.
- Run it full screen at 4K output (render scale 75-100%) and drive or fly through the level for 2-5 minutes, or destroy and respawn a large actor a few times.
- Watch
stat unit. The GPU time climbs 5-10x for 30-120 s. RunProfileGPUduring it: every pass is slowed. - Compare with
iogpu.disable_wired_collector=1, or with a residency set as above: it no longer happens.
Expected Result
The RHI keeps its own GPU allocations resident, using MTLResidencySet on macOS 15 or later as Apple recommends, so macOS’s collector doesn’t evict them mid-frame.
Observed Result
Allocations not declared by the current encoders are evicted under the wired collector, and the GPU stalls faulting them back.
Affects Versions
5.8
Platform(s)
Mac
For crash reports, include your callstack
It’s not a crash, so there’s no crash callstack. This is the stalled thread from a spindump taken during the slowdown (28 Nov, 440 samples). Metal’s command-queue submission is blocked in the kernel GPU driver, waiting on an event stamp:
-[_MTLCommandQueue _submitAvailableCommandBuffers] (Metal)
-[IOGPUMetalCommandQueue submitCommandBuffers:count:] (IOGPU)
IOGPUCommandQueueSubmitCommandBuffers (IOGPU)
IOConnectCallMethod (IOKit)
--- kernel ---
IOGPUDeviceUserClient::s_submit_command_buffers (IOGPUFamily)
IOGPUCommandQueue::submit_command_buffers (IOGPUFamily)
IOGPUCommandQueue::submit_command_buffer (IOGPUFamily)
AGXCommandQueue::submitCommandBuffer (AGXG17X)
AGXCommandBuffer::nextCommandBufferState (AGXG17X)
IOGPUEventMachine::finishEvent (IOGPUFamily)
IOGPUEventMachine::waitForStamp (IOGPUFamily) <- 362 of 440 samples
The GPU is mostly idle meanwhile, and the engine’s RHI thread waits on this submission.
Additional Notes
Workaround we use (macOS 15+): at startup, intercept the MTLDevice’s buffer, texture, heap and IOSurface-texture creation and add each allocation to a single MTLResidencySet, attached (addResidencySet) to every MTLCommandQueue the device creates; commit and requestResidency every 0.5 s; remove allocations once the engine has released them.
This covered ~99.6% of the app’s GPU allocations (7.37 of 7.41 GB) and the stall stopped completely, with hardware ray tracing on or off. Happy to share more detail.
Related: Windows/D3D12 forum threads describe GPU page faults in Lumen HWRT from resources not marked in use (residency/lifetime), which looks like the same class of issue on a different RHI.
Also seen in 5.8.4 on Mac (separate issue, reported on the forums as 2845988): FMetalViewport::PresentDrawLayers retains each CAMetalDrawable without releasing it (one leaked drawable per presented frame).
We can test a fix build or provide Metal System Trace captures on request.