From 60078a196196bcecf2a53fec64b12aa9ca0e85d2 Mon Sep 17 00:00:00 2001 From: bluseliu50 <265648257+bluseliu50@users.noreply.github.com> Date: Tue, 3 Nov 2026 01:49:57 +0800 Subject: [PATCH] fix(diagnostics): send each distinct refusal to the GPU trace With sheng-gpu-trace=1 a refusal text reaches the kernel ring as event 65 in up to two 88-character parts. --- NativeBridgeMetalFrontend.mm | 9 +++++++++ NativeGpuLatency.h | 5 +++-- NativeGpuTrace.h | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/NativeBridgeMetalFrontend.mm b/NativeBridgeMetalFrontend.mm index bcb4a69..aec500d 100644 --- a/NativeBridgeMetalFrontend.mm +++ b/NativeBridgeMetalFrontend.mm @@ -514,6 +514,15 @@ static void noteProblem(NSString *what) { if(native_bridge_metal_problem_hook)native_bridge_metal_problem_hook(gFirstProblem); } } + // With sheng-gpu-trace=1 each distinct refusal text reaches the kernel GPU ring (event 65, 88 characters a part), for the processes + // whose crash follows a nil Metal object (iconservicesagent in untagged-102cb4a069). + if(gpuTraceOn() && gFrameTransport) { + const char *text=what.UTF8String?:"?";const size_t length=strlen(text); + for(uint64_t part=0;part<2 && part*88= 1 && stage <= 16) || (stage >= 40 && stage <= 57); } /* The kernel ring keeps GPU submission and retirement, display arrival, fence - * and latch, build identity and the render threads the CPU sampler follows. */ + * and latch, build identity, the render threads the CPU sampler follows and + * each process's Metal refusals (event 65, the text of what failed). */ static inline bool native_gpu_latency_event(uint32_t event,const uint64_t *,uint32_t) { switch(event) { - case 1:case 3:case 10:case 11:case 20:case 21:case 22:case 23:case 63:return true; + case 1:case 3:case 10:case 11:case 20:case 21:case 22:case 23:case 63:case 65:return true; default:return false; } } diff --git a/NativeGpuTrace.h b/NativeGpuTrace.h index 7d64195..4bfb51f 100644 --- a/NativeGpuTrace.h +++ b/NativeGpuTrace.h @@ -12,7 +12,7 @@ enum { GpuTraceConfig=1, GpuTraceBuild=3, GpuTraceSubmit=10, GpuTraceRetire=11, GpuTraceDisplay=20, GpuTraceDisplaySurface=21, GpuTraceDisplayFence=22, - GpuTraceDisplayLatch=23, GpuTraceThread=63 + GpuTraceDisplayLatch=23, GpuTraceThread=63, GpuTraceProblem=65 }; struct NativeGpuTraceRecord { uint64_t sequence,us;