I've written a brief guide for profiling WebGPU commands with Xcode's Metal debugger. It's... not exactly easy, but it works! I've got several ideas for how to improve it in the future, too.

Also, if you know Xcode better than me (a very VERY low bar) then I'd be thrilled if you have any suggestions to make this process better!

https://toji.dev/webgpu-profiling/xcode

Profiling WebGPU with Xcode’s Metal Debugger

Brandon Jones - Graphics and XR on the web

Toji.dev

@tojiro yooooo this is going to be very helpful

(I previously had to write a minimal Swift + Metal port of my compute kernel, because I couldn't figure out how to attach to a non-XCode project)

@tojiro If you have control over the application you want to capture, it’s nice to explicitly instrument it with MTLCaptureManager with a file output so you can capture traces during normal execution and open the capture files afterwards. I set up one of my graphics apps so when you launch it in debug mode, it adds a menu item “capture frame” which will save a frame capture to the downloads folder so I don’t have to fiddle with attaching a debugger.
@porglezomp Yeah, I'm investigating exactly that now. Want to see if there's some reasonable common ground with Metal/RenderDoc/PIX so that we can set up some developer-only utils to easily spit out a capture file wherever.
@tojiro @porglezomp
Thanks for the blog post! Was quite helpful for my endeavors to figure out how to capture WebGL2 workloads using Metal frame debugger through ANGLE. There is already some MTLCaptureManager support built-in and it’s relatively easy to patch ANGLE for Chrome Canary. But chrome GPU crashes right after a capture leading to empty or incomplete gputrace data.
@tojiro Now do the same with Renderdoc.

@tojiro I think you may be able to automate the process of looking up the PID and setting it in Xcode after launch (why does attaching process process name not work btw?)
I’d try:
- write a wrapper script that launches chrome, looks up the PID, writes it somewhere
- select that script instead of the executable in the scheme
- check if the PID is persisted in the scheme. If so, have the script update it directly
- otherwise, put the PID into clipboard using pbcopy

You can also define custom keyboard shortcuts for “attach…” menu entry to speed that part up

@tojiro @joe I guess I get to be the annoying person who points out that it’s “Xcode”
@saagar @joe Oh, ha! I had no idea. I can fix that in the article. 😁
@saagar @tojiro @joe I was going through the thread just to see if someone pointed this out 🫢 You did it in a nice way.