feat(metal): show the head and tail of a client failure

The board row holds 63 characters: drop the common prefix and keep what
was refused and why. Shader priming does not report problems.
This commit is contained in:
bluseliu50
2026-10-28 20:13:16 +08:00
committed by Sharky Wang
Unverified
parent 0ce1aef588
commit 3ef2bead14
2 changed files with 10 additions and 1 deletions
+8 -1
View File
@@ -150,8 +150,15 @@ static void reportDisplayState(Gpu &gpu) {
static unsigned gClientPort;
static void clientFailure(unsigned port, const char *step, const char *detail) {
if (Gpu *gpu = makeGpu(port)) {
// The row holds 63 characters: the common prefix goes, and a long reason keeps its start (what was refused) and its end (why).
if (!detail) detail = "";
if (!strncmp(detail, "native-metal: ", 14)) detail += 14;
char shown[48];
const size_t length = strlen(detail);
if (length <= 46) strlcpy(shown, detail, sizeof shown);
else snprintf(shown, sizeof shown, "%.18s~%s", detail, detail + length - 27);
char text[64];
snprintf(text, sizeof text, "%.14s %.46s", step, detail ? detail : "");
snprintf(text, sizeof text, "%.14s %s", step, shown);
streamText(*gpu, text);
}
}
+2
View File
@@ -36,6 +36,7 @@ extern "C" unsigned native_bridge_metal_recent_commits(uint64_t windowUs);
// saw in 250 ms.
extern "C" {volatile uint32_t native_prime_compiling, native_prime_libraries_done, native_prime_libraries_total, native_prime_made, native_prime_rate;}
extern "C" void native_bridge_metal_quiet_problems(bool);
namespace prime {
static const char *const kRoots[] = {"/System/Library", "/Applications", "/System/Cryptexes/OS/System/Library"};
@@ -291,6 +292,7 @@ static std::string library(id<MTLDevice> device, const std::string &path, const
// The thread: waits for the desktop to settle, then works through the libraries not finished yet.
static void run(id<MTLDevice> device, std::string root, unsigned delaySeconds, const std::string &listPath) {
pthread_set_qos_class_self_np(QOS_CLASS_BACKGROUND, 0);
native_bridge_metal_quiet_problems(true);
while (root.size() > 1 && root.back() == '/') root.pop_back();
const std::string donePath = root + "/prime-done", badPath = root + "/prime-bad", current = root + "/prime-current",
logPath = root + "/prime.log";