[Metal][Mac] FMetalViewport::PresentDrawLayers retains LocalDrawable and never releases it: one CAMetalDrawable leaked per presented frame

Summary

In Engine/Source/Runtime/Apple/MetalRHI/Private/MetalViewport.cpp, FMetalViewport::PresentDrawLayers (line 1001), the path without WITH_MULTI_VIEW_SLATE_WINDOW_SUPPORT (the normal Mac path) does:

CA::MetalDrawable* LocalDrawable = GetDrawable(EMetalViewportAccessDisplayLink);
LocalDrawable->retain();      // line 1024

CommittedDrawables.Add(GetCommittedDrawableToPresent(std::numeric_limits<int32>::min(), CommandBuffer, bLayersToDraw));

LocalDrawable is not used after this and is never released. The command buffer completion handler releases only the drawables in CommittedDrawables (each retained once inside GetCommittedDrawableToPresent, line 954, which is balanced), so the extra retain at line 1024 is never balanced.

Engine: 5.8.3 launcher build (CL 58210709). Suggested fix: remove the LocalDrawable = GetDrawable(…); LocalDrawable->retain(); pair at lines 1023-1024 (the drawable is already retained in GetCommittedDrawableToPresent), or release it after GetCommittedDrawableToPresent.

What Type of Bug are you experiencing?

Rendering (Graphics / Niagara)

Steps to Reproduce

  1. Package any project for Mac (Development or Shipping) and run it.
  2. Take heap PID snapshots a few minutes apart and count CAMetalDrawable instances.

Expected Result

The number of live CAMetalDrawable objects stays at the swap-chain size (about 3).

Observed Result

The live CAMetalDrawable count grows by one per frame: about 1,800 per minute at 30 fps, about 0.4 MB per minute, without limit. Seen on an M3 MacBook Air (16 GB), macOS 26.6.2, UE 5.8.3 packaged Development build.

Related report (separate leak in the same RHI): FMetalDescriptorHeap leaking its allocator on every descriptor flush, [Metal][Mac] FMetalDescriptorHeap destructor is empty: every FlushPendingDescriptorUpdates leaks an FRHIHeapDescriptorAllocator + FMetalRHIBuffer (steady memory growth on METAL_SM6)

Affects Versions

5.8

Platform(s)

Mac