[5.8][Mac] Metal drawable/IOSurface leak after WindowedFullscreen window is resized below the menu bar

Summary

In a packaged Mac Shipping build (WindowedFullscreen), once the window ends up at 1920x1050 below the menu bar instead of 1920x1080 fullscreen, IOSurfaces leak at about 6-8 per second (~7.5 MB each, ~3 GB/min). The leak continues after the window returns to 1920x1080, until the app is restarted.

What Type of Bug are you experiencing?

Rendering (Graphics / Niagara)

Steps to Reproduce

  1. Package a Mac Shipping build with FullscreenMode = WindowedFullscreen.
  2. Launch it and leave it idle. footprint <pid> | grep IOSurface stays flat.
  3. Press Alt+Enter twice (windowed, then back to fullscreen) and move the mouse around.
  4. The window becomes 1920x1050 at y=30, and the IOSurface count climbs steadily.

Expected Result

The IOSurface count stays flat.

Observed Result

The IOSurface count grows without limit; we saw 38 GB of IOSurfaces after 20 minutes. A stack sample shows the render thread blocked in FMetalViewport::GetDrawableInternal → -[CAMetalLayer nextDrawable] → IOSurfaceCreate.

Suspected cause (MetalViewport.cpp):

  • GetDrawableInternal (~line 727) releases the drawable and calls nextDrawable again on every call when the drawable size != the back-buffer size, so several unpresented drawables are fetched each frame.
  • PresentDrawLayers, single-view branch (~lines 1031-1032): LocalDrawable->retain() is never released on Mac, because it’s only used in the non-Mac presentDrawable path.

Affects Versions

5.8

Platform(s)

Mac

Additional Notes

macOS 27.0, Apple Silicon (M-series), UE 5.8 launcher build, Metal SM6. Shipping builds use WITH_MULTI_VIEW_SLATE_WINDOW_SUPPORT=0, so the single-view PresentDrawLayers branch runs.