Trace backend initialization categories in private graphics probes
This commit is contained in:
+52
@@ -0,0 +1,52 @@
|
||||
package dev.horizonlab.dispatch.fixture;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.renderpearl.api.device.BackendCreationException;
|
||||
import com.mojang.renderpearl.api.device.GpuBackend;
|
||||
import com.mojang.renderpearl.api.device.GpuDebugOptions;
|
||||
import com.mojang.renderpearl.api.device.GpuDevice;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
/** Private diagnostic wrapper. Calls the original operations and rethrows their errors. */
|
||||
@Mixin(Minecraft.class)
|
||||
public abstract class GraphicsBackendTraceMixin {
|
||||
private static void trace(GpuBackend backend, String operation, Throwable failure) {
|
||||
var result = new JsonObject();
|
||||
String name = backend.getName();
|
||||
result.addProperty("backend", name.equals("OpenGL") || name.equals("Vulkan") ? name : "other");
|
||||
result.addProperty("operation", operation);
|
||||
result.addProperty("result", failure == null ? "success" : "failure");
|
||||
if (failure != null) result.addProperty("exception_type", failure.getClass().getName());
|
||||
if (failure instanceof BackendCreationException backendFailure)
|
||||
result.addProperty("reason", backendFailure.getReason().name());
|
||||
System.out.println("HORIZON_GRAPHICS_BACKEND_ATTEMPT " + result);
|
||||
}
|
||||
|
||||
@Redirect(method = "<init>", at = @At(value = "INVOKE",
|
||||
target = "Lcom/mojang/renderpearl/api/device/GpuBackend;loadLibrary()V"), require = 1, allow = 1)
|
||||
private void horizon$traceLibrary(GpuBackend backend) throws BackendCreationException {
|
||||
try {
|
||||
backend.loadLibrary();
|
||||
trace(backend, "load_library", null);
|
||||
} catch (BackendCreationException | RuntimeException | LinkageError | AssertionError failure) {
|
||||
trace(backend, "load_library", failure);
|
||||
throw failure;
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "<init>", at = @At(value = "INVOKE",
|
||||
target = "Lcom/mojang/renderpearl/api/device/GpuBackend;createDevice(Lcom/mojang/renderpearl/api/device/GpuDebugOptions;)Lcom/mojang/renderpearl/api/device/GpuDevice;"), require = 1, allow = 1)
|
||||
private GpuDevice horizon$traceDevice(GpuBackend backend, GpuDebugOptions options) throws BackendCreationException {
|
||||
try {
|
||||
GpuDevice device = backend.createDevice(options);
|
||||
trace(backend, "create_device", null);
|
||||
return device;
|
||||
} catch (BackendCreationException | RuntimeException | LinkageError | AssertionError failure) {
|
||||
trace(backend, "create_device", failure);
|
||||
throw failure;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,8 @@ def main():
|
||||
args = parser.parse_args()
|
||||
root = build_pack.ROOT
|
||||
fixture = build_mod.build_integration_fixture('client-graphics',
|
||||
'dev.horizonlab.metrics.ClientGraphicsIntegration', fixture_dependencies={})
|
||||
'dev.horizonlab.metrics.ClientGraphicsIntegration',
|
||||
fixture_mixins=['GraphicsBackendTraceMixin'], fixture_dependencies={})
|
||||
version = build_pack.read_lock()['pack_version']
|
||||
mod = root / 'dist' / f'horizon-lab-{version}.jar'
|
||||
original_hash = hashlib.sha256(mod.read_bytes()).hexdigest()
|
||||
@@ -48,8 +49,12 @@ def main():
|
||||
raise RuntimeError('Graphics probe did not finish; diagnostics remain private') from None
|
||||
marker = 'HORIZON_CLIENT_GRAPHICS_RESULT '
|
||||
reports = [json.loads(line.split(marker, 1)[1]) for line in run.stdout.splitlines() if marker in line]
|
||||
trace_marker = 'HORIZON_GRAPHICS_BACKEND_ATTEMPT '
|
||||
attempts = [json.loads(line.split(trace_marker, 1)[1]) for line in run.stdout.splitlines() if trace_marker in line]
|
||||
if run.returncode or len(reports) != 1:
|
||||
print('HORIZON_FIXTURE_FAILURE ' + json.dumps(failure_summary(run, len(reports))), flush=True)
|
||||
diagnostics = failure_summary(run, len(reports))
|
||||
diagnostics['backend_attempts'] = attempts
|
||||
print('HORIZON_FIXTURE_FAILURE ' + json.dumps(diagnostics), flush=True)
|
||||
raise RuntimeError('Graphics probe failed; diagnostics remain private')
|
||||
report = reports[0]
|
||||
if report['title_screen_observed'] is not True or report['title_client_ticks'] < 40:
|
||||
@@ -61,7 +66,7 @@ def main():
|
||||
screenshot = instance / 'client-graphics-private.png'
|
||||
if not screenshot.is_file() or hashlib.sha256(screenshot.read_bytes()).hexdigest() != report['private_png_sha256']:
|
||||
raise AssertionError('Private screenshot evidence is missing or changed')
|
||||
report.update(profile=profile, launcher_exit_code=run.returncode)
|
||||
report.update(profile=profile, launcher_exit_code=run.returncode, backend_attempts=attempts)
|
||||
results.append(report)
|
||||
print(json.dumps(report), flush=True)
|
||||
output = root / 'dist/client-graphics-smoke.json'
|
||||
|
||||
Reference in New Issue
Block a user