mirror of
https://github.com/UniXNU/NativeMetal.git
synced 2026-11-18 21:41:38 +03:00
feat(plugin): report a client process's first Metal problem
This commit is contained in:
@@ -194,6 +194,18 @@ static id clientDevice(unsigned port) {
|
||||
if (!device && !lastError[0]) lastError = nmb_last_error();
|
||||
}
|
||||
if (!device) clientFailure(port, usable ? "no-device" : "no-cachedir", lastError);
|
||||
// The client's first problem, once, on the same text line: WidgetRenderer crashed on a nil render encoder with no reason anywhere readable
|
||||
// (its own log lines need the plugin's format strings, which the device does not keep). Checked every second for ten minutes.
|
||||
if (device) {
|
||||
dispatch_async(dispatch_get_global_queue(QOS_CLASS_UTILITY, 0), ^{
|
||||
for (unsigned second = 0; second < 600; ++second) {
|
||||
char problem[200] = {};
|
||||
const uint64_t count = native_bridge_metal_first_problem(problem, sizeof problem);
|
||||
if (count) {clientFailure(port, "problem", problem); return;}
|
||||
sleep(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
return device;
|
||||
}
|
||||
static id deviceForPort(unsigned port) {
|
||||
|
||||
@@ -15,6 +15,8 @@ id native_bridge_metal_library_with_air(const void *bytes, size_t length);
|
||||
size_t native_bridge_metal_status(char *out, size_t size);
|
||||
// The pixel formats of the textures asked for (first eight distinct) and how many texture requests the runtime refused.
|
||||
size_t native_bridge_metal_formats(char *out, size_t size);
|
||||
// The process's first problem (a refusal or a missing call) into out, and how many problems there were.
|
||||
uint64_t native_bridge_metal_first_problem(char *out, size_t size);
|
||||
size_t native_bridge_metal_telemetry(char *out, size_t size);
|
||||
// Structured cumulative artifact/driver-cache counters for offline qualification.
|
||||
struct NmbShaderCacheStats;
|
||||
|
||||
@@ -63,9 +63,12 @@ extern "C" unsigned native_bridge_metal_recent_commits(uint64_t windowUs) {
|
||||
}
|
||||
static std::mutex gProblemLock;
|
||||
static char gLastProblems[2][200];
|
||||
// The process's first problem, kept: a client process has no telemetry table, and its first refusal is usually the cause of the rest.
|
||||
static char gFirstProblem[200];
|
||||
static void noteProblem(NSString *what) {
|
||||
gProblems++;
|
||||
std::lock_guard<std::mutex> lock(gProblemLock);
|
||||
if(!gFirstProblem[0])strlcpy(gFirstProblem,what.UTF8String?:"?",sizeof gFirstProblem);
|
||||
memcpy(gLastProblems[1],gLastProblems[0],sizeof gLastProblems[0]);
|
||||
strlcpy(gLastProblems[0],what.UTF8String?:"?",sizeof gLastProblems[0]);
|
||||
}
|
||||
@@ -1781,6 +1784,11 @@ extern "C" size_t native_bridge_metal_telemetry(char *out,size_t size) {
|
||||
return at;
|
||||
}
|
||||
|
||||
extern "C" uint64_t native_bridge_metal_first_problem(char *out,size_t size) {
|
||||
std::lock_guard<std::mutex> lock(gProblemLock);
|
||||
if(size)strlcpy(out,gFirstProblem,size);
|
||||
return gProblems.load();
|
||||
}
|
||||
extern "C" size_t native_bridge_metal_formats(char *out,size_t size) {
|
||||
std::lock_guard<std::mutex> lock(gProblemLock);
|
||||
return native_bridge_metal_formats_locked(out,size);
|
||||
|
||||
Reference in New Issue
Block a user