Video Player crash on Mac with targeted RHI SF_METAL_SM6

Playing a video on Mac with RHI SF_METAL_SM6 crashes the GPU.

It appears that these 2 textures `Y_SRV` and `UV_SRV` found around ln260 + ln290 of `Engine/Plugins/Media/ElectraUtil/Source/ElectraSamples/Private/ElectraTextureSampleAVF.cpp`, end up null on the GPU or have its texture data deleted before the GPU is done using them. Found in FElectraMediaTexConvApple::ConvertTexture(…).

This same video and setup plays without issue on Windows with D3D12 and SM6.

Log Info:

[UE] Fatal error: [File:./Runtime/Apple/MetalRHI/Private/MetalCommandList.cpp] [Line: 99] Command Buffer MediaTextureResource Failed with PageFault Error! Error Domain: MTLCommandBufferErrorDomain Code: 3 Description Caused GPU Address Fault Error (0000000b:kIOGPUCommandBufferCallbackErrorPageFault) Unknown Unknown [UE] [2025.07.04-10.06.12:551][669]LogMetal: Warning: Metal Command Buffer Failure: PageFault, <MTLDebugCommandBuffer: 0x1372a7800> -> <AGXG14XFamilyCommandBuffer: 0x58a3c6560> label = MediaTextureResource device = <AGXG14DDevice: 0x139875800> name = Apple M2 Ultra commandQueue = <AGXG14XFamilyCommandQueue: 0x13709b400> label = <none> device = <AGXG14DDevice: 0x139875800> name = Apple M2 Ultra retainedReferences = 0

Note: didn’t supply repo project as the link for `[Creating and packaging a repro project for [Content removed] is invalid. At least the repo is a simple setup.

Steps to Reproduce

  • Build + run editor (i’m using XCode 16.2)
  • Create a fresh project from the TP_ThirdPerson template (though any template should cause the issue).
  • Target the SF_METAL_SM6 RHI

[/Script/MacTargetPlatform.MacTargetSettings] +TargetedRHIs=SF_METAL_SM6 ; changed from SF_METAL_SM5* Enable the Electra Player, Electra Player Utilities, and Electra Codecs, plugins.

  • Open editor and create a Media Player + Media player source (can be a local or stream source). I used a mp4 h264 encoded Video 1920x1080 resolution 4min duration.
  • Play the video and crash

Thanks Sean,

I will investigate this and get back to you.

Carl

Hi Sean,

Sorry for the delay, could you try this change?

https://github.com/EpicGames/UnrealEngine/commit/b8f3ef6acd98a5f11ec1ee902c5fe3070b1a7813

Thanks,

Carl

Thanks Carl.

It appears that 5.5.4 is already using `SafeReleaseMetalObject` to release the texture cache. Though reverting that to use to enqueue the RHI cmd, prevents the crash, though results in a solid colour video / no content rendered.

Ok thanks,

We re-wrote the code around that in 5.6, but it’s not applicable to 5.5.4 without other changes.

Not sure if it will help, but wondering if it will narrow it down, could you add the following

In FMetalSurface::~FMetalSurface() inside if(ImageSurfaceRef):

FMetalDynamicRHI::Get().DeferredDelete([ImageSurfaceRef]() {

CFRelease(ImageSurfaceRef);

});

I didn’t write the original code for this and I don’t know if that will make any difference over:

CFArrayRef Temp = CFArrayCreate(kCFAllocatorSystemDefault, &ImageSurfaceRef, 1, &kCFTypeArrayCallBacks);

FMetalDynamicRHI::Get().DeferredDelete((__bridge NS::Array*)Temp);

Thanks, this resulted in a similar behaviour.

No crash, but nothing rendered.

We did manage to get it rendering by using a RDG pass in `FElectraMediaTexConvApple::ConvertTexture` that will do a copy + convert of the texture data. Similar to what it was doing previously with the RHICmdList.

Not the best solution, but it got us working.