Check recommended Mac profiles in demo worlds and retain separate Vulkan research

This commit is contained in:
Ludovic Marie
2026-10-04 11:26:47 +02:00
parent 3858ab38b5
commit a5000edf11
5 changed files with 146 additions and 46 deletions
+7 -27
View File
@@ -59,34 +59,13 @@ jobs:
run: python -c "from tools.build_mod import benchmark_headers; benchmark_headers()"
- name: Test pack integrity and comparisons
run: python -m unittest discover -s tests -v
- name: Start native macOS clients and verify framebuffer readback
- name: Start recommended OpenGL macOS clients and verify framebuffer readback
if: runner.os == 'macOS'
run: |
python - <<'PY'
import json, subprocess, sys
from pathlib import Path
cases = [
['--profile', 'baseline', '--backend', 'vulkan'],
['--profile', 'core-performance', '--backend', 'vulkan'],
['--profile', 'core-performance'],
['--profile', 'm2-balanced'],
['--profile', 'vulkan'],
]
failed = []
observations = []
for case in cases:
result = subprocess.run([sys.executable, 'tools/test_client_graphics.py', '--native-display', *case])
observation = {'case': case, 'exit_code': result.returncode}
if result.returncode:
failed.append(case)
else:
observation['report'] = json.loads(Path('dist/client-graphics-smoke.json').read_text())
observations.append(observation)
Path('dist/client-graphics-macos-cases.json').write_text(json.dumps(observations, indent=2) + '\n')
if failed:
print('HORIZON_MAC_GRAPHICS_FAILED_CASES', failed, flush=True)
sys.exit(1)
PY
python tools/test_client_graphics.py --native-display
cp dist/client-graphics-smoke.json dist/client-graphics-macos-title.json
python tools/test_client_graphics.py --native-display --world
cp dist/client-graphics-smoke.json dist/client-graphics-macos-world.json
- name: Compile the private dispatch fixture
run: python -c "from tools.build_mod import build_dispatch_fixture; build_dispatch_fixture()"
- name: Compile the private tick-manager state fixture
@@ -152,4 +131,5 @@ jobs:
dist/quad-reuse-integration.json
dist/quad-size-integration.json
dist/client-graphics-smoke.json
dist/client-graphics-macos-cases.json
dist/client-graphics-macos-title.json
dist/client-graphics-macos-world.json
@@ -0,0 +1,50 @@
name: macOS Vulkan research
on:
workflow_dispatch:
permissions:
contents: read
jobs:
native-probes:
runs-on: macos-26
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '25'
- name: Build original mod and private probe dependencies
run: python tools/build_mod.py
- name: Probe vanilla, core and distant-terrain Vulkan cases
run: |
python - <<'PY'
import json, subprocess, sys
from pathlib import Path
cases = [
['--profile', 'baseline', '--backend', 'vulkan'],
['--profile', 'core-performance', '--backend', 'vulkan'],
['--profile', 'vulkan'],
]
observations = []
for case in cases:
result = subprocess.run([sys.executable, 'tools/test_client_graphics.py', '--native-display', *case], capture_output=True, text=True)
print(result.stdout, end='', flush=True)
print(result.stderr, end='', flush=True)
observation = {'case': case, 'exit_code': result.returncode}
if result.returncode:
marker = 'HORIZON_FIXTURE_FAILURE '
observation['failure'] = [json.loads(line.split(marker, 1)[1]) for line in result.stdout.splitlines() if marker in line]
else:
observation['report'] = json.loads(Path('dist/client-graphics-smoke.json').read_text())
observations.append(observation)
Path('dist/client-graphics-vulkan-research.json').write_text(json.dumps(observations, indent=2) + '\n')
sys.exit(int(any(item['exit_code'] for item in observations)))
PY
- name: Retain selected observations including failed cases
if: always()
uses: actions/upload-artifact@v4
with:
name: macos-vulkan-observations
path: dist/client-graphics-vulkan-research.json
@@ -8,23 +8,52 @@ import java.util.HashSet;
import java.util.HexFormat;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.Screenshot;
import net.minecraft.client.gui.screens.TitleScreen;
import net.minecraft.network.chat.contents.TranslatableContents;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.levelgen.WorldOptions;
import net.minecraft.world.level.levelgen.presets.WorldPresets;
/** Private startup/readback probe. Never packaged in a playable release. */
public final class ClientGraphicsIntegration implements ClientModInitializer {
private long titleStarted;
private int titleTicks;
private boolean requested;
private boolean opening;
private final boolean worldMode = Files.exists(FabricLoader.getInstance().getConfigDir().resolve("client-graphics-world.flag"));
@Override public void onInitializeClient() {
System.out.println("HORIZON_CLIENT_GRAPHICS_INITIALIZER_READY");
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (requested || !(client.gui.screen() instanceof TitleScreen)) return;
if (requested) return;
if (worldMode) {
if (!opening && client.gui.screen() instanceof TitleScreen screen) {
opening = true;
if (Files.isRegularFile(client.gameDirectory.toPath().resolve("saves/Demo_World/level.dat"))) {
client.createWorldOpenFlows().openWorld("Demo_World", () -> {
throw new AssertionError("Disposable graphics world did not open");
});
} else {
client.createWorldOpenFlows().createFreshLevel("Demo_World", MinecraftServer.DEMO_SETTINGS,
WorldOptions.DEMO_OPTIONS, WorldPresets::createNormalWorldDimensions, screen);
}
return;
}
if (client.gui.screen() != null && client.gui.screen().getTitle().getContents() instanceof TranslatableContents title
&& title.getKey().equals("demo.help.title")) {
client.gui.setScreen(null);
return;
}
if (client.level == null || client.player == null || client.gui.screen() != null
|| client.isPaused() || !client.isWindowActive()) return;
} else if (!(client.gui.screen() instanceof TitleScreen)) return;
if (titleStarted == 0) titleStarted = System.nanoTime();
titleTicks++;
if (titleTicks < 40 || System.nanoTime() - titleStarted < 2_000_000_000L) return;
requested = true;
System.out.println("HORIZON_CLIENT_GRAPHICS_READBACK_REQUESTED");
Screenshot.takeScreenshot(client.gameRenderer.mainRenderTarget(), image -> {
try (image) {
int width = image.getWidth(), height = image.getHeight();
@@ -42,8 +71,11 @@ public final class ClientGraphicsIntegration implements ClientModInitializer {
image.writeToFile(screenshot);
var device = RenderSystem.getDevice().getDeviceInfo();
var result = new JsonObject();
result.addProperty("title_screen_observed", true);
result.addProperty("title_client_ticks", titleTicks);
result.addProperty("observed_mode", worldMode ? "world" : "title");
result.addProperty("title_screen_observed", !worldMode);
result.addProperty("world_loaded", worldMode && client.level != null);
result.addProperty("ready_client_ticks", titleTicks);
result.addProperty("window_active", client.isWindowActive());
result.addProperty("framebuffer_width", width);
result.addProperty("framebuffer_height", height);
result.addProperty("sampled_pixels", samples);
+19
View File
@@ -3,9 +3,28 @@ import subprocess
import unittest
from tools.test_dispatch import failure_summary
from tools.test_client_graphics import graphics_failure_summary
class FixtureDiagnosticTests(unittest.TestCase):
def test_graphics_diagnostics_separate_demo_auth_and_exclude_methods_messages(self):
output = '\n'.join([
'com.mojang.authlib.exceptions.InvalidCredentialsException: private-token',
' at com.mojang.authlib.minecraft.client.MinecraftClient.buildHttpException(File.java:1)',
'java.lang.AssertionError: /private/world/path',
'Caused by: java.lang.RuntimeException: private-message VK_ERROR_FEATURE_NOT_PRESENT',
'HORIZON_CLIENT_GRAPHICS_INITIALIZER_READY',
'HORIZON_CLIENT_GRAPHICS_READBACK_REQUESTED',
])
result = graphics_failure_summary(subprocess.CompletedProcess([], 1, output), 0)
self.assertEqual(result['java_exception_types'], ['java.lang.AssertionError', 'java.lang.RuntimeException'])
self.assertTrue(result['expected_demo_authentication_errors_observed'])
self.assertTrue(result['client_initializer_reached'])
self.assertTrue(result['readback_requested'])
self.assertEqual(result['vulkan_error_codes'], ['VK_ERROR_FEATURE_NOT_PRESENT'])
self.assertNotIn('private', json.dumps(result))
self.assertNotIn('buildHttpException', json.dumps(result))
def test_only_exit_count_and_exception_types_leave_private_log(self):
output = '\n'.join([
'Exception in thread "private-thread-name" java.lang.NoClassDefFoundError: private-token',
+35 -16
View File
@@ -21,11 +21,31 @@ except ImportError:
from test_dispatch import failure_summary
def graphics_failure_summary(run, report_count):
"""Selected stages/types/codes only; messages, paths and raw logs stay private."""
result = failure_summary(run, report_count)
pattern = r'(?<![\w.$])((?:java|org\.lwjgl|com\.mojang|net\.minecraft|net\.fabricmc|org\.spongepowered|dev\.horizonlab)\.[A-Za-z_$][\w.$]{0,160}(?:Exception|Error))(?=[:\s]|$)'
observed = set(result['java_exception_types']) | set(re.findall(pattern, run.stdout, re.ASCII))
expected_auth = {name for name in observed if name.startswith(('com.mojang.authlib.', 'com.mojang.realmsclient.'))}
result['java_exception_types'] = sorted(observed - expected_auth)[:8]
result['expected_demo_authentication_errors_observed'] = bool(expected_auth)
for key, marker in [('backend_attempts', 'HORIZON_GRAPHICS_BACKEND_ATTEMPT '),
('created_devices', 'HORIZON_GRAPHICS_DEVICE_CREATED ')]:
result[key] = [json.loads(line.split(marker, 1)[1]) for line in run.stdout.splitlines() if marker in line][:16]
result['client_initializer_reached'] = 'HORIZON_CLIENT_GRAPHICS_INITIALIZER_READY' in run.stdout
result['readback_requested'] = 'HORIZON_CLIENT_GRAPHICS_READBACK_REQUESTED' in run.stdout
result['vulkan_error_codes'] = sorted(set(re.findall(r'\bVK_ERROR_[A-Z_0-9]{1,100}\b', run.stdout)))[:16]
result['fatal_jvm_error'] = 'A fatal error has been detected by the Java Runtime Environment' in run.stdout
return result
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--native-display', action='store_true')
parser.add_argument('--profile', action='append', choices=sorted(build_pack.PROFILES))
parser.add_argument('--backend', choices=['opengl', 'vulkan'], help='Override backend in these private instances only')
parser.add_argument('--world', action='store_true', help='Create/open a disposable built-in demo world instead of stopping at the title')
args = parser.parse_args()
root = build_pack.ROOT
fixture = build_mod.build_integration_fixture('client-graphics',
@@ -35,10 +55,12 @@ def main():
mod = root / 'dist' / f'horizon-lab-{version}.jar'
original_hash = hashlib.sha256(mod.read_bytes()).hexdigest()
results = []
for profile in args.profile or ['core-performance', 'm2-balanced', 'vulkan']:
for profile in args.profile or ['core-performance', 'm2-balanced']:
instance = root / '.local/runtime' / ('client-graphics-' + profile
+ ('-override-' + args.backend if args.backend else ''))
+ ('-override-' + args.backend if args.backend else '') + ('-world' if args.world else ''))
build_pack.prepare_instance(profile, instance, mod)
if args.world:
(instance / 'config/client-graphics-world.flag').touch()
if args.backend:
options = instance / 'options.txt'
text, count = re.subn(r'^preferredGraphicsBackend:.*$',
@@ -62,23 +84,19 @@ def main():
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:
diagnostics = failure_summary(run, len(reports))
diagnostics = graphics_failure_summary(run, len(reports))
diagnostics['profile'] = profile
diagnostics['preferred_backend'] = args.backend or build_pack.PROFILES[profile].get('backend', 'opengl')
diagnostics['backend_attempts'] = attempts
device_marker = 'HORIZON_GRAPHICS_DEVICE_CREATED '
diagnostics['created_devices'] = [json.loads(line.split(device_marker, 1)[1])
for line in run.stdout.splitlines() if device_marker in line]
diagnostics['client_initializer_reached'] = 'HORIZON_CLIENT_GRAPHICS_INITIALIZER_READY' in run.stdout
diagnostics['vulkan_error_codes'] = sorted(set(re.findall(r'\bVK_ERROR_[A-Z_0-9]{1,100}\b', run.stdout)))[:16]
diagnostics['java_exception_types'] = sorted(set(diagnostics['java_exception_types']) | set(
re.findall(r'\b((?:java|org\.lwjgl|com\.mojang|net\.minecraft|net\.fabricmc|org\.spongepowered|dev\.horizonlab)\.[A-Za-z_$][\w.$]{0,160}(?:Exception|Error))\b', run.stdout, re.ASCII)))[:8]
diagnostics['fatal_jvm_error'] = 'A fatal error has been detected by the Java Runtime Environment' in run.stdout
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:
raise AssertionError('Client never reached the title screen')
if report['observed_mode'] != ('world' if args.world else 'title') or report['ready_client_ticks'] < 40:
raise AssertionError('Client never reached the requested graphics scene')
if args.world:
if report['world_loaded'] is not True or report['window_active'] is not True:
raise AssertionError('Client never reached focused demo-world gameplay')
if not list((instance / 'saves/Demo_World').rglob('*.dat')):
raise AssertionError('Disposable world did not leave saved data')
if report['sampled_pixels'] < 256 or report['distinct_sampled_rgb'] < 8:
raise AssertionError('GPU readback was uniform')
if hashlib.sha256((instance / 'mods' / mod.name).read_bytes()).hexdigest() != original_hash:
@@ -94,8 +112,9 @@ def main():
output.write_text(json.dumps({'schema': 1, 'platform': platform.platform(),
'architecture': platform.machine(), 'minecraft': '26.3',
'original_mod_sha256': original_hash, 'results': results,
'limits': ['Title-screen startup and nonuniform framebuffer readback only.',
'No world gameplay, visual-correctness, FPS or M2 Pro performance claim.',
'limits': ['Short scene startup and nonuniform framebuffer readback only.',
'World mode uses the ordinary limited demo; world files remain private.',
'No exhaustive gameplay, visual-correctness, FPS or M2 Pro performance claim.',
'Vulkan preference can fall back; inspect the observed backend.',
'PNG images, assets and full logs remain in the private runtime directory.']}, indent=2) + '\n')
print('Client graphics startup/readback checks passed.', flush=True)