Skip to content

fix(metal): read resolved counter samples with bytes, not mutableBytes - #135

Open
lastlink wants to merge 1 commit into
renderbag:mainfrom
lastlink:fix/metal-query-results-bytes
Open

lastlink wants to merge 1 commit into
renderbag:mainfrom
lastlink:fix/metal-query-results-bytes

Conversation

@lastlink

@lastlink lastlink commented Nov 7, 2026 •

Copy link
Copy Markdown

Fixes a crash on Intel Macs: the Metal backend aborts on the first frames whenever timestamp queries are used.

resolveCounterRange: returns an immutable NSData. On an Intel UHD 630 (macOS 15.8) it is an NSConcreteData, which has no mutableBytes, so MetalQueryPool::queryResults() aborts with an unrecognized selector:

-[NSObject(NSObject) doesNotRecognizeSelector:]
plume::MetalQueryPool::queryResults()
RT64::WorkloadQueue::threadRenderFrame(...)
RT64::WorkloadQueue::renderThreadLoop()

A small Metal program on the same Mac confirmed the resolved data is an NSConcreteData that answers bytes but not mutableBytes.

The fix reads it with bytes (metal-cpp's NS::Data has no bytes(), so the selector is sent directly) and returns when there is no data.

resolveCounterRange returns an immutable NSData. On an Intel UHD 630 (macOS 15.8) it is an NSConcreteData, which has no
mutableBytes, so queryResults aborted with an unrecognized selector.
@IsaacMarovitz

Copy link
Copy Markdown
Contributor

It seems this was fixed in metal-cpp at some point as the most update to date version has this.
https://github.com/apple/metal-cpp/blob/main/Foundation/NSData.hpp#L42C34-L42C39

We should update our metal-cpp sources first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants