MTLCaptureManager.sharedCaptureManager generates corrupted .gputrace files (0KB, invalid internal structure)

Hello,

I am experiencing an issue with programmatically capturing a GPU trace using MTLCaptureManager. The .gputrace file that is generated appears to be corrupted, and I'm looking for guidance or a solution.

Description of the Problem:

I am using MTLCaptureManager.sharedCaptureManager to capture a Metal frame and save it to disk.

The generated .gputrace file is consistently reported as 0 bytes in size by the file system.

Crucially, when I compress this 0-byte .gputrace file into a .zip archive, the resulting archive contains the full, expected data. After unzipping, the file can be opened and viewed correctly in Xcode.

However,When inspecting the file's contents using NSFileManager in Objective-C (treating it as a directory), the internal structure is different from a .gputrace file captured directly from Xcode's Metal Debugger.

capture in xcode capture in file

Finally,When capturing multiple frames programmatically, the first captured frame contains valid buffer data. However, for subsequent frames (starting from the second frame), the corresponding buffer contents are all zero-filled.

Frame 1: All MTLBuffer data is correctly captured and populated.

Frame 2 and onward: The same MTLBuffer objects are present in the trace, but their contents are entirely 0 (i.e., the data is not captured or is corrupted).

In this case, the on-screen display is normal, but the captured frame is incorrect. The frame captured directly in Xcode is also correct. Only the frame captured to a file is abnormal.

Hello,

This is odd behavior so let's start with a bug report. Please attach a .gputrace.

To investigate further, it will help to have a sample project that reproduces the issue so please attach one if possible.

MTLCaptureManager.sharedCaptureManager generates corrupted .gputrace files (0KB, invalid internal structure)
 
 
Q