Archive incari-client (client, 26.3, clean)
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
# ADR 0001: The repo is patch-only, built on the Spigot/Paper model
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-25
|
||||
|
||||
## Context
|
||||
|
||||
Incari modifies Minecraft's client, and Mojang's code and assets can't be redistributed. Playable
|
||||
Eaglercraft repositories were taken down in 2023, and the EaglercraftX workspace now returns
|
||||
HTTP 451 on GitHub. Spigot's BuildTools has survived since 2014 by shipping only patches plus a tool
|
||||
that downloads and decompiles the game on the user's machine.
|
||||
|
||||
## Decision
|
||||
|
||||
- The repo tracks only Incari's own code, patch files, and a manifest of whole-class changes.
|
||||
- `./incari setup` downloads the pinned client jar from Mojang, decompiles it with Vineflower into
|
||||
the git-ignored `work/`, and applies the patches. A fresh clone reaches a patched tree with that
|
||||
one command.
|
||||
- Game edits are commits in `work/client`. `./incari rebuild` turns them into patch files. Patch
|
||||
files are never edited by hand.
|
||||
- Patches carry as little Mojang text as possible: one context line, no hunk-header function names,
|
||||
and no file deletions. Deleting or replacing a whole class goes through `patches/classes.txt`,
|
||||
which names the class and contains none of its code.
|
||||
- The version, the client jar's SHA-1 and the Vineflower version are pinned exactly, so every
|
||||
machine decompiles the same bytes and the patches apply everywhere.
|
||||
- CI never publishes a build (no artifacts, releases or pages), and a guard script enforces it.
|
||||
|
||||
## Alternatives rejected
|
||||
|
||||
- **Commit the decompiled source on a vendor branch** (the original plan's first sketch): simplest to
|
||||
rebase, but it puts Mojang's code in the repo.
|
||||
- **A binary patch against the jar** (Paper's Paperclip): works for JVM bytecode, but Incari's output
|
||||
is a TeaVM compile. The source tree has to exist locally anyway.
|
||||
- **Full diff context** (`-U3`, the git default): more robust to drift, but triples the Mojang lines
|
||||
in the repo. `git am --3way` with full blob ids recovers most of that robustness.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Updating to a new drop means re-pinning `incari.properties`, then `./incari setup`, fixing
|
||||
conflicts in `work/client`, and `./incari rebuild`. Automating this is planned.
|
||||
- Anyone building Incari needs network access to Mojang's download hosts.
|
||||
- Patch files still contain a few Mojang lines as diff context. Keeping patches thin (one- or
|
||||
two-line hooks into Incari modules) keeps that small; CI holds patches to a size budget.
|
||||
@@ -0,0 +1,22 @@
|
||||
# ADR 0002: GPL-3.0-or-later with a Minecraft additional permission, and DCO sign-off
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-25
|
||||
|
||||
## Decision
|
||||
|
||||
- Incari's own code is licensed **GPL-3.0-or-later** (`LICENSE`) with an **additional permission
|
||||
under GPL section 7** (`LICENSE-EXCEPTION.txt`). It lets anyone convey Incari combined with
|
||||
Minecraft: Java Edition without having to provide Minecraft's source.
|
||||
- Contributors certify the **Developer Certificate of Origin** (`DCO.txt`) with a `Signed-off-by`
|
||||
line on every commit. Signing off licenses the contribution under the project license, exception
|
||||
included, so no contributor's code can later be used against the builds. CI checks sign-offs on
|
||||
every pull request.
|
||||
- DCO rather than a CLA: it's lighter for contributors, and the exception is part of the license
|
||||
every contribution is made under, so a separate grant isn't needed.
|
||||
|
||||
## Consequences
|
||||
|
||||
- The published source must keep `LICENSE`, `LICENSE-EXCEPTION.txt` and `DCO.txt` at the root.
|
||||
- Third-party code copied into Incari must be GPL-3.0-compatible, and must allow the exception.
|
||||
Code under a license that forbids adding permissions can't be merged into Incari modules.
|
||||
@@ -0,0 +1,56 @@
|
||||
# ADR 0003: Enforced module boundaries and one set of quality gates
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-26
|
||||
|
||||
## Context
|
||||
|
||||
Incari is two halves: Mojang's decompiled game, which is touched as little as possible, and
|
||||
Incari's own code, which people and agents write in parallel streams (graphics, platform,
|
||||
network, features). Without mechanical checks, the architecture erodes one convenient import at a
|
||||
time. It's also easy to paste decompiled code into an Incari module, which is a quality problem
|
||||
and a legal one.
|
||||
|
||||
## Decision
|
||||
|
||||
- **Modules and their allowed dependencies are one file**, `gradle/module-boundaries.txt`.
|
||||
`./gradlew checkModuleBoundaries` (part of `check`) fails on an undeclared project dependency
|
||||
and on a module the file doesn't list. ArchUnit tests in each module enforce the package-level
|
||||
rules a Gradle dependency can't express: `platform-api` uses only the JDK and JSpecify, the
|
||||
platforms see no game types, and Incari's game-side code never touches LWJGL or TeaVM directly.
|
||||
- **One set of gates for all Incari code**, run by `./gradlew check`, `npm run check`, CI and the
|
||||
pre-commit hook:
|
||||
- Java: Palantir Java Format via Spotless; `-Xlint:all -Werror`; Error Prone; NullAway in
|
||||
JSpecify mode, where unannotated means non-null (`AnnotatedPackages=incari`).
|
||||
- TypeScript: `strict` plus stricter compiler options, typescript-eslint's strict type-checked
|
||||
rules with zero warnings allowed, `any` an error, a reason required on every disable comment,
|
||||
Prettier.
|
||||
- GLSL: glslang validates every Incari shader.
|
||||
- The verbatim-copy check (`./incari copycheck`) fails on 60-token runs identical to the
|
||||
decompiled game.
|
||||
- The patch budget (`patches/budget.properties`) makes growth in vendor edits a deliberate,
|
||||
reviewed change.
|
||||
- **Vendor code is exempt from all of it.** It's never formatted, linted or fixed for warnings.
|
||||
`:client` compiles it with lint off, and `strictCompile` rechecks Incari's sources in that
|
||||
module with the full gates.
|
||||
- **The build runs on JDK 25** (`gradle/gradle-daemon-jvm.properties` and the toolchain), the
|
||||
same as CI and TeaVM's limit, so formatter and compiler results don't depend on the machine.
|
||||
- **Human review** is required through `CODEOWNERS` for patches, graphics, networking, licensing
|
||||
and the guards themselves.
|
||||
|
||||
## Alternatives rejected
|
||||
|
||||
- **Convention plugins in `build-logic`**: cleaner at scale, but a second build to maintain for
|
||||
about thirty lines of shared configuration. Revisit when features add many modules.
|
||||
- **Checkstyle or Spotless-only rules for architecture**: they can't see the dependency graph.
|
||||
- **A `-Werror`-free `:client`**: would let warnings pile up in Incari's adapter code, the one
|
||||
place Incari and vendor code meet.
|
||||
- **An allowlist for copycheck findings**: every finding is fixed by rewriting, never excused.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Adding a module means a line in `module-boundaries.txt` and an ArchUnit test; changing a line
|
||||
needs an ADR.
|
||||
- `./gradlew check` needs `./incari setup` first, because `:client` compiles the patched tree.
|
||||
- Upgrading Palantir, Error Prone or TeaVM past what JDK 25 supports means moving the whole
|
||||
build's JDK, not one tool.
|
||||
@@ -0,0 +1,45 @@
|
||||
# ADR 0004: The game is built from the patched source tree, starting with decompile fixes
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-26
|
||||
|
||||
## Context
|
||||
|
||||
The TeaVM survey compiled Mojang's jar, not source. Everything after it needs the game compiled
|
||||
from `work/client`, because that's where Incari's patches live: the desktop runtime and the
|
||||
TeaVM build both start from it. Vineflower 1.12.0's output of 26.3 doesn't compile as-is:
|
||||
javac reports 233 errors in 119 files. About 90 are annotation jars Mojang compiled against but
|
||||
doesn't ship; the rest are generics, casts and variable scopes the decompiler lost. Vineflower's
|
||||
`--explicit-generics` makes it worse (1,000 errors).
|
||||
|
||||
## Decision
|
||||
|
||||
- **`:client` compiles `work/client`** as its main source set, against Mojang's own library jars
|
||||
(the list `incari fetch` writes to `work/cache/versions/<version>/classpath.txt`, after checking
|
||||
each jar's SHA-1), plus JetBrains annotations and JSR-305 as compile-only dependencies.
|
||||
- **Decompile errors are fixed by patches in the `decompile` subsystem**, applied first. They
|
||||
restore what the original source must have been (a cast, a type witness, a renamed duplicate
|
||||
local, a missing enum case) and change no behavior; where behavior was in doubt, the bytecode
|
||||
decided. They are **not** wrapped in `// Incari start`/`// Incari end`: those markers identify
|
||||
Incari's changes to the game, and decompile fixes aren't changes to the game.
|
||||
- **Vendor warnings stay.** The tree is compiled with lint off, and a warning in Mojang's own code
|
||||
(26.3 has one) is never patched away.
|
||||
- **The decompiler options stay at Vineflower's defaults** (plus formatting). Any change to them
|
||||
regenerates every file and invalidates every patch.
|
||||
|
||||
## Alternatives rejected
|
||||
|
||||
- **Compile against Mojang's jar and patch only bytecode**: patches would be bytecode transforms
|
||||
instead of readable source diffs, and the desktop debugger would show decompiled, not patched,
|
||||
source.
|
||||
- **Replace every broken class through `classes.txt`**: an Incari-authored copy of a Mojang class
|
||||
is exactly the verbatim copying the repo forbids.
|
||||
- **Tune Vineflower until the output compiles**: tried with `--explicit-generics`, which made it
|
||||
worse; each new drop would need retuning anyway.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Each Minecraft drop starts with fixing the new decompile errors in `patches/decompile/`. The
|
||||
Future update automation would treat "the tree compiles" as its first gate.
|
||||
- The compiled client matches the jar class for class (11,383 classes for 26.3), which the desktop
|
||||
desktop runtime relies on.
|
||||
@@ -0,0 +1,72 @@
|
||||
# ADR 0005: The platform layer: whole-class replacements over Platform interfaces
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-26
|
||||
|
||||
## Context
|
||||
|
||||
26.3 talks to the machine directly: SDL3 for windowing and input, OpenAL for sound, Netty's NIO
|
||||
and epoll transports for servers, the JVM's thread pools. The browser has none of these. This ADR puts
|
||||
a platform layer under the game so the same code can run on the desktop (for development) and in
|
||||
the browser, and proves it on the desktop first: vanilla must stay fully playable.
|
||||
|
||||
The SDL and OpenAL calls sit in about twenty classes (`com.mojang.blaze3d.platform`,
|
||||
`com.mojang.blaze3d.audio`, `Blaze3D`) whose job is exactly this glue, plus a handful of calls in
|
||||
game classes (`RenderSystem`, `Minecraft`, `MouseHandler`, `InputConstants`, `InputQuirks`).
|
||||
|
||||
## Decision
|
||||
|
||||
- **`platform-api` defines the platform** as plain Java interfaces with no game or library types:
|
||||
`Platform` (lifecycle, clock, event polling) with `PlatformWindow`/`PlatformDisplays`,
|
||||
`PlatformInput`, `PlatformShell` (clipboard, links, message boxes), `PlatformAudio`,
|
||||
`PlatformNetwork` (a byte stream), `PlatformStorage` and `PlatformThreads`. One platform is
|
||||
installed per process (`Platforms`).
|
||||
- **Input uses SDL3's conventions as data**: scancodes are USB HID usage ids, keycodes follow SDL's
|
||||
rule, modifier bits are `SDL_Keymod` values, key actions press/release/repeat. That's what the
|
||||
game's key handling already reads, so the desktop passes events through untouched and the
|
||||
browser maps `KeyboardEvent.code` onto the same ids.
|
||||
- **Glue classes are replaced whole** (`patches/classes.txt`) by Incari sources in
|
||||
`client/src/main/java` that keep the game-facing API and delegate to the platform. A replacement
|
||||
is written fresh (copycheck holds it to that) and carries the full quality gates; a patch that
|
||||
deleted the same SDL code would republish it as `-` lines. Classes that are mostly game logic
|
||||
(`VideoMode`, `InputConstants`, `RenderSystem`...) get small hook patches instead.
|
||||
- **Policy moves with the OS calls.** Desktop windowing rules (borderless-window fullscreen on
|
||||
Windows, exclusive-mode fallback, mouse confinement in exclusive fullscreen) live in
|
||||
`platform-desktop`; the game's own rules (sizes, GUI scale, the fullscreen request) stay in the
|
||||
replacement `Window`.
|
||||
- **Graphics keeps Mojang's backend API.** `PreferredGraphicsApi.getBackendsToTry` asks
|
||||
`GraphicsBackends`, which the entry point fills: Mojang's OpenGL and Vulkan backends on the
|
||||
desktop, WebGL2 in the browser. The backend creates the native surface through the
|
||||
platform (`NativeSurfaceFactory`).
|
||||
- **Networking keeps Netty's pipeline.** Client connections use `PlatformSocketChannel`, a Netty
|
||||
channel over `PlatformNetwork`, so framing, compression and packets run unchanged over a socket
|
||||
on the desktop and a WebSocket in the browser. "Open to LAN" still listens with Netty NIO.
|
||||
- **Threads**: the platform sizes the background pool; 0 means run inline, which the browser uses
|
||||
until Web Workers (ADR 0015, 0023).
|
||||
- **The desktop runtime is verified by a scripted session** (`./gradlew :app-desktop:smokeTest`,
|
||||
and `smokeHost` + `smokeJoin` for two clients), driven by real SDL events.
|
||||
|
||||
## Deviations from vanilla
|
||||
|
||||
- macOS: the "Close Window" menu item isn't hidden (the desktop runtime doesn't drive the
|
||||
Objective-C menu); Command+W asks the game to close, which saves as usual.
|
||||
- Audio: a device that opens but lacks a required OpenAL extension is skipped in favour of the
|
||||
next device rather than failing sound; sources are capped at the device's mono-source count.
|
||||
- The smoke test turns off authentication on its own LAN world so an offline second client can
|
||||
join; vanilla always authenticates LAN guests.
|
||||
|
||||
## Alternatives rejected
|
||||
|
||||
- **Patching every SDL call site**: about 200 edits, each republishing Mojang lines in patch files,
|
||||
and conflicts on every drop that touches these classes.
|
||||
- **A platform API in game types** (taking `Window`, `VideoMode`): would tie `platform-desktop` and
|
||||
`platform-web` to the vendor tree and break the module boundary.
|
||||
- **Replacing Netty's pipeline with Incari's own protocol stack**: far more code, and the Via
|
||||
integration (ADR 0017) expects Netty.
|
||||
|
||||
## Consequences
|
||||
|
||||
- A new drop that changes a replaced class isn't a patch conflict; `./incari setup` still copies
|
||||
the replacement. Each drop needs a check that the replacements' API still matches (the compile
|
||||
catches most of it) and a smoke-test run.
|
||||
- `platform-web` implements the same interfaces (ADRs 0006–0015).
|
||||
@@ -0,0 +1,54 @@
|
||||
# ADR 0006: How the browser build links: removals by rule, a class library for the rest
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-26
|
||||
|
||||
## Context
|
||||
|
||||
TeaVM compiles a closed world: everything reachable must exist at link time. As-is, 26.3 reaches
|
||||
thousands of APIs a page can't have (LWJGL, JNA, OSHI, profilers, Realms, Vulkan, raw sockets) and JDK
|
||||
classes TeaVM lacks. The TeaVM survey (`docs/port-backlog.md`) filed each as *stub*, *shim*, *rewrite* or *delete*
|
||||
(`tools/survey/rules.txt`). The build must link and run the game loop with rendering off, without editing
|
||||
libraries or scattering patches.
|
||||
|
||||
## Decision
|
||||
|
||||
- **The survey's rules decide removals.** `RemovalTransformer` rewrites every reference to a
|
||||
*missing* symbol filed under *delete* or *rewrite*. Existing symbols are never touched; a missing
|
||||
*stub* or *shim* stays a link error. `removed.txt` lists every removal and its rule.
|
||||
- **Deleted features are stripped; rewrites throw.** A call into a deleted feature does nothing and
|
||||
its value is null or zero. A call into code still to be rewritten throws
|
||||
`UnsupportedOperationException`, so unported paths fail loudly. Class literals of removed classes
|
||||
become classes nothing is an instance of.
|
||||
- **`web-classlib` provides stubs and shims**, written fresh from JDK contracts:
|
||||
- `substitutes.<pkg>.T<Name>` replaces `<pkg>.<Name>` (ours win over TeaVM's);
|
||||
- `additions` adds missing methods to TeaVM's classes;
|
||||
- SLF4J binds straight to a console logger;
|
||||
- LWJGL's memory classes over Java arrays (later linear memory, ADR 0008);
|
||||
- LWJGL's `STBImage` as a PNG decoder written for the build, pixel-checked against the JDK's;
|
||||
- the shader include cache's struct as plain memory.
|
||||
- **`java.time` from ThreeTen Backport**, which TeaVM already maps.
|
||||
- **Concurrency follows TeaVM:** threads are coroutines; locks, queues, executors and futures block
|
||||
through monitors and never spin. The worker pool ran inline (until ADR 0015).
|
||||
- **Monitors that guard no suspension are dropped** (`MonitorElision`). Any monitor makes a method a
|
||||
coroutine, and that spreads through virtual calls: one `synchronized toString` made every
|
||||
`toString` a coroutine. In the page, code that can't suspend already runs exclusively, so monitors
|
||||
come off methods that don't wait or block; `lock()` there becomes a non-waiting acquire that fails
|
||||
loudly if held. The accepted risk: a method that blocks only through a virtual call loses a monitor
|
||||
it needed. `async.txt` lists hot methods still compiled as coroutines.
|
||||
- **`ServiceLoader` finds nothing:** service lookups are only for extras the build leaves out.
|
||||
- **TeaVM bugs are fixed in `tools/teavm-patches`**, each meant for upstream.
|
||||
- **Generic superclasses kept only for type capture** (`TypeCaptures`): `TypeToken` subclasses read
|
||||
their type argument at run time.
|
||||
- **Resources come from the client jar at run time** (since ADR 0011, mounted in place).
|
||||
- **Entry-point hooks** for native library loading, the Vulkan check and the render step (off until
|
||||
ADR 0007). The loop yields to the page once per pass (`Platform.endFrame`).
|
||||
|
||||
## Consequences
|
||||
|
||||
- The build links without editing any library; every removal traces to a rule, and changing what
|
||||
the browser keeps is a reviewed change to `rules.txt`.
|
||||
- A stripped feature can hide a null a later caller trips over. Deleted categories (profilers,
|
||||
telemetry, Realms, online-mode crypto) are chosen so that doesn't reach game logic; a crash traced
|
||||
to a stripped reference means a rule is in the wrong category.
|
||||
- `web-classlib` is JDK surface we maintain, tested against the real JDK where possible.
|
||||
@@ -0,0 +1,40 @@
|
||||
# ADR 0007: The WebGL2 backend, under Mojang's frontend, with shaders translated at build time
|
||||
|
||||
- Status: accepted; the unsupported pipelines and the depth range are superseded by
|
||||
[ADR 0012](0012-webgl2-backend-complete-and-screenshot-diffs.md)
|
||||
- Date: 2026-09-27
|
||||
|
||||
## Context
|
||||
|
||||
26.3 draws through `com.mojang.renderpearl`: a validating frontend (`FrontendGpuDevice`) over a
|
||||
backend (`GpuDeviceBackend`: OpenGL or Vulkan). Pipelines compile at run time with shaderc and
|
||||
SPIRV-Cross, native libraries a page doesn't have; compiling them to WebAssembly would add megabytes
|
||||
for work with the same answer every time. WebGL2 also differs in shaders (GLSL ES 3.00) and device
|
||||
features (no mapping, base vertex, multi-draw, per-target blend).
|
||||
|
||||
## Decision
|
||||
|
||||
- **The backend sits under Mojang's frontend:** `render-webgl2` implements `GpuDeviceBackend`, and
|
||||
`WebGl2Backend` wraps it in `FrontendGpuDevice`, so the game's validation stays in front. The
|
||||
device reports what WebGL2 lacks, so the game takes its plain paths.
|
||||
- **Shaders are translated at build time:** `tools/shaders` loads the game's pipeline registry on the
|
||||
build JVM and compiles every distinct stage to GLSL ES 3.00 with shaderc and SPIRV-Cross, set up as
|
||||
the game does. Varyings are renamed by location; blocks and samplers keep the game's names. The
|
||||
result and its reflection go in `shaders.json` beside the page (never in the TeaVM output, never
|
||||
committed).
|
||||
- **glslang checks every program**; `?shaders=eager` links them all in the browser at start-up.
|
||||
- **One hook** (`PipelineCompilingBackend`) lets the backend compile its own pipelines from the
|
||||
manifest, so the frontend never creates shaderc. A resource pack that changes a vanilla shader gets
|
||||
the vanilla translation, with a warning.
|
||||
- **Programs link on first use** (each link costs milliseconds on a Chromebook).
|
||||
- **The game's copy of a buffer is the truth;** writes are uploaded through linear memory.
|
||||
- **Gaps filled in the device:** attributes re-pointed for a base vertex, one shared vertex array,
|
||||
the first target's blend for all, texture views as mip ranges, no timestamps.
|
||||
- At first, 33 of 216 pipelines (texel buffers, indexed fragment outputs) drew nothing; ADR 0012 fixed them.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Most of the render API runs unchanged, and the frontend validates every call before the backend.
|
||||
- Resource packs can't change shaders in the browser.
|
||||
- `tools/shaders` runs game code at build time and fails loudly if a version reaches beyond the
|
||||
minimal platform it installs.
|
||||
@@ -0,0 +1,46 @@
|
||||
# ADR 0008: Off-heap memory in the module's linear memory, and Netty in heap mode
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-27
|
||||
|
||||
## Context
|
||||
|
||||
The game keeps vertex data, images and uniforms off the Java heap through LWJGL's `MemoryUtil`,
|
||||
`MemoryStack` and allocators. The first stand-ins (ADR 0006) used Java arrays, so every write went through a lookup
|
||||
and every upload was copied (a `byte[]` under WebAssembly GC is invisible to JavaScript).
|
||||
|
||||
Netty's buffers didn't start in the page at all: `MethodHandles.lookup()` failed on TeaVM's empty
|
||||
`java.lang.invoke`, the leak detector used reflection, and TeaVM's generated atomic updaters were
|
||||
treated as missing. Networking needs them.
|
||||
|
||||
The original plan was `ArrayBuffer` + `DataView`, but every vertex element would then be a call into
|
||||
JavaScript, where TeaVM's `Address` intrinsics compile to single load/store instructions on the same
|
||||
bytes.
|
||||
|
||||
## Decision
|
||||
|
||||
- **The game's memory users run unchanged;** `web-classlib`'s stand-ins (`TMemoryUtil`,
|
||||
`TMemoryStack`, `TBufferUtils`, `TSTBImage`) sit underneath, over `Heap`. No vendor patch.
|
||||
- **Memory is the module's linear memory:** each allocation is a TeaVM direct buffer, an address is
|
||||
its real offset, reads and writes are single instructions (`LinearMemory`), and views are slices.
|
||||
WebGL uploads read them in place, with no copy.
|
||||
- **Freeing is immediate** (linear memory only grows). `calloc` and `BufferUtils` clear explicitly.
|
||||
- **TeaVM's internal buffer interfaces** are redeclared identically in `web-classlib` so `Heap` can name them.
|
||||
- **The same code runs on a JVM for tests:** `Heap.linear()` picks the backend at compile time; the
|
||||
JVM backend checks bounds and fills `malloc`'d memory with junk.
|
||||
- **Byte parity is tested:** `MemoryParityTest` runs the game's memory users on LWJGL and on the
|
||||
stand-ins and requires every byte to match; a browser probe compares digests.
|
||||
- **Netty runs in heap mode:** unpooled, no `Unsafe`, leak detection off (`LibraryDefaults`). A
|
||||
method-handle lookup that finds nothing makes Netty fall back; leak detector reflection is declared;
|
||||
generated atomic updaters count as present.
|
||||
- **JOML starts:** `joml.format=false` (TeaVM rejects its `DecimalFormat`), and `org.joml.Runtime` is
|
||||
substituted (`Class.forName("java.lang.Float")` fails in TeaVM).
|
||||
|
||||
## Consequences
|
||||
|
||||
- A vertex element costs one store; a mesh upload costs no copy.
|
||||
- Linear memory isn't bounds-checked: a stray write corrupts instead of throwing. The JVM backend
|
||||
and the parity test catch misuse.
|
||||
- Linear memory never shrinks; its high-water mark is the page's.
|
||||
- Netty's adaptive allocator stays unusable; the default is unpooled.
|
||||
- LWJGL's `PointerBuffer` isn't stood in for: nothing the browser runs uses it.
|
||||
@@ -0,0 +1,63 @@
|
||||
# ADR 0009: A WebSocket transport under the game's Connection, one packet per message
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-27
|
||||
|
||||
## Context
|
||||
|
||||
A page can't open TCP sockets; every browser client uses WebSocket. Eagler servers speak WebSocket
|
||||
with one packet per binary message, no length prefix, after an Eagler handshake. The game's
|
||||
connections already run on `PlatformSocketChannel` (ADR 0005). Missing: a WebSocket on each platform,
|
||||
a way to name a WebSocket server, and message framing. Via and the Eagler handshake must fit later.
|
||||
|
||||
## Decision
|
||||
|
||||
- **The platform opens WebSockets:** `PlatformNetwork.openWebSocket(url, listener)` returns the same
|
||||
`NetConnection` as TCP, with message semantics. Desktop: the JDK's `java.net.http.WebSocket`.
|
||||
Browser: the page's `WebSocket`, whose callbacks only queue events, delivered on the game's thread
|
||||
at each poll (a JavaScript callback can't start a coroutine).
|
||||
- **A new module, `:net`**, owns the transport (`NetConnectionChannel`, `WebSocketUrl`,
|
||||
`WebSocketAddress`, `MessageFraming`). Netty and `platform-api` only, no game types.
|
||||
- **Players type a URL:** `ws://` or `wss://`. `ServerAddress` is replaced whole to hold either a TCP
|
||||
host and port or a `WebSocketUrl`. Two hooks: the resolver passes WebSocket addresses through (no
|
||||
DNS or SRV; the block list still applies), and `Connection.connect` hands them to
|
||||
`WebSocketConnections`, which builds the game's own pipeline with message framing. Connect screen,
|
||||
server ping and reconnects work unchanged.
|
||||
- **One packet per message:** `MessageFraming` replaces "splitter" and "prepender" under the same
|
||||
names, so compression and encryption slot in as over TCP. Oversized or empty messages fail.
|
||||
- **Later stages slot in by name:** the Eagler handshake before "splitter"; Via between compression
|
||||
and the codec, as ViaFabricPlus does.
|
||||
- **A development bridge** (`tools/wsbridge`) stands in for an Eagler proxy in front of a vanilla
|
||||
server. Never shipped.
|
||||
- **The browser build keeps Netty's pipeline**, minus the NIO transport. Event loops are local ones
|
||||
on coroutine threads; `web-classlib` adds IP-literal socket addresses, two NIO exceptions, and binds
|
||||
Netty's logger to SLF4J (Log4j's lookup made every exception constructor a coroutine).
|
||||
- **The Eagler handshake belongs in the client**, not a server plugin
|
||||
([`docs/eaglerxserver.md`](../eaglerxserver.md)).
|
||||
|
||||
## Alternatives rejected
|
||||
|
||||
- **TCP's byte stream inside messages:** no Eagler server speaks it.
|
||||
- **Hooking `ConnectScreen`:** would miss the server list ping, and `Connection.connect` loses a URL.
|
||||
- **`java.net.URI`:** not a browser's rules. `WebSocketUrl` accepts exactly what a page's `WebSocket` does.
|
||||
- **A separate channel class:** the address already decides which call opens the connection.
|
||||
|
||||
## Verified
|
||||
|
||||
- **Desktop** (`smokeServer`): ping, join, chat, the Nether and back, a transfer, disconnect and
|
||||
reconnect, over `ws://` through the bridge and over TCP.
|
||||
- **Browser** (`server-join.steps`): join, chat, the Nether and back, a transfer to a `ws://`
|
||||
address, a kick and rejoin. Getting there took about ten TeaVM and build fixes, most with a probe
|
||||
in `app-web/probes/`: coroutine type inference, class initialization order, interrupted `wait()`,
|
||||
`ArrayDeque`'s iterator, `getSuppressed`, Netty handlers' captured generic types, and `Module`.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Online-mode encryption can't pass a proxy that doesn't decrypt (each message would be encrypted
|
||||
alone). Eagler servers run offline mode, so this matches the target.
|
||||
- The legacy server ping (only when a modern one fails) can't reach a WebSocket server.
|
||||
- A transfer packet may name a `ws://` URL as its host, so servers can move browser players.
|
||||
- The bandwidth chart counts packets without TCP's length prefix.
|
||||
- Network events reach the game once per frame, which bounds reading in a throttled hidden tab
|
||||
(ADR 0006's quarter-second fallback keeps the connection alive). Since ADR 0075 a message also
|
||||
wakes the game's thread between frames, and the connection's thread reads it at once.
|
||||
@@ -0,0 +1,45 @@
|
||||
# ADR 0010: Browser input: focus, a text input element, an asynchronous clipboard, dropped files
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-27
|
||||
|
||||
## Context
|
||||
|
||||
The game reads input as SDL3 reports it (ADR 0005). A page gets DOM events instead, and the browser
|
||||
keeps control SDL gives a desktop program: it owns shortcuts like Ctrl+W, allows Pointer Lock and
|
||||
fullscreen only after a gesture, releases the lock on Escape, reads the clipboard only in a paste
|
||||
event or a promise, and gives dropped files as contents, not paths. And a DOM listener can't call
|
||||
into the game (a coroutine can't start from a JavaScript callback).
|
||||
|
||||
## Decision
|
||||
|
||||
- **Every DOM event is queued and drained at the game's poll** (`DomEventQueue`, plain Java). Async
|
||||
APIs report back through the same queue. The only call from a listener into Java is the pure
|
||||
`DomEventQueue.consumesKey`.
|
||||
- **Keys are the game's while it has focus** (canvas, its textarea, or the body). All defaults are
|
||||
cancelled except developer tools, Ctrl+V (for the paste event) and dead keys (for composition). A
|
||||
host page's own controls keep their keys.
|
||||
- **Browser-reserved shortcuts:** Ctrl+W/T/N, Ctrl+1–9 and Ctrl+Q can't be cancelled outside
|
||||
fullscreen. In fullscreen, Keyboard Lock takes them (and Escape pauses; holding it exits). Outside
|
||||
fullscreen, a leave-page prompt guards the tab while the mouse is locked.
|
||||
- **Text through an invisible textarea** while a field wants typing, placed over the field so input
|
||||
method candidates appear there. Ordinary typing still comes from key events; only compositions
|
||||
and keyless text (virtual keyboards, voice) come from the textarea.
|
||||
- **Key names from the Keyboard Map API**, re-read on refocus; learned from typing where it's
|
||||
missing (Firefox, Safari).
|
||||
- **Clipboard never waited on:** Ctrl+V's paste event arrives in the same frame as the key. Writes
|
||||
use the async Clipboard API (or a copy command over plain http) without waiting.
|
||||
- **Pointer Lock asks for raw movement** (`unadjustedMovement`), falling back to a plain lock. Leaving
|
||||
with Escape gives the game the Escape it missed, so it pauses.
|
||||
- **Fullscreen is the canvas's**, always borderless; leaving it from the browser updates the game's option.
|
||||
- **A hidden tab counts as lost focus:** held keys release, pause-on-focus-loss applies.
|
||||
- **Dropped files are copied into `/incari/dropped/<id>/`** and their paths handed to the game's drop
|
||||
handler, so pack screens take them as on the desktop.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Nothing depends on game types; the game-facing side is unchanged from ADR 0005.
|
||||
- Headless Chromium can't show raw movement, Keyboard Lock, input method windows or the leave-page
|
||||
prompt: they're on the manual checklist.
|
||||
- Without `unadjustedMovement` (Firefox, Safari, some Chromium), mouse movement keeps system
|
||||
acceleration, unlike SDL's relative mode.
|
||||
@@ -0,0 +1,65 @@
|
||||
# ADR 0011: Storage: the file system in memory, written behind to OPFS by a worker
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-28
|
||||
|
||||
## Context
|
||||
|
||||
The browser build ran on TeaVM's in-memory file system: a reload lost everything, and the
|
||||
client jar was unpacked on every load (22,844 resources, 86 MB of heap, ~1 s).
|
||||
|
||||
The game's file access is synchronous everywhere; the browser's durable storage (OPFS, IndexedDB)
|
||||
isn't, and OPFS's synchronous handles exist only in workers. Making file calls wait would turn most
|
||||
of the program into coroutines (ADR 0006), and the page's thread may not block on a worker.
|
||||
|
||||
## Decision
|
||||
|
||||
- **The file system is a tree in memory** (`TreeFileSystem`), installed first thing in `WebMain`.
|
||||
Every file call stays synchronous. Where TeaVM differed from the JDK, it follows the JDK
|
||||
(`"rw"` keeps bytes, seeks past the end leave zeros, renames may replace, `/tmp` exists).
|
||||
- **Written behind once a frame:** a `Journal` records shape changes and written byte ranges. At
|
||||
`endFrame` one batch goes out: folders, then writes (new files whole, existing ones only the
|
||||
changed bytes), then deletes. A file rewritten many times is sent once; a temp file renamed into
|
||||
place is never sent under its temp name. No game patches: save points are ordinary writes.
|
||||
- **A storage worker keeps the durable copy** (`storage-worker.js`, run from a Blob URL). OPFS with
|
||||
sync access handles, writing only changed bytes off the page's thread; `createWritable` where sync
|
||||
handles are missing; IndexedDB without OPFS (plain-http pages, older browsers); nothing, with a
|
||||
console note, if neither exists. It loads `/incari` at start-up and hands it to the page.
|
||||
- **One tab writes:** a Web Lock; a second tab keeps its changes to itself and tells the player
|
||||
(`PlatformNotice`, a toast), as it does when there's no storage. The page asks for persistent storage.
|
||||
- **A change the store couldn't keep is sent again whole** (2026-11): the worker stores the rest of
|
||||
the batch and names the failed paths; five seconds later the page marks them changed, so a lost
|
||||
range never leaves a file damaged. A failed save is told to the player once until saving works again.
|
||||
- **Leaving saves singleplayer** (2026-11): the page's own hidden, `beforeunload` and `pagehide`
|
||||
listeners post a save to the world's worker, and in a world the page asks before closing.
|
||||
- **The client jar is cached whole and mounted** read-only at `/incari/classpath` (`ZipArchive`),
|
||||
each entry inflated when opened: one read instead of 22,844, and a 40 MB buffer outside the heap
|
||||
instead of 86 MB in it.
|
||||
- **Not kept:** dropped files, the mounted jar, anything outside `/incari`.
|
||||
- **Files reach the player through the shell:** `PlatformShell.openPath` downloads a file (F2's
|
||||
screenshot link) or opens the file picker for a folder (the pack screens' "Open Pack Folder" becomes import).
|
||||
- **Screenshots encode in the page** (`PngEncoder` behind LWJGL's `STBImageWrite`).
|
||||
- **Fixed on the way:** `MessageDigest` added (Guava's `sha1()` names server icons); TeaVM's
|
||||
`ZipFile` failed at some entries' end (638 textures of a pack); single-byte reads returned signed
|
||||
bytes, so 0x80 read as end-of-file and the server list was lost.
|
||||
|
||||
## Alternatives rejected
|
||||
|
||||
- **Suspending file calls:** most of the game becomes coroutines, and each small write a round trip.
|
||||
- **The page blocking on a worker** (`Atomics.wait`): the page's thread may not block.
|
||||
- **Writing from the page with `createWritable`:** copies the whole file on every close.
|
||||
- **Persisting the unpacked jar:** 22,844 reads every start.
|
||||
- **Flushing only on `pagehide`:** no Java can run there, and async writes started there may not finish.
|
||||
|
||||
## Consequences
|
||||
|
||||
- **A reload can lose** the current frame's writes and a batch not yet applied (milliseconds). An
|
||||
interrupted OPFS batch can be partly applied; IndexedDB batches are whole. A failed change is
|
||||
sent again, whole.
|
||||
- **Everything stored is in memory** (worlds too), until region files stay in place (ADR 0041).
|
||||
- **File times:** OPFS keeps its own; a time the game sets is kept only in IndexedDB. Read-only flags aren't kept.
|
||||
- **Without persistent storage**, the browser may evict data when the disk is nearly full.
|
||||
- The game's profiling-report zip file system is still unsupported.
|
||||
- **Verified** by `storage.steps`, `community-pack.steps`, `screenshot.steps`, the probes
|
||||
`StorageProbe`, `FileReadProbe`, `ZipFileProbe`, and unit tests of the tree, journal, zip reader and
|
||||
worker. Persistence across a browser restart, second tabs and downloads are on the manual checklist.
|
||||
@@ -0,0 +1,72 @@
|
||||
# ADR 0012: Every pipeline in WebGL2, and screenshot diffs against the desktop
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-28
|
||||
|
||||
## Context
|
||||
|
||||
After ADR 0007, 33 of 216 pipelines couldn't run: the clouds read a texel buffer (WebGL2 has none),
|
||||
and the improved-transparency passes index an array of fragment outputs (GLSL ES 3.00 forbids it).
|
||||
And nothing checked that the browser draws what the desktop draws.
|
||||
|
||||
## Decision
|
||||
|
||||
### Every pipeline runs
|
||||
|
||||
`tools/shaders` lists every pipeline the game can make (219 in 26.3, post-effect passes included)
|
||||
and what each needs; all translate and link.
|
||||
|
||||
- **Texel buffers become 2D textures**, 2048 texels wide (element `i` at `(i & 2047, i >> 11)`). The
|
||||
build rewrites `texelFetch` (`EsslRewrites.texelBuffers`); the device re-uploads the texture only
|
||||
when the buffer changed (`TexelBufferTexture`).
|
||||
- **Fragment output arrays become separate outputs**: the shader writes a private array, and a new
|
||||
`main` copies each element out (`EsslRewrites.fragmentOutputArrays`).
|
||||
- **Depth runs 0 to 1 where the browser has EXT_clip_control**, so the game's reversed-Z works as on
|
||||
the desktop; the build translates a second variant of stages that read the depth define. Without
|
||||
the extension, the game's own −1-to-1 path draws the same images with less far-plane precision.
|
||||
- **32-bit float targets fall back to 16-bit** where the browser can't blend 32-bit floats.
|
||||
- **Wireframe** uses WEBGL_polygon_mode where present, else is skipped with one warning.
|
||||
- **Texture uploads read linear memory in place.**
|
||||
|
||||
Atlases, mipmaps, anisotropy, framebuffers, post effects and uniform buffers needed no change.
|
||||
|
||||
### Screenshot diffs (`./gradlew :app-web:screenshotDiff`)
|
||||
|
||||
- **Two games, one script.** Each gets its own vanilla server with a fresh world from one seed. The
|
||||
desktop game (Mojang's OpenGL backend, the reference) is driven over a loopback line protocol
|
||||
(`SceneAgent`); the browser build over DevTools. Both run `scenes.txt`: RCON commands build each
|
||||
scene and place the camera.
|
||||
- **Deterministic.** Worlds are frozen and stepped tick by tick from game time 40, so weather,
|
||||
clouds and animations line up. Built scenes float above y 150. Same options (1280×720, GUI scale 2,
|
||||
FOV 70, render distance 8, HUD hidden). A shot waits for three alike frames 1.5 s apart.
|
||||
- **Compared by SSIM** (RGB mean, 11-pixel Gaussian window, `ImageDiff`), plus the share of pixels
|
||||
over 32/255 apart and a heat map.
|
||||
- **Threshold SSIM ≥ 0.90** for every shot. Correct renders on two drivers score ≥ 0.996; broken ones
|
||||
(unlit terrain, a missing pass, a crash) scored 0.13–0.85.
|
||||
- **The page must stay clean:** any WebGL error, incomplete framebuffer, shader failure or skipped
|
||||
pipeline fails the run.
|
||||
- **Nothing rendered is committed:** shots are pictures of Mojang's assets.
|
||||
|
||||
## Results
|
||||
|
||||
2026-09-28, RX 9060 XT: desktop on Mesa radeonsi, browser on ANGLE's OpenGL over the same driver.
|
||||
14 shots (terrain, translucency with and without improved transparency, entities, particles, sky,
|
||||
GUI, distant terrain, post effects, weather, Nether, End): **SSIM 0.9967–1.0000**, ≤ 0.17% of pixels
|
||||
changed.
|
||||
|
||||
## Consequences
|
||||
|
||||
- **Every vanilla pipeline draws in the browser** with no WebGL errors. The gaps cost little: a
|
||||
texture upload when clouds rebuild, a few moves per fragment in improved-transparency passes.
|
||||
- **The diff found bugs nothing else had:** the End crashed twice (an empty immutable map divided by
|
||||
zero; the dragon's phases lacked reflection metadata); two item pipelines never reached the
|
||||
manifest; uniform ranges were too small for Mesa's layout under ANGLE.
|
||||
- **The GPU matters.** Headless Chromium defaults to SwiftShader; the harness uses the real GPU via
|
||||
ANGLE (`--gpu gl`). SwiftShader (`-Pscreenshots.gpu=swiftshader`, all CI has) renders correctly
|
||||
but scores lower and isn't the gate.
|
||||
- **Needs a display and GPU**; a full run takes about ten minutes.
|
||||
- **For later:** the manifest grew 29.6 → 43.5 kB gzip (the 0-to-1 variants ~10.6 kB could load
|
||||
separately). To measure on a Chromebook: cloud re-uploads, the improved-transparency targets, and
|
||||
whether its GPU has EXT_clip_control.
|
||||
- Read-backs (screenshots) still block on `readPixels`; async is for when something calls them per frame.
|
||||
- Resource packs still can't change shaders in the browser (ADR 0007).
|
||||
@@ -0,0 +1,68 @@
|
||||
# ADR 0013: Sound over Web Audio, with the browser's decoder and the desktop's panning
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-28
|
||||
|
||||
## Context
|
||||
|
||||
The game's sound engine already sits on `PlatformAudio` (ADR 0005), with OpenAL on the desktop. The
|
||||
browser had a silent stand-in. The game expects OpenAL's model: a listener, mono sources placed in
|
||||
the world with a distance model, gain, pitch, looping, one-shot buffers and queued streams, 255
|
||||
sources.
|
||||
|
||||
The game decodes Ogg Vorbis itself (JOrbis). On the page that would run on the only thread and cost
|
||||
frames for every new sound and every second of music. Browsers decode Ogg natively, but
|
||||
`decodeAudioData` decodes whole files only (70 MB of floats for a 3-minute track). And a page can't
|
||||
play sound until the player clicks or presses a key.
|
||||
|
||||
## Decision
|
||||
|
||||
- **Web Audio implements `PlatformAudio`**: one `AudioContext`; each source is a small graph with a
|
||||
gain per ear. **Panning comes from `Spatializer`**, plain Java that runs OpenAL Soft's own model,
|
||||
not Web Audio's `PannerNode`, so each ear hears what it would on the desktop.
|
||||
- **The desktop's model, measured:** `:platform-desktop:openAlReference` records OpenAL Soft's mix to
|
||||
a WAV at known positions. For stereo without HRTF, each ear gets `0.5 ± 0.5·right + 0.0957·front`
|
||||
of the attenuated gain (ahead 0.596 per ear, behind 0.404). `SpatializerTest` holds the browser
|
||||
within 0.003.
|
||||
- **The browser decodes, off the page's thread.** `PlatformAudio.decoder()` (optional) is
|
||||
`decodeAudioData`. `PlatformSoundLoading` hooks the game's sound buffer library; three loader
|
||||
threads decode and cache as the game would. The desktop has no decoder and keeps the game's path;
|
||||
a file the browser can't decode falls back to it too.
|
||||
- **Streams play compressed:** music and records go to a media element feeding the same graph
|
||||
(pitch as `playbackRate`), so a track costs its file, never its decoded samples. The game's
|
||||
buffer-queue path stays for anything else.
|
||||
- **OpenAL semantics over one-shot nodes:** a `PlaybackClock` per source handles pause, resume,
|
||||
position and looping. 255 sources, as OpenAL Soft.
|
||||
- **Gains change only when needed**, smoothed over 5 ms while playing. Re-panning every frame allocates nothing.
|
||||
- **Directional Audio (HRTF)** uses the browser's HRTF panner, which differs from OpenAL Soft's data set.
|
||||
- **Autoplay unlock:** a small "Click or press a key to turn on sound" prompt until the first
|
||||
gesture. Until then one-shot sounds are dropped (so title clicks don't pile up) and streams wait.
|
||||
JavaScript callbacks only set flags; only the decoder's promise calls Java.
|
||||
- **Sounds are fetched when first played:** the page writes the sound list and an empty placeholder
|
||||
per sound; on first play `RemoteSounds` fetches the real file. Resource pack sounds are read normally.
|
||||
- `javax.sound.sampled.AudioFormat` (description only) is in `web-classlib`.
|
||||
|
||||
## Deviations from the desktop
|
||||
|
||||
- No output limiter: loud stacks clip instead of being limited.
|
||||
- No output device choice.
|
||||
- Sound starts after the first click or key press, as on every web page.
|
||||
- Decoded sounds take about twice the desktop's memory (32-bit floats at output rate).
|
||||
- A sound's first play waits for its download.
|
||||
|
||||
## Alternatives rejected
|
||||
|
||||
- **`PannerNode`:** equal-power panning ignores front and back and makes listener-relative sounds
|
||||
(UI, music) 1.5 dB louder than the desktop.
|
||||
- **JOrbis in the page:** on the only thread; frames drop on every new sound.
|
||||
- **WebCodecs with an Ogg demuxer:** a demuxer to maintain and patchy Vorbis support; the media
|
||||
element does it natively.
|
||||
- **A worker for decoding:** `decodeAudioData` is already off-thread.
|
||||
- **Downloading every sound at start:** 360 MB, mostly never played.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Positional sound, UI, music and records work in the browser. `audio.steps` checks the unlock and
|
||||
streaming; `audio-positional.steps` matches the desktop's panning and fade within 1%.
|
||||
- What needs ears (HRTF, jukeboxes, long sessions) is on the manual checklist.
|
||||
- Where Safari refuses an Ogg file, the game's decoder takes over for that sound.
|
||||
@@ -0,0 +1,44 @@
|
||||
# ADR 0014: The loader page, the build manifest, the service worker and the asset pack
|
||||
|
||||
- Status: accepted; the JavaScript fallback and the manifest's `wasm`/`js` entries are superseded by
|
||||
ADR 0036 (Fast and Compatible builds, manifest format 2)
|
||||
- Date: 2026-09-28
|
||||
|
||||
## Context
|
||||
|
||||
The page was a stub: it fetched the whole module (29 MB gzip) every visit, showed nothing useful
|
||||
while doing so, and gave no reason when a browser couldn't run it.
|
||||
|
||||
What a player's browser downloads falls into three groups (ADR 0001): the **build** (the module and
|
||||
what's prepared at build time; contains Mojang code, so it's self-hosted, never published by the
|
||||
project), **Mojang's files** (client jar, asset index, sounds), and **the page**.
|
||||
|
||||
## Decision
|
||||
|
||||
- **The page is a loader** (`index.html`, `boot.ts`): a loading screen with a progress bar and the
|
||||
current step. It checks the browser (`features.ts`), reads the manifest, picks a build, registers
|
||||
the service worker, downloads with byte counts, and starts the game, which reports its own steps
|
||||
through `window.incariLoader`. Failures stop with a sentence the player can act on.
|
||||
- **TypeScript compiled by stripping types** (Node's `stripTypeScriptTypes`, `:app-web:pageScripts`):
|
||||
erasable syntax only, no bundler.
|
||||
- **`build.json`** lists the game version, release flag, targets, the asset pack, and every file's
|
||||
size and SHA-256. Files are requested as `name?v=<hash>`.
|
||||
- **Streaming compile with progress:** the module compiles while it downloads.
|
||||
- **A service worker** (`sw.ts`, `cache-policy.ts`) caches versioned build files and sounds: a
|
||||
returning player downloads only what changed. The page and its starting files come from the network
|
||||
with a cached fallback, so play works offline. The client jar passes through (the storage worker
|
||||
keeps it). `?sw=off` unregisters it.
|
||||
- **The asset pack** (`incari.pack`): build-time data for the game (shaders, later sprites and Via's
|
||||
mappings), mounted read-only at `/incari-pack` like the jar. Never published.
|
||||
- **Release builds:** `-Pteavm.release` (TeaVM ADVANCED, obfuscated, no debug data). Strict null
|
||||
checks stay on: the game catches `NullPointerException`, and without them a null dereference traps.
|
||||
- **The dev server serves the page by name**, so editing it needs no recompile.
|
||||
|
||||
## Consequences
|
||||
|
||||
- A returning player downloads only changes. On the desktop a dev build starts in ~0.7 s from a local
|
||||
server; Chromebook loads wait for the device.
|
||||
- Browsers without module workers run uncached, with a warning.
|
||||
- The JavaScript fallback built and ran (60 fps standing, 36–44 fps in fresh terrain), but was later
|
||||
dropped for the Fast and Compatible builds (ADR 0036).
|
||||
- `serve`, `browserCheck`, `screenshotDiff` and `checkDownloadSize` build the page and pack too.
|
||||
@@ -0,0 +1,45 @@
|
||||
# ADR 0015: The background pool runs between frames, and the render thread's waits are counted
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-28
|
||||
|
||||
## Context
|
||||
|
||||
The web platform reported no background threads, so the game's worker pool ran every task inline,
|
||||
usually on the render thread mid-frame. Terrain meshing resubmits itself until the backlog is empty,
|
||||
so one `schedule` meshed everything before the frame went on: turning in fresh terrain gave 38 fps
|
||||
with frames up to 950 ms.
|
||||
|
||||
This is also the audit of blocking calls: a wait on the render thread holds the frame for as long
|
||||
as it lasts, and deadlocks if what it waits for can only run on the render thread.
|
||||
|
||||
## Decision
|
||||
|
||||
- **The platform may run the game's pool:** `PlatformThreads.backgroundExecutor(name)` (null on the
|
||||
desktop, which keeps `ForkJoinPool`). The existing `Util.makeExecutor` hook takes it.
|
||||
- **In the page the pool runs between frames** (`IdleTimeExecutor`): tasks queue; one coroutine runs
|
||||
them in slots that start after the frame is drawn and end 2 ms before the next is due (at least
|
||||
4 ms). A started task runs to its end. A thread waiting on a queued task waits for the next slot,
|
||||
which comes even in a hidden tab (within a quarter second), so nothing deadlocks.
|
||||
- **Render-thread waits are counted:** the frame monitor (`window.__incariFrames`) times each frame;
|
||||
if the animation-frame callback returns before the frame ends, the render thread waited. Every
|
||||
`Object.wait` is routed through `Waits`, which adds render-thread waits to the frame's total and
|
||||
prints the stack of any wait ≥ 50 ms.
|
||||
- **The build lists every blocking call** (`blocking.txt`), classified in
|
||||
[`docs/threading.md`](../threading.md).
|
||||
- **The gate:** `soak.steps`, 30 minutes on a server, fresh terrain every minute, turning full
|
||||
circle; fails on any frame with ≥ 50 ms of render-thread waiting.
|
||||
|
||||
## Results
|
||||
|
||||
- **Gate passed** (2026-09-29, release build): 108,244 frames at 60 fps; longest wait total 32 ms,
|
||||
no frame over 50 ms. Fixed on the way: slots that started during a short wait made it wait for a
|
||||
whole task, and the frame limiter's skipped frames were counted as waits.
|
||||
- Arriving in fresh terrain holds 59 fps (worst frame 50 ms); turning there 59 fps (worst 33 ms).
|
||||
|
||||
## Consequences
|
||||
|
||||
- Background work gets only the time frames leave: with full frames, the pool gets 4 ms and terrain
|
||||
appears more slowly rather than frames dropping. Workers (ADR 0023) add throughput.
|
||||
- Resource reloads run on the pool too, so the loading screen animates.
|
||||
- The frame monitor and wait tracing stay on in every build (a timestamp per frame and per wait).
|
||||
@@ -0,0 +1,61 @@
|
||||
# ADR 0016: The Eagler handshake in the client, and Eagler skins
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-29
|
||||
|
||||
## Context
|
||||
|
||||
Every browser-reachable Minecraft server today is an Eagler server: EaglerXServer in front of
|
||||
ordinary backends, nearly all 1.8. Its first binary message opens Eagler's own login exchange (a
|
||||
vanilla handshake is closed silently); after it, the proxy logs the player in and carries vanilla
|
||||
packets one per message (ADR 0009's framing). Protocol V5 accepts any Minecraft protocol number, so
|
||||
the handshake belongs in the client ([`docs/eaglerxserver.md`](../eaglerxserver.md)).
|
||||
|
||||
Eagler servers also answer the server list with a text MOTD query and move skins in their own
|
||||
messages. Gate: join a stock EaglerXServer 1.8 network with skins both ways. EaglerXServer is All
|
||||
Rights Reserved: written from the wire protocol only.
|
||||
|
||||
## Decision
|
||||
|
||||
- **Every `ws://`/`wss://` server speaks Eagler.** `EaglerHandshake` sits at the pipeline's head,
|
||||
below framing, and runs V5 when the channel opens. It swallows the game's handshake and Login Start
|
||||
(the proxy already logged in), then answers with a Login Success in the connection's protocol
|
||||
layout (and swallows Login Acknowledged from 1.20.2, holding backend packets until then). A refusal
|
||||
becomes a Login Disconnect, shown as the kick reason.
|
||||
- **The protocol named is the server's:** with Via above, it's the version Via translates to.
|
||||
- **Eagler's own messages** (`0xEE`, bundled `0xEE 0xFF`) go to an `EaglerSession`.
|
||||
- **Server list MOTD:** WebSockets gain text messages. A hook in `ServerStatusPinger.pingServer`
|
||||
sends `Accept: motd` (`EaglerPings`) and fills the entry: MOTD, counts, names, and the 64×64 icon.
|
||||
An Incari extension field `data.protocol` is read when present; otherwise the server is taken as 1.8.
|
||||
- **Skins:** the player's own is sent at login (`skin_v2`, `cape_v1`; chosen on Edit Profile since
|
||||
ADR 0029). Others' are asked for by UUID the first time they're drawn (`EaglerSkins`, a hook in
|
||||
`PlayerInfo`), registered as `incari:eagler/...` textures, released on disconnect. Invalidations and
|
||||
forced skins are honoured.
|
||||
- **Formats** (`EaglerTextures`): skins 64×64 at 3 bytes a pixel (alpha as one bit), capes a 22×17
|
||||
region plus 11 pixels. Checked byte for byte against EaglerXServer's converters with a local
|
||||
program (nothing of its jar committed).
|
||||
- **Presets:** Eagler's skins 0 and 1 show as Steve and Alex; the rest (Eagler's art, not shipped) as
|
||||
one of the game's default skins. Preset capes (Mojang's) aren't drawn; custom capes are.
|
||||
- **`tools/wsbridge` speaks Eagler** in front of a vanilla server: MOTD, V5 handshake, login over
|
||||
TCP, compression, then bridging.
|
||||
- **Later:** passwords, voice, cookies, redirects, capabilities.
|
||||
|
||||
## Alternatives rejected
|
||||
|
||||
- **An EaglerXServer add-on:** needs each server's operator.
|
||||
- **Eagler only for marked addresses:** no WebSocket Minecraft server isn't Eagler.
|
||||
- **Answering the login before the game asks:** the game's login listener isn't ready yet.
|
||||
- **Drawing Eagler's preset skins:** not Incari's art to ship.
|
||||
|
||||
## Verified
|
||||
|
||||
- **Desktop** against EaglerXServer 1.1.1 on BungeeCord, in front of vanilla 1.8.9: `smokeServer`
|
||||
pings, joins through Via, chats, moves, stays 20 s, reconnects. `smokeSkinA` + `smokeSkinB`: each
|
||||
sees the other's exact skin, model and cape. Against the bridge: 26.3, 1.20.4, 1.12.2, 1.8.9 pass.
|
||||
- **Browser:** `server-join.steps` and `version-join.steps` pass.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Eagler servers show their MOTD, counts and icon; the version reads "Eagler 1.8.x" or what they name.
|
||||
- `wss://` works as far as the platform's WebSocket does.
|
||||
- The bridge now closes with a proper close frame (an abrupt drop showed as error 1006).
|
||||
@@ -0,0 +1,57 @@
|
||||
# ADR 0017: Via in the client, and choosing a server's version
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-29
|
||||
|
||||
## Context
|
||||
|
||||
The game speaks only 26.3's protocol. Players want mostly 1.8 servers (nearly every Eagler server),
|
||||
then 1.12, then modern ones. ViaVersion and its companions translate packet by packet as a Netty
|
||||
stage, as ViaFabricPlus does in-client. Goal: Via under TeaVM, version detection with a manual
|
||||
override, and 1.8, 1.12, 1.20 and 26.3 servers joining and playing.
|
||||
|
||||
## Decision
|
||||
|
||||
- **A new module, `:via`**: Netty and Via, no game types. ViaVersion and ViaBackwards 5.12.0,
|
||||
unmodified, from `repo.viaversion.com`.
|
||||
- **ViaVersion covers every older server** (1.8–26.2): "a newer client on an older server" is its
|
||||
job. **ViaBackwards** only for servers newer than the game, loaded on first need. **No ViaRewind**
|
||||
(for old *clients* on new servers). Pre-1.8 would need ViaLegacy; left until needed.
|
||||
- **The platform** (`IncariVia`): a version provider per connection. Settings live in memory (no
|
||||
update checks, 1.8 idle movement packets, no rate limits); no YAML. Via starts on the first join
|
||||
that needs it, on the connector thread, never blocking the network thread.
|
||||
- **The pipeline** (`ViaPipeline`): `via-decoder` after "splitter", `via-encoder` after
|
||||
"prepender", so compression lands correctly; the Eagler stage stays below and speaks the server's
|
||||
version. `via-relay` defers packets Via releases synchronously inside the game's own write (for
|
||||
pre-1.20.2 servers), which otherwise met a pipeline with no outbound protocol.
|
||||
- **Choosing the version:** a "Version" button on each server's edit screen ("Auto" or a release),
|
||||
saved in `servers.dat`. (How "Auto" resolves was replaced by ADR 0018: join as the game's version
|
||||
and read the refusal.)
|
||||
- **The server list** counts servers Via can reach as compatible.
|
||||
- **In the browser:** Via compiles in like any library; its mappings (0.3 MB compressed) ride in
|
||||
the asset pack. Build help: Via's bundled `TypeToken` joins `TypeCaptures`, `PipelineUtil` is
|
||||
substituted, SnakeYAML is stripped, `Collections.unmodifiableSortedSet` added (probes for each).
|
||||
- **Licensing is open:** Via is GPLv3 without Incari's Minecraft exception (ADR 0002). The repo
|
||||
holds no Via code, and building locally distributes nothing; the project distributes no build
|
||||
with Via until it's settled.
|
||||
|
||||
## Alternatives rejected
|
||||
|
||||
- **ViaLoader:** pulls in ViaLegacy, ViaBedrock and ViaAprilFools; the part needed is a hundred lines.
|
||||
- **Via's YAML configs:** a parser and file writes for settings no player edits.
|
||||
- **Detecting an Eagler server's version from the handshake:** V5 accepts anything; only the backend knows.
|
||||
- **One Via stage for both directions:** the game's handlers aren't neighbours, and compression is
|
||||
placed by the framing names.
|
||||
|
||||
## Verified
|
||||
|
||||
- **Desktop** (`smokeServer`, behind the bridge): 1.8.9, 1.12.2, 1.20.4 join through Via, chat, move,
|
||||
stay 20 s, reconnect; 26.3 without Via. 1.8.9 over plain TCP too. Via starts in ~150 ms.
|
||||
- **Browser** (`version-join.steps`): the same three versions and stock EaglerXServer with a 1.8.9
|
||||
backend: join, chat, 20 s, kick, rejoin. Via starts in ~30 ms.
|
||||
|
||||
## Consequences
|
||||
|
||||
- A wrongly detected version gets the server's own "outdated client" message; the Version button fixes it.
|
||||
- The 1.8 behaviour layer (ADR 0020) builds on the known version (`ServerConnections.lastJoinedProtocol`).
|
||||
- Every packet to an older server costs Via's translation on the network thread.
|
||||
@@ -0,0 +1,48 @@
|
||||
# ADR 0018: "Auto" finds a server's version by joining
|
||||
|
||||
- Status: accepted (amended by ADR 0071: Via is off by default)
|
||||
- Date: 2026-09-29
|
||||
|
||||
## Context
|
||||
|
||||
ADR 0017's "Auto" took any Eagler server that doesn't name its version as 1.8. Nothing an Eagler
|
||||
server says before login names it (the MOTD has none; the handshake accepts anything), so every
|
||||
non-1.8 Eagler server was joined as 1.8 and refused. BungeeCord over TCP has the same problem.
|
||||
|
||||
What servers do say, reliably, is why they refuse, in words: "Outdated server! I'm still on 1.8.8",
|
||||
"Incompatible client! Please use 1.20.4", BungeeCord's "Kicked whilst connecting to lobby: …".
|
||||
|
||||
## Decision
|
||||
|
||||
- **"Auto" joins as**, in order: the player's choice; the version that last reached the world at
|
||||
this address (`incari/learned-versions.txt`); the version the server reports; else the game's own.
|
||||
- **Refusals are read** (`VersionRetry`, one hook in `DisconnectedScreen.init`): release numbers in
|
||||
the text and its translation arguments map to protocols through Via. The newest version below the
|
||||
refused one is tried next (older only if nothing older is named), never one already tried. Only
|
||||
within a minute of connecting, only for "Auto", at most four joins.
|
||||
- **A silent drop is a hint:** EaglerXServer on BungeeCord closes without a word when the proxy
|
||||
can't carry the protocol. A close during the Eagler login (`droppedDuringLogin`) makes "Auto" try
|
||||
1.8 next, then 1.12.2; a newer backend refuses 1.8 by name, which the next retry reads. Not
|
||||
when the dropped version already reached the world at this address: a rejoin right after a kick
|
||||
is often dropped while the old session lingers, and a multi-version server would accept the 1.8
|
||||
guess and teach it for good (Carrotcraft). Only a refusal in words corrects a learned version.
|
||||
- **Only a join that reaches the world is remembered.** A stale one is refused and corrected,
|
||||
except on a server that accepts every version: a wrong one sticks there, so the drop rule above
|
||||
guards it. `server-versions.txt`, which builds up to 0.1.2 could fill that way, is deleted once.
|
||||
|
||||
## Alternatives rejected
|
||||
|
||||
- **Keeping 1.8 as the Eagler default:** wrong for every non-1.8 server.
|
||||
- **Probing versions in parallel:** each probe is a full login, visible to the server, and looks like an attack.
|
||||
- **Trying every release newest-first:** up to fifty logins, where a refusal names the version in one.
|
||||
|
||||
## Consequences
|
||||
|
||||
- **Verified** against EaglerXServer 1.1.1 on BungeeCord: with a 1.8.9 backend, 26.3 is dropped,
|
||||
"Auto" tries 1.8, joins, and remembers it. With a 1.20.4 backend, 26.3 dropped, 1.8 refused naming
|
||||
1.20.4, then 1.20.4 tried.
|
||||
- That last join fails outside the client: EaglerXServer 1.1.1 on BungeeCord carries protocols only
|
||||
up to 1.18.2 here. Modern Eagler networks need Velocity.
|
||||
- The first join to such a 1.8 server costs one dropped login (~10 s); later joins use the learned version.
|
||||
- A kick message that mentions a version and a refusal word triggers a retry; the minute window
|
||||
and four-join cap stop loops.
|
||||
@@ -0,0 +1,67 @@
|
||||
# ADR 0019: Eagler's extras: passwords, cookies, redirects, voice chat and shared worlds
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-29
|
||||
|
||||
## Context
|
||||
|
||||
Joining an Eagler server (ADR 0016) left out EaglerXServer's extras: handshake passwords, login
|
||||
cookies, redirects, WebRTC voice chat, and worlds shared through a relay. Gate: voice chat and
|
||||
auth-plugin servers work.
|
||||
|
||||
Two kinds of auth: **most Eagler servers log players in on the backend** with plugins like AuthMe
|
||||
(`/login` in chat), which needs only chat and commands. **EaglerXServer's handshake auth** asks for a
|
||||
password before the player reaches any server; it's in the protocol but uncommon. Neither is a
|
||||
Mojang account.
|
||||
|
||||
EaglerXServer and Eagler's clients are All Rights Reserved: everything here is written from the wire
|
||||
protocol. Local test doubles (an auth plugin, the relay jar) live under `run/` and are never committed.
|
||||
|
||||
## Decision
|
||||
|
||||
- **Handshake passwords** (`EaglerPassword`, `EaglerAuth`, `PasswordScreen`): the server names a
|
||||
method and salt; the client answers `EAGLER_SHA256`, `AUTHME_SHA256`
|
||||
(`hex(sha256(hex(sha256(password)) + salt))`), or plain text only after the player agrees. A
|
||||
refusal for a missing password shows the password screen, which joins again (`JoinFailures`).
|
||||
Passwords stay in memory for the session, by server URL; never on disk.
|
||||
- **Cookies** (`EaglerCookies`): a server's cookie (≤ 255 bytes, ≤ a week) is sent with the next
|
||||
login to the same URL. The server chooses whether it's saved (`incari/eagler-cookies.txt`).
|
||||
- **Redirects:** a redirect to a `ws://`/`wss://` address joins it with "Auto"; others are refused.
|
||||
- **Voice chat** (`EaglerVoice`, `Platform.rtc()`; browser only): the server only signals (who has
|
||||
voice on, pairing, offers, answers, ICE). Each peer gets an audio transceiver up front and the mic
|
||||
track is swapped in once granted, so the permission prompt never forces renegotiation. Voices play
|
||||
through the game's audio context with a gain and stereo pan set each tick (proximity: linear fade
|
||||
and direction; global: fixed). Push to talk on B. Voice starts off; choosing a channel shares the
|
||||
microphone. Controls are in the pause menu's voice panel (ADR 0045); the HUD lists who's talking.
|
||||
- **Joining shared worlds** (`incari.net.relay`, `RelayScreen`): "Shared..." on the multiplayer screen
|
||||
takes a relay URL and code. `RelayJoin` negotiates a WebRTC data channel through the relay, which
|
||||
becomes the game's connection with Eagler's LAN framing (`LanFraming`) and login (`LanLogin`), under
|
||||
Via at 1.8, since Eaglercraft hosts are 1.8. Hosting came later (ADR 0062).
|
||||
- **Capabilities** asked at login: cookies and redirects always; voice where WebRTC exists.
|
||||
|
||||
## Alternatives rejected
|
||||
|
||||
- **Storing passwords or hashes on disk:** cookies are the servers' own "remember me", and a stored
|
||||
hash is as good as the password.
|
||||
- **An audio element per voice with `PannerNode`:** voices share the game's context and listener,
|
||||
with one gain each for mutes and fades.
|
||||
- **WebRTC on the desktop:** it's the development runtime; voice and shared worlds are checked in the browser.
|
||||
|
||||
## Verified
|
||||
|
||||
- **Handshake auth** (`smokeAuth`) against EaglerXServer 1.1.1 with a local test plugin: both hashed
|
||||
methods accepted, the cookie saved, and the next join logged in by cookie alone. Hashes match
|
||||
independent vectors in `EaglerHandshakeTest`. Plain text is unit-tested only.
|
||||
- **Voice** (`voice-talker.steps` + `voice-listener.steps`, two headless Chromiums with fake mics):
|
||||
paired, connected, and the listener hears the talker. Signalling also on the desktop (`smokeVoiceA`
|
||||
+ `smokeVoiceB`). Fixed on the way: the answering side now adopts the offer's transceiver.
|
||||
- **Shared worlds** (`relay-join.steps`) against EaglerSPRelay and a stand-in host page: the channel
|
||||
opens, the host gets the Eagler login, the client reaches the world.
|
||||
|
||||
## Consequences
|
||||
|
||||
- **In-game `/login` plugins (the common case) aren't checked yet.** They need only chat and
|
||||
commands, but a check with AuthMe on the local 1.8.9 server should run before the gate counts.
|
||||
- Redirects are unit-tested only; no redirecting server was at hand.
|
||||
- The desktop has no voice or shared worlds; its screens say so.
|
||||
- The talking indicator holds 0.6 s after the last loud moment.
|
||||
@@ -0,0 +1,52 @@
|
||||
# ADR 0020: The legacy behaviour layer: playing 1.8 servers as 1.8 did
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-29
|
||||
|
||||
## Context
|
||||
|
||||
Via translates packets but can't change how the client moves, aims and collides. A 1.8 server
|
||||
simulates the player by 1.8's rules: sneaking under a slab, a thicker ladder or a taller lily pad
|
||||
gets corrected (rubber-banding) or flagged by anticheat. And 1.8 PvP means no attack cooldown, sword
|
||||
blocking, and a swing before each attack.
|
||||
|
||||
ViaFabricPlus is the reference, but it's GPL-3.0 without Incari's Minecraft exception, so nothing of
|
||||
it is used: the behaviour is written fresh from what 1.8 does. Gate: side-by-side recordings with a
|
||||
real 1.8.9 client.
|
||||
|
||||
## Decision
|
||||
|
||||
- **Everything keys off the server's version** (`LegacyRules`, from
|
||||
`ServerConnections.lastJoinedProtocol`, updated once a tick). Plain static fields, cheap on hot paths.
|
||||
- **Combat on 1.8** (`LegacyCombat`):
|
||||
- no attack cooldown (strength always 1, no indicator);
|
||||
- **sword blocking:** swords become usable like shields with the `BLOCK` animation; Via turns the
|
||||
use into 1.8's block and the server halves damage. 26.3 already draws the 1.8 pose;
|
||||
- the swing sent before attacking or digging;
|
||||
- a 0.1 pick margin around entities.
|
||||
- **Movement and poses** (`LegacyPlayer`, `LegacyMovement`): sneaking keeps a 1.8-high box with eyes
|
||||
at 1.54 (1.65 high for 1.9–1.13), for every player so hitboxes match; no swimming or crawling before
|
||||
1.13; on 1.8 each axis of motion under 0.005 a tick stops.
|
||||
- **Block shapes on 1.8** (`LegacyShapes`, one pair of hooks in `BlockStateBase`): ladders 2/16
|
||||
thick; lily pads full 1/64 squares; glass panes and bars as 1.8's arms; anvils full height, 12/16
|
||||
wide; farmland a full block. Unchanged shapes aren't touched.
|
||||
- **Fishing rods and bows** need nothing: the server and Via handle them.
|
||||
|
||||
## Alternatives rejected
|
||||
|
||||
- **Porting ViaFabricPlus:** its licence, and its fixes are mixins against other mappings.
|
||||
- **Hooks per block class:** more hooks for the same result.
|
||||
- **A `blocks_attacks` component on swords:** it's the server's, and would show in tooltips and be
|
||||
sent back in creative.
|
||||
|
||||
## Consequences
|
||||
|
||||
- **Verified against a real 1.8.9 server** (`smokeLegacy`): rules follow protocol 47; pick margin
|
||||
0.1; full strength after a swing; 1.54 sneak eyes; a server-placed ladder collides at 2/16; and
|
||||
blocking halves an arrow as 1.8 does ((1 + d) / 2: 3.0 open, 2.0 blocking). Singleplayer and current
|
||||
servers are unchanged.
|
||||
- **The gate isn't met as written:** no recordings beside a real 1.8.9 client yet. Feel (knockback,
|
||||
hit registration, strafing) still needs that session with a PvP player.
|
||||
- Not changed yet: creative reach, red hurt armour, hurt tilt, the offhand. Each is a small hook.
|
||||
- Rules are per version group: 1.9–1.13 get the sneak height (and to 1.12 no swim pose), but not
|
||||
1.9's own changes.
|
||||
@@ -0,0 +1,70 @@
|
||||
# ADR 0021: The profiler, the benchmark and the performance gate
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-29
|
||||
|
||||
## Context
|
||||
|
||||
The goal is 60 fps at render distance 8 on a 4 GB Chromebook. Every change must show what it
|
||||
did, on the same scenes, and regressions must be caught before merge. That needs an
|
||||
in-game overlay, a fixed benchmark world with scripted scenes, a runner for real Chromebooks, and a
|
||||
CI report per pull request that fails on regressions.
|
||||
|
||||
## Decision
|
||||
|
||||
### Measuring a frame
|
||||
|
||||
- **The game's own profiler zones are the timers.** One hook (`Minecraft.run`) wraps the game's
|
||||
`ProfilerFiller` with Incari's `FrameProfiler` while collecting; it times the two outer zone levels
|
||||
and allocates nothing. Nothing collecting: the frame is untouched.
|
||||
- **Split:** *tick*, *extract* (`update`, `extract`), *render* (handing the frame to the backend:
|
||||
every WebGL call), and *GPU*.
|
||||
- **GPU time** from EXT_disjoint_timer_query_webgl2 (`GpuTimer`), a frame or two late; unknown (not
|
||||
zero) without the extension. The backend also counts draws, terrain draws and sections
|
||||
(`GpuFrameStats`). The desktop's Mojang backends report these as unknown.
|
||||
- **`PlatformProfiling`:** memory (JVM heap on the desktop; JavaScript heap and linear memory in the
|
||||
browser), each frame, and start-up marks. The page keeps the last 16384 frames in
|
||||
`window.__incariFrames`.
|
||||
- **1% low** is the frame rate over the slowest 1% of frames (their mean), so stutters show.
|
||||
|
||||
### The overlay
|
||||
|
||||
F9 (rebindable) or `?overlay`: FPS and 1% low, the frame split, draws, mesh queue, memory, GC, and a
|
||||
frame-time graph. Text rebuilt 4x a second.
|
||||
|
||||
### The benchmark (`./gradlew :app-web:benchmark`)
|
||||
|
||||
- **Fixed world:** the screenshot harness's server, fixed seed, time and spawning stopped, every
|
||||
chunk pre-generated so scenes measure client loading.
|
||||
- **Scripted scenes** (`benchmark.txt`): the player spectates an armor stand the server moves.
|
||||
`flythrough` (55 s east at 11 blocks/s over unseen terrain), `combat` (golems vs raiders, 40 s).
|
||||
- **Loads:** cold start (cleared origin), warm start, join.
|
||||
- **Figures** (`FrameStats`, `GcStats`): FPS, 1% low, p99 frame, tick/extract/render/GPU, draws,
|
||||
sections, mesh queue, memory, GC pauses from a DevTools trace. Chromium runs with precise memory info.
|
||||
- **Gate** (`PerfBaseline`, `baseline.properties`): per machine, per figure, a direction and an
|
||||
allowed worsening (percentage *and* absolute). Past it fails. `-Pbenchmark.updateBaseline` records.
|
||||
- **Report:** Markdown and JSON, plus history in `~/.incari/benchmark-history.jsonl` and trend charts.
|
||||
|
||||
### Real Chromebooks
|
||||
|
||||
The runner drives any Chrome over DevTools (`--connect`), serving the page from this machine
|
||||
(`--page-host`). A Chromebook in developer mode exposes remote debugging through SSH
|
||||
([`docs/benchmark.md`](../benchmark.md)). No Playwright: it uses the same protocol and can't drive a
|
||||
stock Chromebook either, and `tools/webbuild` already has a DevTools client.
|
||||
|
||||
### Every pull request
|
||||
|
||||
Hosted runners can't compile the browser build (20 GB heap) and their software GPU gives meaningless
|
||||
times, so CI's `perf` job runs on a self-hosted runner labelled `incari-perf` once
|
||||
`INCARI_PERF_RUNNER` is set. It compiles, measures, and writes the report to the job summary; a
|
||||
regression fails. Nothing is uploaded. Never for fork pull requests.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Two three-line hooks (`Minecraft.run`, `Gui`); the rest is `incari.client.profiler` and
|
||||
`incari.platform.api.profile`.
|
||||
- Figures are per machine. Until a Chromebook is recorded, the gate protects the desktop's figures:
|
||||
it catches regressions in work done, not the floor device's margins.
|
||||
- On SwiftShader GPU time is unknown, but draw counts still gate.
|
||||
- Players pay nothing until they press F9.
|
||||
- The CI job waits for someone to register the runner.
|
||||
@@ -0,0 +1,59 @@
|
||||
# ADR 0022: Terrain in a few multi-draws a frame
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-29
|
||||
|
||||
## Context
|
||||
|
||||
Every WebGL call crosses from WebAssembly into JavaScript and is validated; on a Chromebook that
|
||||
overhead, not the GPU, limits drawing. Terrain is most draws: each section's layer cost about eight
|
||||
WebGL calls (uniforms, re-pointing attributes because WebGL2 has no base vertex, the index buffer,
|
||||
the draw).
|
||||
|
||||
The 26.x renderer already keeps sections in shared heaps (`UberGpuBuffer`), culls with the occlusion
|
||||
graph, groups by layer and heap, and on capable devices submits each group as one indirect draw with
|
||||
per-instance section data. WebGL2 lacks indirect draws, base vertex and base instance, but has
|
||||
`WEBGL_multi_draw` (many ranges in one call, told apart by `gl_DrawID`).
|
||||
|
||||
## Decision
|
||||
|
||||
- **Claim indirect multi-draws and base instance where `WEBGL_multi_draw` exists**, so the game takes
|
||||
its indirect terrain path. `?multidraw=off` turns it off.
|
||||
- **Run indirect draws from the game's copy of the command buffer** (every buffer has one, ADR 0007).
|
||||
- **Base vertex goes into the indices:** the backend keeps a 32-bit quad index pattern
|
||||
(`QuadIndices`) where quad `v / 4` already counts from vertex `v`, so a section draws from an
|
||||
offset with no base vertex. A heap is one `multiDrawElementsWEBGL`; sections at a vertex not a
|
||||
multiple of four take one extra call per remainder. At most four calls per heap's layer.
|
||||
- **Base instance becomes `gl_DrawID`:** terrain vertex shaders are rewritten to read per-section
|
||||
data (16 bytes) from row `gl_DrawID` of a uniform block (`DrawIdRewrite`), filled per batch from a
|
||||
ring (`DrawRows`).
|
||||
- **Translucent indices are rebased and kept** (`RebasedIndices`): each sorted section's indices are
|
||||
copied with the base vertex added, and kept until the game re-sorts it (tracked per 4 KiB page).
|
||||
Copying them every frame had cost more than it saved.
|
||||
|
||||
## Results
|
||||
|
||||
Desktop, render distance 8, three alternating runs each:
|
||||
|
||||
| | Fly-through off | on | Combat off | on |
|
||||
| --- | ---: | ---: | ---: | ---: |
|
||||
| Terrain draw calls | 553 | 9 | 513 | 9 |
|
||||
| All draw calls | 629 | 85 | 591 | 87 |
|
||||
| Render submit (ms) | 1.2 | 1.1 | 1.6 | 1.1 |
|
||||
|
||||
Terrain calls fell ~60x, past the tenfold target. The desktop holds 60 fps either way; render submit
|
||||
falls a third in combat. On a Chromebook, where calls cost more, that's what matters.
|
||||
|
||||
Found on the way: a TeaVM heap bug (whole-page allocation after an exactly full heap) fixed in
|
||||
`tools/teavm-patches`; and new typed-array views per multi-draw caused 290–370 ms GCs until views
|
||||
were kept.
|
||||
|
||||
## Consequences
|
||||
|
||||
- The quad index buffer costs 24 bytes per quad of the fullest heap (a fifth of the vertices).
|
||||
- Per-section uniform rebinding and attribute re-pointing are gone.
|
||||
- Re-sorted translucent sections are copied again when they change (a handful a frame in water).
|
||||
- Without `WEBGL_multi_draw`, terrain draws as before.
|
||||
- This relies on how the game draws terrain (indirect only for terrain, one instance each, the quad
|
||||
pattern). Pipelines that break it skip their draws and say so; a changed pattern falls back to a
|
||||
draw per section.
|
||||
@@ -0,0 +1,76 @@
|
||||
# ADR 0023: Terrain meshed in Web Workers by Incari's own mesher
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-30
|
||||
|
||||
## Context
|
||||
|
||||
Meshing terrain (`SectionCompiler.compile`: models, culling, light, fluids, visibility, translucent
|
||||
sorting) is the game's heaviest recurring job. In the page it runs between frames (ADR 0015), so
|
||||
terrain gets only the time frames leave; the fly-through's 1% low was 31 fps because of it.
|
||||
|
||||
The plan: a small WebAssembly mesher in a worker pool, flat snapshots in a
|
||||
`SharedArrayBuffer` (or transferred buffers), a compact vertex format, and sorting in the worker.
|
||||
Gate: no meshing on the main thread, no chunk-load stutter. The catch: a worker can't touch game
|
||||
objects, and the picture must not change.
|
||||
|
||||
## Decision
|
||||
|
||||
### An exact mesher of Incari's own
|
||||
|
||||
- **`:mesher`** has no dependencies. A `Snapshot` (block ids, light, tints, per-position shapes for a
|
||||
section and two blocks around it) plus `MeshTables` (every state and model) go into `SectionMesher`,
|
||||
which writes exactly what the game's compiler writes: culling and skip rules, smooth or flat
|
||||
lighting with the game's quirks, tints, emission, fluids, visibility, sorted translucency. Written
|
||||
fresh, not copied.
|
||||
- **Tables are read from the game, never assumed** (`MeshTableExport`): flags, light, shapes, skip
|
||||
rules, fluid heights, plant offsets and every baked quad. How a model picks parts is discovered by
|
||||
running it with a recording random source. States that don't fit are marked unsupported (none in
|
||||
26.3). The mesher's copies of the game's hash, random and table trig are checked against the game's.
|
||||
- **Checked byte for byte:** `-Dincari.mesher=verify` meshes every section both ways; `smokeMesher`
|
||||
covers ten overworld places, the Nether, the End and the debug world, with smooth lighting and
|
||||
cutout leaves on and off: 17,763 sections, none different.
|
||||
|
||||
### In the page
|
||||
|
||||
- **Compiled alone:** `mesher.wasm` (~120 KB, 123 classes), run in one worker per core but one, up to four.
|
||||
- **Messages are bytes:** tables once (~11 MB), a ~25 KB snapshot per compile, centers per re-sort.
|
||||
Copied through a `SharedArrayBuffer` slot when cross-origin isolated, else a transferred
|
||||
`ArrayBuffer`. The answer goes straight into the section's buffer pack.
|
||||
- **The game's dispatcher is unchanged:** hooks in compile and re-sort call `Meshing`. A mesh the
|
||||
render thread needs at once (a block the player changed) is meshed in place by the same mesher.
|
||||
- **Several meshes in flight:** a pool task waiting for a worker steps aside so another can run
|
||||
(`IdleTimeExecutor.awaitOutside`). Buffer packs start at 64 KB, not 8.8 MB.
|
||||
- **Snapshots never hold up a frame:** filling one takes 5–10 ms, so it calls
|
||||
`PlatformThreads.pauseIfLate()` per layer and resumes in the next slot.
|
||||
- **Slots end before the next frame:** the slot deadline only learns from frame steps near one
|
||||
interval (skipped frames had pulled it toward 33 ms).
|
||||
- **Compact vertices:** 16 bytes instead of 28 (position and light in four shorts, colour, UVs in two
|
||||
shorts exact for power-of-two atlases). `TerrainVertexFormat` and `CompactTerrainRewrite` decode
|
||||
them in the shaders. The desktop keeps the game's format.
|
||||
- **Options:** `?mesher=inline` (on the page's thread), `?mesher=vanilla` (the game's compiler),
|
||||
`?mesher=verify`.
|
||||
|
||||
## Results
|
||||
|
||||
Fly-through, desktop, vs `?mesher=vanilla`:
|
||||
|
||||
| | Workers | Game's compiler |
|
||||
| --- | ---: | ---: |
|
||||
| 1% low | 38–41 fps | 31.9 fps |
|
||||
| p99 frame | 21.6–24.5 ms | 28.3 ms |
|
||||
| Mesh queue, mean | 6.2 | 9.8 |
|
||||
| Linear memory peak | 565 MB | 657 MB |
|
||||
| Slowest frames' pool work between frames | ~1 ms | 25.2 ms |
|
||||
|
||||
What's left in the slowest frames is the game's tick (chunk packets, light), as in combat, which
|
||||
loads no terrain.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Meshing leaves the main thread; only copying the snapshot and the finished mesh stays.
|
||||
- The mesher follows the game: changes in a new version show up in `smokeMesher`, and the arithmetic
|
||||
check fails loudly.
|
||||
- Building the tables takes ~2 s in the page per world or reload: joins take about a second longer
|
||||
(until ADR 0032 kept them).
|
||||
- The desktop meshes with the game's compiler unless asked (`-Dincari.mesher=incari`).
|
||||
@@ -0,0 +1,68 @@
|
||||
# ADR 0024: Entities, particles and text
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-09-30
|
||||
|
||||
## Context
|
||||
|
||||
A crowded lobby is where browser clients fall apart. The plan: entity occlusion culling,
|
||||
instanced entity models, batched text, GUI and signs, and pooled, capped particles, gated on a
|
||||
crowded-lobby benchmark.
|
||||
|
||||
The new `lobby` scenario: 80 armored mannequins with names, 24 hologram armor stands, 12 text
|
||||
displays, 30 dropped items, signs, a sidebar, a boss bar and three particle fountains, from an
|
||||
orbiting camera. Before this work its profile was mostly particles (~7 of 16 busy seconds), then text
|
||||
(1.4 s), entity models (1.3 s) and entity ticks.
|
||||
|
||||
The 26.x renderer already batches draws (one staged buffer, one range per render type; the GUI merges
|
||||
elements). What's left is CPU work per vertex, glyph and particle, and entities drawn nobody can see.
|
||||
|
||||
## Decision
|
||||
|
||||
- **Entity occlusion culling** (`EntityOcclusion`): skip an entity in the frustum if none of the
|
||||
sections its box touches was reached by the terrain occlusion graph. Never culled: players,
|
||||
glowing entities, visible names, text displays, leashed entities, the camera's entity. A few array
|
||||
lookups, no allocation. `?entityculling=off`.
|
||||
- **Instanced entity models** (`ModelBatches`, page only, `?instancing=off`):
|
||||
- A model's cubes are baked once into a vertex buffer (`ModelMesh`).
|
||||
- Per instance the CPU runs `setupAnim` and walks the part tree with the game's own transforms:
|
||||
one matrix per part (hidden parts collapse to zero).
|
||||
- One instanced draw per render type and model; rows in a 1024-row uniform block.
|
||||
- A copy of the entity pipeline whose vertex shader the backend rewrites to apply the part
|
||||
transform (`EntityInstanceRewrite`).
|
||||
- Only solid-phase models with the entity shader; translucent, outlined, crumbling or remapped
|
||||
(armor trims) models go the game's way. `ModelMeshTest` checks the arithmetic.
|
||||
- **Text, GUI and signs:** the game's batching stays. `VertexMath` overrides `BufferBuilder`'s pose
|
||||
transforms with the same arithmetic minus the per-vertex vector allocation: bit-identical.
|
||||
- **Particles:**
|
||||
- **Caps per tier** (`ParticleBudget`): 2048 / 8192 / 16384 (Potato / Standard / High), with the
|
||||
game's admission curve scaled (all admitted until three quarters full). `?particles=`.
|
||||
- **No per-particle allocation:** the camera rotation is reused, turned corners are kept while the
|
||||
rotation holds, and light is read once per block per frame (`ParticleScratch`, `ParticleQuads`,
|
||||
`ParticleLight`). Bit-identical.
|
||||
|
||||
## Results
|
||||
|
||||
Desktop:
|
||||
|
||||
| | Before | After |
|
||||
| --- | ---: | ---: |
|
||||
| Lobby 1% low | 40.2 fps | 38.4–44.6 fps |
|
||||
| Lobby p99 frame | 22.9 ms | 21.9 ms |
|
||||
| Lobby extract / render submit | 2.0 / 3.4 ms | 1.9 / 2.4 ms |
|
||||
| Combat extract + render submit | 2.1 ms | 1.4 ms |
|
||||
| Lobby particle CPU (41 s profile) | 5.07 s | 4.18 s |
|
||||
|
||||
The desktop holds 60 fps either way; the floor device is where this should show.
|
||||
|
||||
- Instancing takes armor (and mobs, armor stands in play). The mannequins' bodies stay the game's:
|
||||
skins are translucent with a texture each (taken later by ADR 0027's opaque skins).
|
||||
- Culling saves nothing in the lobby (everything is in sight); it's for ordinary play.
|
||||
|
||||
## Consequences
|
||||
|
||||
- An entity hidden behind terrain costs nothing to extract, animate or draw.
|
||||
- New or changed models need nothing: meshes are baked from the game's parts on first draw.
|
||||
- If a game version changes the entity shader's `Position` or `Normal` inputs, the instanced copy
|
||||
fails to compile and those models fall back to the game's way: slower, never missing.
|
||||
- Particle tiers change what's seen only past three quarters of a group's cap.
|
||||
@@ -0,0 +1,74 @@
|
||||
# ADR 0025: The memory diet
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-01
|
||||
|
||||
## Context
|
||||
|
||||
A 4 GB Chromebook gives a tab far less than the 1–2 GB the client uses on a desktop, and running
|
||||
out kills the tab. Done when the benchmark's heap is under budget with no GC pause over 16 ms.
|
||||
|
||||
There was no heap budget yet, and the benchmark only reported peaks (which include uncollected
|
||||
garbage). Measured first on the desktop: **1016 MB live JavaScript heap at the title screen**, ~1.1 GB
|
||||
in a world, and 565 MB of linear memory. The desktop JVM holds 250 MB at the same title screen.
|
||||
|
||||
## Decision
|
||||
|
||||
### Measuring
|
||||
|
||||
- **Live figures:** after the title screen and each scenario, the benchmark forces a GC and reads the
|
||||
JavaScript heap (`heapLiveMB`) and linear memory in use (`nativeLiveMB`, counted by `Heap`).
|
||||
- **What holds memory:** `-Pbenchmark.heapProfile`, `-Pbenchmark.heapSnapshot`, and
|
||||
`-Pbenchmark.desktopJfr`, which plays the scenarios on the desktop under Flight Recorder to see
|
||||
allocation sites (the browser's tools can't see inside WebAssembly).
|
||||
- **Budgets** (`budgets.properties`): absolute limits; over budget fails regardless of baseline.
|
||||
Memory budgets apply to every machine.
|
||||
- **Measure the release build**, which players get (a dev build also holds 92 MB of TeaVM's deobfuscator).
|
||||
|
||||
### Where memory went
|
||||
|
||||
| Change | What |
|
||||
| --- | --- |
|
||||
| Data fixer built only when needed (`incari.client.datafix`) | The game builds every schema since 2013 at start-up, plus a discarded development check. The page passes current data through a stand-in and builds the real fixer only for old data. Most of the title-screen heap, and 2.1 s of start-up |
|
||||
| Terrain heaps sized by tier (`TerrainHeaps`) | The game reserves 128 MB vertex + 32 MB index heaps per layer and 98 MB of staging: 540 MB of GPU memory, mirrored in linear memory. Now 32/8 MB at Standard (16/4 at Potato), staging 16 MB; a full heap gets another, costing one more multi-draw |
|
||||
| Draw-only buffers keep no copy (`WebGl2Buffer`) | Large, never-mapped vertex buffers write straight to WebGL. A read-back still works, with a warning |
|
||||
| Block states share equal data (`BlockStateSharing`) | Occlusion face arrays and sturdy-face tables are interned (a few hundred kinds among 35,000 states). `BlockStateSharingTest` checks every state |
|
||||
| Decoded sounds budgeted (`DecodedSoundBudget`) | 16 / 32 / 96 MB by tier; the oldest leave the cache and decode again when replayed |
|
||||
| Atlases capped by tier (`AtlasBudget`) | 2048 / 4096 / GPU limit. An atlas that doesn't fit halves its sprites' resolution (alpha-weighted) until it does. Vanilla fits every tier |
|
||||
| `DeviceTier` | One setting for all the budgets above and the particle cap. The page takes Standard (or `?tier=`); the desktop High |
|
||||
|
||||
Found on the way: TeaVM's unmodifiable collections scanned every element, making model loading
|
||||
quadratic (fixed in `TCollections`).
|
||||
|
||||
### Allocations in hot paths
|
||||
|
||||
GC counts showed where (the lobby collected 8x a second) and desktop JFR showed what:
|
||||
|
||||
- **World text laid out every frame** → `TextLayouts` caches up to 2048 layouts keyed by content,
|
||||
style and position (not obfuscated text). `TextLayoutsTest`.
|
||||
- **Five vectors per item quad** → `VertexMath` writes with two reused vectors, bit-identical (`VertexMathTest`).
|
||||
- **`ChunkSectionLayer.values()` copied per section per frame** → one shared array.
|
||||
|
||||
The lobby's render thread allocated 37 GB over 40 s before, 23 GB after. What's left would mean
|
||||
restructuring the game's renderer, and causes no long pauses.
|
||||
|
||||
## Results
|
||||
|
||||
Desktop, release build, 2026-10-01, live figures after a forced GC:
|
||||
|
||||
| | Before | After |
|
||||
| --- | ---: | ---: |
|
||||
| JavaScript heap, title screen | 1016 MB | 255–265 MB |
|
||||
| JavaScript heap, in a world | ~1.1 GB | 337–356 MB |
|
||||
| Linear memory, peak | 565 MB | 74 MB |
|
||||
| Longest GC pause | 5.2–7.3 ms | 1.8–5.5 ms |
|
||||
|
||||
Every scenario still runs at ~60 fps and within budget. Screenshot diffs 14/14.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Memory budgets are enforced: over 320 MB live at the title, 420 MB in a world, 128 MB of linear
|
||||
memory, or a 16 ms GC pause fails `:app-web:benchmark`.
|
||||
- An old world or options file pays to build the data fixer when first read.
|
||||
- A draw-only buffer read back logs a warning: a new caller to look at.
|
||||
- The Chromebook's heap should match; its pauses and times wait for the device.
|
||||
@@ -0,0 +1,70 @@
|
||||
# ADR 0026: Start-up
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-01
|
||||
|
||||
## Context
|
||||
|
||||
The plan: pre-build what can be pre-built, cache processed state, stream the compile, defer what the
|
||||
title screen doesn't need. Done when a warm start hits a time budget (set here, since none had been set
|
||||
without the Chromebook).
|
||||
|
||||
Measured first (desktop, development build): cold start 10.5 s, warm 8.7 s. The warm start's profile
|
||||
(`-Pbenchmark.profile` now records one):
|
||||
|
||||
| What | Time |
|
||||
| --- | ---: |
|
||||
| Data fixer (removed by ADR 0025) | 2.1 s + GC |
|
||||
| Loading screen fade after everything loaded | 2.0 s |
|
||||
| Block state definitions and models | 1.5 s |
|
||||
| Bootstrap: block state shape caches | 1.1 s |
|
||||
| Atlases: decode, stitch, mip | 0.6 s |
|
||||
| Model discovery lookups (TeaVM scanned maps) | 0.27 s |
|
||||
| Copying the module through the loader's byte counter | 0.25 s |
|
||||
| Interface type checks over long tag-range lists | 0.24 s |
|
||||
|
||||
The benchmark now splits a warm start: to the first frame, to the end of the first reload, and the fade.
|
||||
|
||||
## Decision
|
||||
|
||||
- **Models load after the title screen** (`DeferredModels`): the first resource reload skips the
|
||||
model manager and entity/block-entity dispatchers; a second reload runs them once the title is up.
|
||||
Joining while they load shows "Loading Minecraft" until done. A later reload runs everything
|
||||
together, as the game does. Page only (`-Pincari.browserStartup` tries it on the desktop).
|
||||
- **Vanilla sprites decoded at build time** (`tools/sprites`, `SpriteCache`): 3142 sprites with their
|
||||
mip levels, ~1.06 MB in the asset pack, kept in OPFS. The page uses them instead of decoding PNGs;
|
||||
pack and animated sprites go the game's way. `SpritesTest` compares every byte.
|
||||
- **Block state answers once per shape** (`BlockStateSharing`): support answers depend only on the
|
||||
shape, which most of the 35,000 states share. A build-time registry snapshot would have to rebuild
|
||||
`VoxelShape` identities, for less gain.
|
||||
- **No copy through the loader:** a module the service worker already has goes straight to the
|
||||
browser's compiler instead of through a byte-counting stream.
|
||||
- **Faster fade** (`LoadingFade`): half a second, not two.
|
||||
- **TeaVM fixes:** unmodifiable collections ask the wrapped collection (`TCollections`); interface
|
||||
type checks binary-search their tag ranges (`WasmGCSupertypeFunctionGenerator`).
|
||||
|
||||
Not done: **pre-built baked models**. Models no longer delay the title, and serializing the model
|
||||
graphs would need a format kept in step with every game version, to save time a join mostly spends
|
||||
on the network.
|
||||
|
||||
## Results
|
||||
|
||||
Desktop, 2026-10-01 (before: development build; after: release build, now what's measured):
|
||||
|
||||
| | Before | After |
|
||||
| --- | ---: | ---: |
|
||||
| Warm start to title | 8.7 s | 2.1 s (first frame 1.1 s, reload done 1.6 s) |
|
||||
| Cold start to title | 10.5 s | 2.9 s |
|
||||
| Join the benchmark server | 11.4 s | 5.1 s |
|
||||
|
||||
Desktop budgets (3.0 s warm, 4.5 s cold) hold; the Chromebook's (10 s, 20 s) are estimates.
|
||||
|
||||
The pre-built sprites first drew blocks blank: TeaVM's absolute `ByteBuffer.put` copied nothing when
|
||||
the source had no `remaining()`. Fixed in `TByteBuffer`; screenshot diffs 14/14 again.
|
||||
|
||||
## Consequences
|
||||
|
||||
- The first join after start-up may wait for models. `?models=now` and `?sprites=off` turn the two
|
||||
changes off to compare.
|
||||
- `sprites.bin` is rebuilt with the game; a stale or missing copy costs time, not correctness.
|
||||
- The Chromebook's time budgets wait for the device.
|
||||
@@ -0,0 +1,73 @@
|
||||
# ADR 0027: Performance follow-ups: the compile, the backend's calls, and the game's own costs
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-01
|
||||
|
||||
## Context
|
||||
|
||||
After ADRs 0021–0026 the desktop holds 60 fps everywhere, but a 4 GB Chromebook has about a fifth of its
|
||||
single-thread speed and a GPU 30–60x slower. A review of profiles and code found costs nothing
|
||||
had covered yet: in the compile, the WebGL2 backend's calls, and the game's own logic. Every change is
|
||||
exact and has an off switch.
|
||||
|
||||
## Decision
|
||||
|
||||
| Area | Change | Off switch |
|
||||
| --- | --- | --- |
|
||||
| Compile | JOML's `HAS_Math_fma` is a constant `false` (as on the desktop), so `Math.fma` folds and inlines. It was the lobby's top self time (5.6%) | — |
|
||||
| Compile | Fewer coroutines: untimed queue `offer`/`poll` no longer count as blocking; two always-complete `join()`s became `resultNow()`; a `forEach` became a loop | — |
|
||||
| Backend | Uniform writes are uploaded once per buffer range before the next draw (`PendingUploads`) | `?uniforms=each` |
|
||||
| Backend | Quad draws read the backend's quad indices from `vertexOffset / 4`, so attributes stay bound | `?rebase=off` |
|
||||
| Backend | Re-sorted translucent indices are copied in place, not appended | — |
|
||||
| Backend | Uploads use kept views of linear memory, not a new typed array each (`Staging`, `WebWorkerPool`) | — |
|
||||
| Game | Translucent quads sorted by radix sort, same permutation as the game's stable sort (`QuadSort`) | `?sort=game` |
|
||||
| Game | Snapshots read light a section at a time (`SnapshotLight`) | `-Dincari.mesher.lightByBlock` |
|
||||
| Game | Biome tints reuse the row's previous samples, bit-exact (`TintBlend`, page only) | `?tint=game` |
|
||||
| Instancing | Plain items drawn instanced (`ModelBatches.takeItem`) | `?items=game` |
|
||||
| Instancing | Skins with all-or-nothing alpha and an opaque tint draw in the solid phase, so instancing takes them (`OpaqueSkins`, page only) | `?skins=game` |
|
||||
|
||||
Why some of these matter:
|
||||
|
||||
- **The upload views:** TeaVM wraps each JavaScript object that reaches Java in a `WeakMap`. Thousands
|
||||
of per-upload views piled up as ephemerons, and some GC pauses spent 33–36 ms marking them. Now
|
||||
≤ 0.2 ms.
|
||||
- **Opaque skins:** a texture with no partial alpha never blends, so drawing it before translucent
|
||||
models gives the same picture (only exactly equal depths could differ).
|
||||
- **Coroutines:** the hot-method list didn't shrink. TeaVM's flow analysis merges everything through
|
||||
shared library code, so a blocking thread body makes every `Runnable.run` a coroutine. `async.txt`
|
||||
now opens with a per-package coroutine count. The real fix needs TeaVM changes (later: the Fast
|
||||
build, ADR 0036).
|
||||
|
||||
**Tools:** `-Pbenchmark.cpuThrottle=<n>` (a CPU stand-in for a Chromebook) and
|
||||
`-Pbenchmark.gcTrace` (collector events per scenario).
|
||||
|
||||
## Not done
|
||||
|
||||
- **Skipping ambient-particle biome lookups outside the Nether:** exact and cut the tick 30–40%,
|
||||
but the page allocating less triggered V8's memory reducer: heap-shrinking pauses of 11–26 ms.
|
||||
Left out (ADR 0031 later did it differently).
|
||||
- **The integrated server in a worker:** its own piece of work (later ADR 0039).
|
||||
|
||||
## Results
|
||||
|
||||
Development desktop, release build, 2026-10-01 (it holds 60 fps either way):
|
||||
|
||||
| | Before | After |
|
||||
| --- | ---: | ---: |
|
||||
| Lobby render submit (ms) | 9.9 | 8.4 |
|
||||
| Lobby p99 frame (ms) | 22.9 | 21.7 |
|
||||
| Fly-through longest GC pause (ms) | 5.5 | 3.5–8.8 |
|
||||
| Fly-through live heap (MB) | 350 | 356 |
|
||||
|
||||
Items and skins instanced, lobby: render submit 8.4 → 6.5 ms, draws 132 → 97.
|
||||
|
||||
`async.txt`: 63% of reachable methods compile as coroutines. Correctness: screenshot diffs 14/14,
|
||||
`smokeMesher` (18,060 sections) clean, `QuadSortTest`, `TintBlendTest`.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Six more vendor patches.
|
||||
- The coroutine count is worth guarding.
|
||||
- `TintBlend` trusts that biome changes invalidate the game's tint caches (true in 26.3).
|
||||
- A JavaScript object handed to Java on a hot path costs a weak-map entry: keep views, as
|
||||
`Staging`, `DrawRows` and `WebWorkerPool` do.
|
||||
@@ -0,0 +1,37 @@
|
||||
# ADR 0028: The web folder (`./incari build`)
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-01
|
||||
|
||||
## Context
|
||||
|
||||
The goal: `incari build` writes a web folder and an offline HTML file, on Windows, macOS and
|
||||
Linux. Until now a build ran only through the localhost dev server.
|
||||
|
||||
Every build contains Mojang's code, so the project never publishes one (ADR 0001, 0014). Once the
|
||||
source is public, people will build anyway. They need a supported way to host their own build, and
|
||||
a plain statement, wherever builds are seen, that they mustn't be shared.
|
||||
|
||||
## Decision
|
||||
|
||||
- **`./incari build [--out <dir>] [--only fast|compatible] [--no-sounds]`** (`WebBuild`) fetches
|
||||
sounds if missing, compiles the release builds, and runs `:app-web:webFolder`. Default output
|
||||
`dist/web/` (ignored). An output git would track is refused.
|
||||
- **`WebFolder`** copies only what the page fetches (build files, page, manifest, pack, the jar's
|
||||
resources, sounds) and writes its own `build.json` over exactly those.
|
||||
- **It only replaces what it wrote** (`.incari-web-folder` marker); a folder with other files is refused.
|
||||
- **The notice travels with the build:** `README.txt` starts "DO NOT SHARE, UPLOAD OR PUBLISH THIS
|
||||
FOLDER" and explains why; `./incari build` prints it; [`docs/self-hosting.md`](../self-hosting.md)
|
||||
is the project's statement.
|
||||
- **Server set-up is documented, not required:** relative URLs; `.htaccess` for Apache, nginx and
|
||||
Caddy snippets in `README.txt`. Without isolation headers, workers copy instead of sharing; over
|
||||
plain HTTP, no service worker and IndexedDB storage.
|
||||
|
||||
(The original `--js` option went with the JavaScript fallback, ADR 0036.)
|
||||
|
||||
## Consequences
|
||||
|
||||
- A release build replaces the development one in `app-web/build/`.
|
||||
- The offline HTML file came later (ADR 0057).
|
||||
- Via's licensing question (ADR 0002) is unchanged: hosting your own build is easier; publishing
|
||||
one stays forbidden.
|
||||
@@ -0,0 +1,34 @@
|
||||
# ADR 0029: Edit Profile
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-01
|
||||
|
||||
## Context
|
||||
|
||||
Eagler clients open an "Edit Profile" screen at load: a username, a skin from a dropdown beside a
|
||||
preview, Add Skin and Clear List, and a Capes link. Eagler players know it, and nearly every Eagler
|
||||
server is offline-mode, so that name is the player's identity. Incari took the name only from the
|
||||
launch (`?name=`, `--username`), and skins from a bare "Eagler Skin..." screen.
|
||||
|
||||
## Decision
|
||||
|
||||
- **The name is answered at `Minecraft.getUser`** (one hook, `PlayerName`), so the login, Eagler
|
||||
handshake, singleplayer, relay and voice all use it, with the matching offline UUID. Only offline
|
||||
launches; a real account keeps its name.
|
||||
- **3–16 letters, digits or underscores**, as Eagler requires; Done stays off until valid. Kept in
|
||||
`incari/profile.properties`.
|
||||
- **The screen opens at start-up** after the game's first-run screens, unless the entry point names
|
||||
the player (`?name=`, `?server=`, tests, `-Pincari.username`). The web suggests `Player` + three
|
||||
digits. Reopened from a title-screen link or the skin customisation screen. Locked in a world.
|
||||
- **Skin list:** the game's nine default skins in both models, then the player's added PNGs
|
||||
(`incari/skin/library/`; slim or wide read from the image). Add Skin uses the file picker, Clear
|
||||
List removes added ones, the cape has its own screen. "Eagler Skin..." is gone.
|
||||
- **Your own skin shows everywhere**, singleplayer and vanilla servers included.
|
||||
- **The preview is vanilla's `PlayerSkinWidget`** (draggable); in the browser it shows "..." until
|
||||
models load after the title (ADR 0026).
|
||||
|
||||
## Consequences
|
||||
|
||||
- Three new hooks plus one retargeted.
|
||||
- A different name is a different offline UUID, so singleplayer inventories are per name.
|
||||
- Not done: Eagler's profile Import/Export, and a cape on the preview.
|
||||
@@ -0,0 +1,86 @@
|
||||
# ADR 0030: Ideas from the Java optimization mods: draw lists, facing culling, sprite animation
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-02
|
||||
|
||||
## Context
|
||||
|
||||
The floor device has about a fifth of the desktop's CPU and a GPU 30–60x slower. We surveyed the
|
||||
Java optimization mods (Sodium, Lithium, ImmediatelyFast, FerriteCore, ModernFix, EntityCulling,
|
||||
MoreCulling, Exordium, Enhanced Block Entities) for ideas not yet taken. Their licenses
|
||||
rule out their code, so everything here is written fresh from what each mod does.
|
||||
|
||||
Flight Recorder on the desktop showed the render thread spending 65% of the fly-through (21% of
|
||||
combat) rebuilding the terrain draw list every frame, a third of that in hash lookups. And the
|
||||
blocks atlas animates ~41 sprites a tick into 5 mip levels: ~67 draws a frame, where the whole
|
||||
fly-through frame was 80.
|
||||
|
||||
## Decision
|
||||
|
||||
Six changes, each with a page option that restores the game's way. The first four draw exactly the
|
||||
game's picture; the HUD texture and meshed chests differ slightly, which was accepted.
|
||||
|
||||
| Change | Idea from | Off switch | Exact? |
|
||||
| --- | --- | --- | --- |
|
||||
| Terrain draw list kept between frames | Sodium | `?drawlists=game` | Yes |
|
||||
| Back-facing quad runs left out | Sodium | `?faces=all` | Yes |
|
||||
| Only visible animated sprites redrawn | Sodium | `?animations=all` | Yes |
|
||||
| No threading checks on one thread | Lithium | — | Yes |
|
||||
| HUD kept in a texture between refreshes | Exordium | `?hud=live` | Rounds one 8-bit step; lags ≤ one refresh |
|
||||
| Closed chests meshed into terrain | Enhanced Block Entities | `?chests=game` | Shading within one step; mipmapped; no break cracks |
|
||||
|
||||
- **Draw lists** (`SectionDraws`, `TerrainDrawLists`): each section mesh keeps its draws per layer,
|
||||
re-read only when `UberGpuBuffer` moves its allocation. The frame's list is written straight into
|
||||
two reused buffers, same groups and order as the game's, with no object per section. The desktop
|
||||
uses it too.
|
||||
- **Facing culling** (`incari.mesher.Facings`): the mesher groups solid and cutout quads by the
|
||||
axis-aligned direction they face (others unassigned). The draw list skips runs the camera can't
|
||||
see the front of (with a 3-block margin) and merges neighbours. The pipelines cull back faces
|
||||
anyway, so the picture is identical. `smokeMesher` checks the grouping (18,120 sections, none differ).
|
||||
- **Animated sprites** (`AnimatedSprites`): meshes record which animated sprites they use; anything
|
||||
else that draws one notes it. Every animation still ticks, but only sprites drawn this or last
|
||||
frame get new frames. A sprite coming back into view is caught up before terrain draws. When
|
||||
terrain's sprites are unknown, everything animates as in the game.
|
||||
- **Threading checks:** `ThreadingDetector`'s lock and semaphore are skipped where
|
||||
`PlatformThreads.oneThread()` (the page): one thread can't race itself.
|
||||
- **HUD texture** (`HudCache`): with no screen open, the camera overlays and crosshair stay live;
|
||||
everything above them is drawn into a texture every 50 ms (Standard) or 66 ms (Potato), never at
|
||||
High, and blended over each frame. It only kicks in while frames come faster than refreshes
|
||||
(otherwise it would only add a pass). Between refreshes, nothing above the split is extracted.
|
||||
- **Chests** (`ChestBaking`): a chest closed now and last tick is posed by its own renderer and its
|
||||
quads are written into the section's cutout layer; the game no longer draws it as a block
|
||||
entity. Chest textures join the blocks atlas; directional entity lighting is baked into vertex
|
||||
colour. Opening re-meshes the section without it; it's meshed back 11 ticks after closing. Page only.
|
||||
|
||||
`?drawcensus` logs each pipeline's draws every 600 frames; that's how the animations' share was found.
|
||||
|
||||
## Results
|
||||
|
||||
Development desktop, release build, 2026-10-02. Draws a frame:
|
||||
|
||||
| | Off | On |
|
||||
| --- | ---: | ---: |
|
||||
| Fly-through | 80 | 18.5 |
|
||||
| Combat | 84 | 17.8 |
|
||||
| Lobby (CPU ÷4) | 238 | 31 |
|
||||
|
||||
- Unthrottled: render submit 0.88–0.90 ms vs 0.94–2.21 off; GPU 0.60 vs 0.72 ms.
|
||||
- CPU throttled 4x: fly-through tick 2.9 vs 3.1 ms, GPU 0.50 vs 0.57; combat GPU 0.51 vs 0.77; lobby
|
||||
tick 13.9 vs 15.5. FPS within noise: WebGL calls are cheap on the desktop. The floor device,
|
||||
where each call and the GPU cost more, should gain most.
|
||||
- HUD texture in the lobby: extract 2.1 vs 2.2 ms, draws 27 vs 29. At 17 fps (throttled) it steps
|
||||
aside as designed.
|
||||
- Correctness: screenshot diffs 15/15 (HUD 0.9971, chest scene 0.9996), `smokeMesher` clean.
|
||||
|
||||
## Not done
|
||||
|
||||
- **Lithium's skip of ambient particles where no biome adds any:** knowing that needs the biome
|
||||
lookup it would save (done differently in ADR 0031).
|
||||
|
||||
## Consequences
|
||||
|
||||
- Five more vendor patches.
|
||||
- A path that moves a terrain allocation without `UberGpuBuffer` would leave a stale draw.
|
||||
- Mesh tables are encoding version 2.
|
||||
- `?drawlists=game` also turns off animation culling.
|
||||
- A chest lid that opens without its block event (none in 26.3) would stay drawn shut until re-meshed.
|
||||
@@ -0,0 +1,76 @@
|
||||
# ADR 0031: What the floor stand-in's profiles found: items, ambient particles, glyphs, tints, indices
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-03
|
||||
|
||||
## Context
|
||||
|
||||
Until now every performance figure came from the desktop with its CPU throttled. With no Chromebook to
|
||||
hand, an old laptop now stands in (`laptop-floor`: i5-8250U held to 2 cores at 2.8 GHz, UHD 620,
|
||||
Chromium capped at 3 GB with zram; [`docs/benchmark.md`](../benchmark.md)). It's closer to the floor
|
||||
device than anything before, but still faster.
|
||||
|
||||
Before this ADR it held 60 fps in the fly-through and combat (1% lows 11–26 fps) and 21 fps in the
|
||||
lobby (tick 10, extract 9, render submit 26, GPU 18 ms). Profiles of a release build with Java names
|
||||
found, in the lobby: items written vertex by vertex 15%, glyph vertices 13%, ambient particle
|
||||
sampling 10%. In the fly-through: section snapshots 15% (half biome lookups for tints), rebasing
|
||||
translucent indices 7.5%. The slowest frames were catch-up ticks spent on ambient particles.
|
||||
|
||||
## Decision
|
||||
|
||||
Eight exact changes (the game's picture, byte-identical where vertices), each but the index copy
|
||||
with an off switch, plus three tools.
|
||||
|
||||
| Change | What | Off switch |
|
||||
| --- | --- | --- |
|
||||
| Generated items instanced | ADR 0027 missed flat items: every layer's quads carry a tint index. Now an item whose quads share one tint index is instanced with that layer's colour (`ModelBatches`) | `?items=game` |
|
||||
| Ambient particles per biome a tick | Of the attribute's layers, only the biome's reads the position, so the value is kept per biome per tick (`AmbientParticles`). Biomes are still looked up per position | `?ambient=game` |
|
||||
| A glyph quad in one call | `GlyphQuads` writes a glyph's four vertices straight into place for the two world-text formats, same FMA order, same bytes (`GlyphQuadsTest`) | `?glyphs=game` |
|
||||
| Blank sign lines skipped | `SignLines`: a blank line draws nothing anyway | `?signs=game` |
|
||||
| Tint biomes kept by position | An 8192-slot table, dropped when the client's biomes may change | `?tint=game` |
|
||||
| Direct index copies | `RebasedIndices` uses straight linear-memory loads/stores, ranges checked once | — |
|
||||
| Occlusion graph rebuild paced | `GraphUpdates` checks the clock every 64 nodes and yields at the slot's end, so a 37–41 ms rebuild no longer overruns a frame | `?graph=game` |
|
||||
| Particle light kept | `ParticleLight` keeps answers until a block or its light changes, or a chunk loads | `?particlelight=frame` |
|
||||
|
||||
**Tools:**
|
||||
|
||||
- **`-Pteavm.names`:** a release build that keeps Java names, so profiles read as the game's methods
|
||||
(about twice the download; profiling only).
|
||||
- **`?gpucensus`:** each draw's GPU time by pipeline. A draw that switches render targets also
|
||||
absorbs earlier work, so read shares with care.
|
||||
- **Benchmark against a remote browser** now gets the page's console, closes its tab, and prints the
|
||||
stack of any 50 ms render-thread wait.
|
||||
|
||||
## Results
|
||||
|
||||
`laptop-floor`, release build, 2026-10-03, three alternating runs each (medians):
|
||||
|
||||
| Lobby | Before | After |
|
||||
| --- | ---: | ---: |
|
||||
| Frame rate (fps) | 21.1 | 31.6 |
|
||||
| 1% low (fps) | 7.5 | 9.8 |
|
||||
| Tick / extract / render submit (ms) | 10.2 / 8.7 / 26.2 | 5.1 / 7.8 / 15.9 |
|
||||
| GPU (ms) | 18.0 | 10.6 |
|
||||
|
||||
| Fly-through and combat | Before | After |
|
||||
| --- | ---: | ---: |
|
||||
| Fly-through tick (ms) | 2.8 | 1.7 |
|
||||
| Fly-through slowest-1% tick (ms) | 43.4 | 16.6 |
|
||||
| Fly-through 1% low (fps) | 13.7 | 15.9 |
|
||||
| Combat slowest-1% tick (ms) | 19.8 | 14.0 |
|
||||
| Combat 1% low (fps) | 24.0 | 26.8 |
|
||||
|
||||
Both hold 60 fps at the median either way. Memory and start-up don't move. Screenshot diffs pass
|
||||
15/15 (SSIM ≥ 0.9938).
|
||||
|
||||
## Consequences
|
||||
|
||||
- Five more vendor patches; the glyph one is largest, since Incari code can't reach LWJGL's memory
|
||||
functions.
|
||||
- Items with per-quad tint changes within one layer (none in 26.3) would need the game's way.
|
||||
- Ambient particles assume the biome is the only positional layer, as in 26.3.
|
||||
- Particle light trusts that every light change marks render sections dirty, as meshing does.
|
||||
- The occlusion graph's full update can take several frames, as the game already allows.
|
||||
- What's left on the stand-in: the lobby is CPU-bound (~30 ms of tick, extract and submit across
|
||||
entities, text, particles); the slowest fly-through and combat frames are scavenges and catch-up
|
||||
ticks.
|
||||
@@ -0,0 +1,61 @@
|
||||
# ADR 0032: Catch-up ticks paced, mesher tables kept, light maps updated in place, particles instanced
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-03
|
||||
|
||||
## Context
|
||||
|
||||
Still without a Chromebook, these changes were chosen as wins on any device, measured on
|
||||
`laptop-floor`:
|
||||
|
||||
- **Catch-up ticks:** the slowest 1% of frames were mostly missed ticks run back to back after a stall.
|
||||
- **Joining:** building the mesher's tables took ~7 s of the 22 s join, every time, for the same tables.
|
||||
- **Fly-through GCs:** young collections averaged 10 ms (the lobby's 0.7 ms). Desktop JFR showed what
|
||||
lives long: 70 of 158 samples were the light engine copying its whole section map after each
|
||||
round of updates; 28 the occlusion graph cloning two sets.
|
||||
- **Particles:** writing their vertices was 3.3% of the lobby.
|
||||
|
||||
## Decision
|
||||
|
||||
| Change | What | Off switch |
|
||||
| --- | --- | --- |
|
||||
| Catch-up ticks paced (`TickPacing`) | Owed ticks spread over frames: each frame runs the average needed (at least one), one more while over two frames' worth is owed. Debt capped at the game's own 10. Page only | `?ticks=game` |
|
||||
| Mesher tables kept (`MeshTableCache`) | Encoded tables saved to `/incari/cache/mesher-tables.bin` in OPFS, keyed by build id, lighting settings, packs and every blocks-atlas sprite. Only with built-in packs and release builds | `?meshtables=build` |
|
||||
| Light maps updated in place (`LightCopies`) | Instead of copying ~8,700 sections' arrays after each round, update the visible map only at sections noted as changed. One-thread only. Light from remote servers is kept as it arrives, not copied | `?light=game`, `?light=verify` |
|
||||
| Occlusion graph copies refilled | Two kept sets refilled instead of cloned for each full update | `?graph=game` |
|
||||
| Particles instanced (`ParticleInstancing`, `ParticleInstanceRewrite`) | Each particle's 12 floats and 2 ints go to the GPU as one instance; the vertex shader builds the quad from `gl_VertexID`. Translucent order kept. Only when every pipeline a layer may use has an instanced copy | `?particlequads=game` |
|
||||
|
||||
A first tick-pacing version allowed 20 ticks of debt and drained faster as it grew: combat's 1% low
|
||||
fell after its stalls. Capped at 10, it doesn't.
|
||||
|
||||
The benchmark now joins twice (`load.rejoinMillis`), as a player's every later join.
|
||||
|
||||
## Results
|
||||
|
||||
`laptop-floor`, release build, 2026-10-03:
|
||||
|
||||
- **Tables:** built in 6.7 s, read back in 0.23 s. Rejoin 13.0–13.8 s vs 18.8–19.6 s.
|
||||
- **Tick pacing**, fly-through (6 runs each): 1% low 26.9 vs 18.3 fps; slowest-1% frame 20.9 vs
|
||||
36.1 ms. Combat and lobby unchanged.
|
||||
- **Light and graph copies:** young GCs 40 vs 44 and 347–369 vs 376–417 ms total; p99 frame 26.3 vs
|
||||
28.5 ms. `?light=verify` over 1,000 swaps: no difference.
|
||||
- **Particles:** lobby render submit 15.1 vs 15.9 ms; 33.1 vs 31.6 fps.
|
||||
- Screenshot diffs 15/15 (particles 0.9989, drawn instanced). `TickPacingTest`,
|
||||
`ParticleInstanceRewriteTest`.
|
||||
|
||||
## Not done
|
||||
|
||||
- **Chunk data off the GC heap:** JFR named the light copies, not chunk storage.
|
||||
- **Decoding chunk packets off the main thread:** 2.4% of the page; too little to pay for a worker's copies.
|
||||
- **Lithium's shape and collision caches:** collisions were 1–2%.
|
||||
- **Found for later:** every packet handed to the game's thread costs a throw, ~10x dearer off the
|
||||
main thread (`PacketHandoffProbe`). ADR 0033 takes it.
|
||||
|
||||
## Consequences
|
||||
|
||||
- More vendor patches (tick hook, light swap and accessors, graph copies, four particle hooks).
|
||||
- The kept tables cost 11 MB of heap; the title stays in budget.
|
||||
- The tables' key must name every input; a new one (a model-changing setting) must join it.
|
||||
- After a stall the game runs up to 10 ticks behind the clock for a few frames.
|
||||
- In-place light trusts every change notes its section, as in 26.3; `?light=verify` checks.
|
||||
- Particle positions are the GPU's arithmetic; the screenshot diffs check them.
|
||||
@@ -0,0 +1,72 @@
|
||||
# ADR 0033: Throws off the page's main thread: the packet handoff, and Via's dropped packets
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-03
|
||||
|
||||
## Context
|
||||
|
||||
`PacketUtils.ensureRunningOnSameThread` was 2.5% of combat on `laptop-floor`, mostly entity movement
|
||||
packets, whose handoff cost ~100x their decoding.
|
||||
|
||||
The game decodes each packet on the network thread and calls its handler there; nearly every client
|
||||
handler queues the packet for the game's thread and throws a shared exception that
|
||||
`Connection.channelRead0` catches. Cheap on the JVM. In the page (`PacketHandoffProbe`):
|
||||
|
||||
| ns per packet | Main thread | Any other thread |
|
||||
| --- | ---: | ---: |
|
||||
| Calls | 5–15 | 5–10 |
|
||||
| Queueing | 20–30 | 20–30 |
|
||||
| Throw and catch | 65–100 | 640–860 |
|
||||
|
||||
The network thread is another thread, so every packet paid the dear throw.
|
||||
|
||||
## Decision
|
||||
|
||||
**`PacketHandoff`** (two hooks in `Connection.channelRead0`): the first time a packet type's handler
|
||||
throws to hand off (per listener type), the pair is noted. From then on the connection queues such
|
||||
packets on the game's packet processor itself, without calling the handler on the network thread.
|
||||
The game's thread handles them as before.
|
||||
|
||||
That's exactly the game's effect where the handler's first statement is an unconditional handoff.
|
||||
`PacketHandoffTest` reads the game's listeners and confirms it for 136 of 138 handlers in 26.3; the
|
||||
other two (custom payload, transfer) are never noted. Handlers that don't hand off never throw, so
|
||||
are never noted. Client listeners only. Page only; `?handoff=game` restores the game's way.
|
||||
|
||||
### The other throws: a census
|
||||
|
||||
`-Pteavm.throwCensus` (development builds) counts every `throw` by site and thread
|
||||
(`ThrowCensus`, `ThrowCensusProbe`). On a 26.3 server: ~13 a second, mostly loading (missing-file
|
||||
checks, reflection) and the section dispatcher finding no free buffer (fixed in ADR 0034). Not worth patches.
|
||||
|
||||
**Through Via:** 135–205 a second, nearly all Via dropping packets the other version doesn't use. Each
|
||||
dropped packet threw in Via, then 3–4 more times in Netty's `MessageToMessage` codecs that
|
||||
`ViaPipeline` extended.
|
||||
|
||||
**Via's stage without Netty's codecs:** `ViaPipeline`'s decoder and encoder are now plain handlers
|
||||
that do the codecs' job and catch Via's drop themselves. A dropped packet now throws twice, both in
|
||||
Via. `ViaPipelineTest` checks every buffer is released.
|
||||
|
||||
## Results
|
||||
|
||||
`laptop-floor`, release build, vs `?handoff=game`:
|
||||
|
||||
- Normal runs: within noise, since combat and the fly-through already hold 60 fps.
|
||||
- With the profiler on (page 97–98% busy, like a slower device): combat median 40.7–44.4 vs
|
||||
37.6–39.1 fps, every run with the change above every run without.
|
||||
|
||||
Via census, same sessions before and after:
|
||||
|
||||
| Throws off the main thread | Before | After |
|
||||
| --- | ---: | ---: |
|
||||
| 1.8.9 server, 2 minutes | 16,080 | 6,161 |
|
||||
| 1.12.2 server, 90 s | 18,484 | 5,172 |
|
||||
|
||||
On the stand-in that's a few tenths of a millisecond a second, below what can be measured; it
|
||||
counts where the CPU is the limit.
|
||||
|
||||
## Consequences
|
||||
|
||||
- One vendor patch (`Connection.channelRead0`).
|
||||
- A future handler that does something before handing off fails `PacketHandoffTest` until listed.
|
||||
- Via's own two throws per dropped packet stay; avoiding them means replacing Via's classes.
|
||||
- `-Pteavm.throwCensus` adds a call before every throw: development only.
|
||||
@@ -0,0 +1,71 @@
|
||||
# ADR 0034: Fixed translucent orders, the class library's lookups, collision sweeps, and Binaryen
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-04
|
||||
|
||||
## Context
|
||||
|
||||
`laptop-floor` holds the fly-through and combat at 60 fps and the lobby near 33 fps. What's left is
|
||||
thin CPU time and slow frames. Profiles of the stand-in named:
|
||||
|
||||
| Share of page time | |
|
||||
| --- | ---: |
|
||||
| Combat: dropped items' ticks, a third in block collision sweeps | 10% |
|
||||
| Lobby: particles removed from an `ArrayDeque` element by element | 2% |
|
||||
| Combat: `Set.contains` on the class library's `Set.copyOf` (tag checks) | 1.2% |
|
||||
| Fly-through: `drawBuffers` on every framebuffer bind | 3.1% |
|
||||
| Fly-through: a `NullPointerException` thrown when no buffer pack is free | 0.7% |
|
||||
| Fly-through: section snapshots (tint biome lookups 2.5%) | 11% |
|
||||
|
||||
## Decision
|
||||
|
||||
| Change | What | Off switch |
|
||||
| --- | --- | --- |
|
||||
| Fixed translucent order (Sodium's static sorting) | When every translucent quad in a section lies flat across one axis (still water), one order is correct from any camera, because back faces are culled. The mesher writes that order (`FixedOrder`) and the game's re-sort is skipped. Page only | `?resort=game` |
|
||||
| Air skipped in collision sweeps (Lithium) | `AirBlock` shapes are empty in every context, so skip them before asking (`Collisions`) | `?collisions=game` |
|
||||
| Snapshots read section copies directly | `SnapshotBuilder` reads each copied section's palette, not 8,000 checked lookups. Desktop too, so `smokeMesher` checks it | `?snapshotreads=game` |
|
||||
| Tint biomes dropped locally | A chunk loading or unloading drops cached biomes only in it and its neighbours (`TintBlend.chunkChanged`) | — |
|
||||
| Hashed immutable sets and maps | `TTemplateCollections` probes an index table instead of comparing every element (`ImmutableCollectionsProbe`) | — |
|
||||
| `ArrayDeque` middle removal | Shifts with `System.arraycopy` | — |
|
||||
| Draw buffers set once | A framebuffer's draw buffers are set on its first draw bind (`Framebuffers`) | — |
|
||||
| No throw for a busy dispatcher | Requeue without the `NullPointerException` the game threw and caught | — |
|
||||
|
||||
## Binaryen (`-Pteavm.wasmOpt`, opt-in at the time)
|
||||
|
||||
Runs `wasm-opt --closed-world -O3 -ocimfs 100` (Binaryen 133, pinned and fetched to
|
||||
`work/cache/binaryen/`) after TeaVM. Adds ~13 minutes and 10 GB to a release build.
|
||||
|
||||
- **`--closed-world`** broke the page at first: functions JavaScript calls reached Binaryen only as
|
||||
function references, so it emptied `main`. `WasmGCJsoCommonGenerator` (teavm-patches) now exports them.
|
||||
- **`-ocimfs 100`:** uncapped single-caller inlining made functions V8's optimizer ran out of memory on.
|
||||
- Plain `-O3` without closed world measured nothing.
|
||||
|
||||
On `laptop-floor`: fly-through render submit 2.3 → 1.9 ms; the rest within noise; download about the
|
||||
same. Kept opt-in until measured on the floor device (made the default in ADR 0043).
|
||||
|
||||
## Not done
|
||||
|
||||
- **Vertex pulling** (terrain without an index buffer): on the UHD 620 it cost up to two thirds more
|
||||
GPU time where vertices dominate.
|
||||
- **Reusing entity render states:** constructors were 0.2% of combat, and reuse would trust every
|
||||
renderer to reset every field.
|
||||
|
||||
## Results
|
||||
|
||||
`laptop-floor`, release build, 2026-10-04. The three switchable changes, on vs off: combat tick 2.3
|
||||
vs 2.7 ms; fly-through and lobby within noise (both already at their limits).
|
||||
|
||||
Profile shares before → after: `drawBuffers` 3.1% → 0; dispatcher stack traces 0.5% → 0; snapshots
|
||||
11% → 8.3%; `Set.contains` 1.2% → 0.02%; `ArrayDeque` removal 2% → 0.
|
||||
|
||||
Found on the way: the lobby's mesh queue drains at ~1.5 sections a second when frames overrun,
|
||||
because the background pool gets only 1 ms then (fixed in ADR 0035).
|
||||
|
||||
Correctness: screenshot diffs 15/15, `smokeMesher` (17,943 sections) clean, `SectionMesherTest`.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Five more vendor patches.
|
||||
- The fixed order trusts that terrain pipelines cull back faces.
|
||||
- Skipping air trusts that air has no shape in any collision context, as in 26.3.
|
||||
- Local tint drops trust that a biome lookup never reads past the neighbouring chunk.
|
||||
@@ -0,0 +1,42 @@
|
||||
# ADR 0035: A floor for the background pool's share of a late frame
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-05
|
||||
|
||||
## Context
|
||||
|
||||
Background work runs in slots between frames (ADR 0015), ending 2 ms before the next frame is due,
|
||||
with at least 1 ms. When the game's frame already overruns (the lobby on `laptop-floor` runs at 33
|
||||
fps on a 60 Hz display), every slot is that 1 ms: part of one section's snapshot. A section took
|
||||
dozens of frames, and terrain after a teleport took minutes on a slow device.
|
||||
|
||||
## Decision
|
||||
|
||||
While the pool has work, a slot lasts until `max(frame start + interval − 2 ms, now + floor)`, the
|
||||
floor 4 ms by default (`WebPlatform.setPoolFloor`; `?poolfloor=<ms>`). On-time frames are unchanged;
|
||||
only already-late frames give the pool more, and only while it has work.
|
||||
|
||||
## Results
|
||||
|
||||
Desktop, CPU throttled 4x, lobby:
|
||||
|
||||
| Floor | FPS | Mesh queue | Sections drawn |
|
||||
| --- | ---: | ---: | ---: |
|
||||
| 1 ms (before) | 29.9 | 81 | 119 |
|
||||
| 4 ms | 29.0 | 48 | 196 |
|
||||
| 8 ms | 26.4 | 46 | 197 |
|
||||
|
||||
Two-thirds more terrain in the same time for 3% of the frame rate; 8 ms cost more and loaded no
|
||||
more. The fly-through (time to spare each frame) didn't move. On `laptop-floor` the lobby's queue
|
||||
halved (17.7 → 8.3) for 2% of its frame rate.
|
||||
|
||||
## Not done
|
||||
|
||||
- **Several sections in progress at once:** starting another task while one waits for a worker made
|
||||
no difference; the page's share of each section (snapshot, upload) is the limit.
|
||||
|
||||
## Consequences
|
||||
|
||||
- A late frame is ~3 ms later while terrain loads (more if a long task starts in its slot).
|
||||
- The lobby benchmark loads further in the same time, so its tick and render submit rise with the
|
||||
terrain drawn.
|
||||
@@ -0,0 +1,68 @@
|
||||
# ADR 0036: Fast and Compatible builds (JSPI instead of coroutines)
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-05
|
||||
|
||||
## Context
|
||||
|
||||
TeaVM compiles every method that might suspend as a coroutine, and its analysis spreads that through
|
||||
shared library code (ADR 0027). In the release module, coroutines are 83,152 of 303,310 functions but
|
||||
**81% of all instructions**, ~38% of which is the transformation's own bookkeeping. The fly-through
|
||||
spends 87% of its WebAssembly time in coroutines. `CoroutineCostProbe`: the same code takes 8.3–8.7 ns
|
||||
an item as coroutines vs 5.5–5.9 ns plain.
|
||||
|
||||
**JSPI** (WebAssembly JavaScript Promise Integration) lets the engine keep a suspended stack itself,
|
||||
so nothing needs compiling differently. Chrome/Edge 137+ and Firefox 153+ have it; Safari doesn't yet.
|
||||
|
||||
The JavaScript fallback (ADR 0014) served only Chrome before 119 (end-of-life devices), ran far
|
||||
slower, and was a second compile to maintain.
|
||||
|
||||
## Decision
|
||||
|
||||
- **Two WebAssembly GC builds, named for players:**
|
||||
- **Fast:** threads suspend through JSPI; nothing is a coroutine. Chrome/Edge 137+, Firefox 153+.
|
||||
- **Compatible:** TeaVM's coroutines, for browsers with WebAssembly GC but no JSPI (Safari, older
|
||||
Chrome and Firefox).
|
||||
|
||||
The names say what a player weighs (speed vs reach) and are used everywhere: the loading screen,
|
||||
`?build=`, `-Pteavm.fast`, `build/teavm-fast/`, `./incari build --only`, the manifest.
|
||||
- **The JavaScript fallback goes.** Browsers without WebAssembly GC are told to update.
|
||||
- **TeaVM changes** (teavm-patches): with `incari.jspi` set, `AsyncMethodFinder` finds nothing async.
|
||||
`Fiber.Jspi` runs each fiber through `WebAssembly.promising` and suspends on a
|
||||
`WebAssembly.Suspending` import. `JspiTransformer` routes `Fiber.suspend`/`start` there.
|
||||
- **The page:** `build.json` format 2 lists `fast` and `compatible`. Where both run, the loading
|
||||
screen asks (Fast recommended) and remembers.
|
||||
- **Ending fibers on `pagehide`:** V8 never frees a suspended stack, so every reload leaked the
|
||||
whole game (50 MB a load in `ReloadLeakProbe`; the lobby held three old games, 1,140 vs 356 MB).
|
||||
`jspi.ts` resumes each waiting fiber with an order to end, and it unwinds by trapping, with no
|
||||
Java code run.
|
||||
- **`./incari build`** compiles both; `--only` makes one.
|
||||
|
||||
## Results
|
||||
|
||||
`laptop-floor`, release builds:
|
||||
|
||||
| | Compatible | Fast |
|
||||
| --- | ---: | ---: |
|
||||
| Lobby median / 1% low | 32.5 / 7.6 fps | 60.4 / 32.0 fps |
|
||||
| Lobby tick / extract / render submit | 7.8 / 7.9 / 14.8 ms | 1.6 / 3.8 / 9.6 ms |
|
||||
| Combat 1% low | 27.0 fps | 38.9 fps |
|
||||
| Cold start | 13.4 s | 10.2 s |
|
||||
| Join | 19.5 s | 13.7 s |
|
||||
|
||||
Desktop: lobby render submit 4.05 → 2.38 ms, join 4.9 → 3.6 s, combat and lobby 1% low up 22–27%.
|
||||
Module 64.1 → 36.5 MB (gzip 20.5 → 12.3 MB). GC pause spikes vary run to run in both builds.
|
||||
|
||||
`JspiProbe` (sleep, wait/notify, join, exceptions across waits, `currentThread`) passes in both;
|
||||
`jspi.test.ts` runs the imports under Node's JSPI.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Two release compiles per build.
|
||||
- Code reached from a JavaScript callback still must not suspend (JSPI traps).
|
||||
- In Fast, a woken thread resumes from a microtask, not inside the call that woke it. Nothing found
|
||||
relies on the old order.
|
||||
- Thread switches through TeaVM's event queue cost ~4 ms in both builds (the `setTimeout` clamp; see
|
||||
ADR 0040).
|
||||
- Compatible is unchanged, so running both separates Fast regressions from game ones.
|
||||
- Drop Compatible once every browser that matters has JSPI (watch Safari).
|
||||
@@ -0,0 +1,45 @@
|
||||
# ADR 0037: The Unicode font and the languages from the asset index
|
||||
|
||||
- Status: accepted; the panorama is no longer fetched (menus show Incari's own photo, `MenuBackdrop`)
|
||||
- Date: 2026-10-05
|
||||
|
||||
## Context
|
||||
|
||||
The game reads both the client jar and the assets directory a launcher fills from the asset index.
|
||||
The page took only sounds from the index (ADR 0013), and it showed:
|
||||
|
||||
- **Only English:** the jar has `en_us.json`; the other 142 languages (and the language list,
|
||||
`pack.mcmeta`) are in the index.
|
||||
- **No Unicode font** (`font/unifont*.zip`, 1.8 MB): CJK, most non-Latin scripts and many symbols drew
|
||||
as boxes.
|
||||
- **A grey title panorama:** the jar holds blank stand-ins. (Since replaced by Incari's own photo.)
|
||||
|
||||
These are Mojang's files: fetched by `./incari assets` into the ignored cache and copied into the
|
||||
builder's own folder (ADR 0028), like the sounds. Nothing is committed.
|
||||
|
||||
## Decision
|
||||
|
||||
- **The build copies them:** `WebFolder` copies `sounds.json`, `pack.mcmeta`, `minecraft/font/` and
|
||||
`minecraft/lang/` with the sounds. `--no-sounds` still leaves the whole index out.
|
||||
- **The language list is fetched at start**, with `sounds.json`, since the pack repository reads it
|
||||
once before the first reload.
|
||||
- **The rest is fetched before the listeners that read it reload** (`RemoteAssets.gate`, through the
|
||||
existing reload hook, no new patch): the font and the selected language are fetched on the
|
||||
background pool while the language and font managers' reloads wait; others start at once. Files
|
||||
already written are skipped, so later reloads fetch only a newly picked language.
|
||||
- **A failed fetch is logged** and the reload continues with what's there.
|
||||
- **The service worker keeps them** between loads (content-addressed objects).
|
||||
- The desktop reads its full assets directory as before.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Every language can be picked, and text outside the bitmap font draws.
|
||||
- A first visit downloads ~1.8 MB more for the font (0.6 MB more for a non-English language).
|
||||
- The folder grows by the languages (85 MB on disk; only one is downloaded).
|
||||
|
||||
## Alternatives rejected
|
||||
|
||||
- **A file system that fetches on open:** the page's file system never suspends (ADR 0011).
|
||||
- **Fetching when the language screen closes:** a new patch, a render-thread wait, and it misses a
|
||||
language saved from an earlier visit.
|
||||
- **Incari's own font:** only needed for a distributable build, which none is.
|
||||
@@ -0,0 +1,62 @@
|
||||
# ADR 0038: Singleplayer in the page
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-07
|
||||
|
||||
## Context
|
||||
|
||||
Singleplayer was planned for much later. The plan changed: all of vanilla works before the client
|
||||
builds its own features, singleplayer included. The integrated server was always in the browser
|
||||
build, but nothing had opened a world. The first try failed to save `level.dat` and then waited
|
||||
forever for its first chunk.
|
||||
|
||||
This ADR is stage one: singleplayer working with the integrated server on the page's one thread.
|
||||
ADR 0039 moves the server into a worker.
|
||||
|
||||
## Decision
|
||||
|
||||
### Getting the server to run
|
||||
|
||||
- **The game's wait loops end their frame:** world load and save-and-quit pump events from inside a
|
||||
loop, so the page never reached the point between frames where the server and pool run.
|
||||
`SDLEventHandler.pumpEvents` now ends the frame there. No-op on the desktop.
|
||||
- **A blocking pool task gives up the pool** (`IdleTimeExecutor.beforeWait`, via `Waits`): world
|
||||
generation joins work it queued on the same pool, which never ran with the one runner holding it.
|
||||
Another runner takes over. `IdleTimeExecutorTest`.
|
||||
|
||||
### Class library fixes (found because singleplayer is the first heavy user)
|
||||
|
||||
| What | Bug | Fix |
|
||||
| --- | --- | --- |
|
||||
| `GZIPOutputStream.flush()` | Threw on zlib's "no progress" | web-classlib's own |
|
||||
| `Deflater`, `DeflaterOutputStream` | Threw mid-stream; miscounted input | web-classlib's own over jzlib (`DeflateProbe`) |
|
||||
| `InflaterInputStream.skip` | Overwrote input not yet inflated | An addition skipping into scratch |
|
||||
| `ByteBuffer.allocateDirect` | Not zeroed: region headers garbage | teavm-patches |
|
||||
| Polled `ReferenceQueue` references | Lost their class's methods (Optimize World trapped) | teavm-patches (`WeakQueueProbe`) |
|
||||
| Netty's local channels | Reflection, two NIO exceptions, interface probing | Declared, added, fixed ids |
|
||||
| `STBImageResize` | Missing | `ImageResize` in Java |
|
||||
| Logged crashes | Lost their cause | The console logger walks the chain |
|
||||
|
||||
### What a page does instead of a folder or a port
|
||||
|
||||
- **Folder buttons download zips** where the platform can't show folders (`FolderDownloads`): Open
|
||||
World Folder, Open Backups Folder. Pack folders keep the file picker.
|
||||
- **Drop a world on the world list to import it** (`WorldImport`): a zip or folder with a
|
||||
`level.dat` becomes a new world, never overwriting one. Entries pointing outside are refused.
|
||||
- **Open to LAN fails cleanly:** `PlatformNetwork.canAcceptConnections` is false, and the game's own
|
||||
"couldn't host" path shows. Sharing through a relay came later (ADR 0062).
|
||||
|
||||
## Verified
|
||||
|
||||
Headless Chrome: create, generate, play, pause, save and quit, reopen, quit again; every chunk in
|
||||
every region file inflates with the browser's `DecompressionStream`. Backups, Edit World, World
|
||||
Options and Optimize World work.
|
||||
|
||||
## Consequences
|
||||
|
||||
- **The server shares the page's thread:** 60 ms frames during world generation, and "Can't keep
|
||||
up". ADR 0039 fixes this.
|
||||
- **Worlds sit in memory** as well as OPFS (until ADR 0041).
|
||||
- **"UUID of added entity already exists"** a few times a session: entities load twice, the game
|
||||
keeps the first, and saves hold no duplicates. Cause open.
|
||||
- **The loading screen's chunk map** costs half the page's time while a world loads.
|
||||
@@ -0,0 +1,65 @@
|
||||
# ADR 0039: Singleplayer's server in a Web Worker
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-07
|
||||
|
||||
## Context
|
||||
|
||||
ADR 0038's server on the page's thread works, but its ticks and world generation take time from the
|
||||
client's frames (60 ms frames after joining a new world, the server seconds behind). On the
|
||||
reference Chromebook that's the difference between playable and not. Web Workers share nothing with
|
||||
the page: own WebAssembly instance, own heap, messages only.
|
||||
|
||||
## Decision
|
||||
|
||||
### The same program, in a worker
|
||||
|
||||
- **No second module:** the worker loads the game's own (cached) module and starts it with a role:
|
||||
`WebMain.main(["--worker", "server"])` runs `GameWorkerMain`, never the client. A second compile
|
||||
would double build time and download for nearly all-shared code.
|
||||
- **`PlatformThreads.startGameWorker`** runs `game-worker.js`, which loads the module as `boot.ts`
|
||||
does (with JSPI for Fast). Page and worker talk through a `PlatformChannel` of transferred byte
|
||||
messages. The desktop keeps the vanilla integrated server; `?singleplayer=page` keeps ADR 0038's way.
|
||||
- **The worker's platform is headless** (`WorkerPlatform`): threads, pool, files. Pool slots are 8 ms
|
||||
turns of the event loop (`WorkerSlots`).
|
||||
- **The worker reads the client jar** from OPFS where the page cached it.
|
||||
|
||||
### The world's files move with the server
|
||||
|
||||
- **Hand-over:** the page sends the world's files and forgets them (`PlatformStorage.handOver`); on
|
||||
stop the worker sends them back (`takeOver`). Never in both heaps. (ADR 0041 later leaves region
|
||||
files in place.)
|
||||
- **The worker's writes go to storage through the page** every 250 ms (ADR 0041 later made this direct).
|
||||
- **A new world's settings are written on the page** before hand-over, so the worker opens every
|
||||
world the same way.
|
||||
|
||||
### The server
|
||||
|
||||
- **`WorkerServer`**: a `MinecraftServer` written for the worker, doing what `IntegratedServer` does
|
||||
for one player. Pause and view distances arrive by message. The owner's data goes into
|
||||
`level.dat`, so worlds move between browser and desktop unchanged.
|
||||
- **The client connects as if remote:** the game's pipeline, one packet per message over the channel
|
||||
(`ChannelLink`). No compression or encryption.
|
||||
- **Hooks:** opening (`Minecraft.doWorldLoad`: write data, start the worker, show its progress,
|
||||
connect), leaving (`Minecraft.disconnect`: save and stop with "Saving world"), pausing, and the
|
||||
world icon (taken on the page, sent to the worker).
|
||||
- **World Options** asks a `SingleplayerHost` (the integrated server, or the worker's reported
|
||||
settings, changed by message). Open to LAN fails cleanly.
|
||||
|
||||
## Verified
|
||||
|
||||
`singleplayer.steps`, both builds: create, play, World Options and a command, save, ~1,100 chunks
|
||||
inflate, reopen, download, import, delete. A worker-made world opens in page mode too.
|
||||
|
||||
Desktop frames in the 5 s after joining a new world, then after: server on the page 32, 41, 56, 55
|
||||
fps; in a worker 36, 58, 59, 58 fps.
|
||||
|
||||
## Consequences
|
||||
|
||||
- **Two copies of the game run;** the worker's heap (registries, data packs, world) adds to the
|
||||
page's. Measuring both together is next.
|
||||
- **The worker starts in a few seconds per world** (later started early, ADR 0041).
|
||||
- **Logs** carry the worker's own thread names in the page's console.
|
||||
- **"UUID of added entity already exists"** still appears: a chunk's entities load twice. The game
|
||||
keeps the first; saved files hold no duplicates. Why it happens here and not on the desktop is open.
|
||||
- **The desktop is unchanged.**
|
||||
@@ -0,0 +1,65 @@
|
||||
# ADR 0040: Singleplayer's server, faster: wakeups, math, spawn settings, stronghold rings
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-07
|
||||
|
||||
## Context
|
||||
|
||||
With the server in a worker (ADR 0039), a new world took 29 s to create on the desktop and 62 s on
|
||||
`laptop-floor`; the idle tick at spawn was 9.7 ms (22 on the laptop), and the laptop's fly-through
|
||||
drew ~20 sections because terrain couldn't keep up.
|
||||
|
||||
We surveyed the server-side optimization mods (Lithium, C2ME, Noisium, ScalableLux, ModernFix, Chunky)
|
||||
against profiles of the worker itself (`-Pbenchmark.profile` now records them). Nothing here is a mod's
|
||||
code. The profiles found:
|
||||
|
||||
| Where | What |
|
||||
| --- | --- |
|
||||
| Creating a world | 18 of 25 s with the worker 99% idle while picking spawn |
|
||||
| Everywhere | 8–18% of busy time calling out to JavaScript |
|
||||
| Idle spawn area | 55% of each tick in `NaturalSpawner.createState`, spawning off |
|
||||
| Opening a world | half the time searching biomes for 128 stronghold rings |
|
||||
| Fly-through | noise 50%, surface 24%, features 10% (not addressed here) |
|
||||
|
||||
## Decision
|
||||
|
||||
- **Wakeups without the timer clamp** (`wakeups.ts`): picking spawn makes ~8,000 hand-offs between
|
||||
the world-gen task and the IO thread. TeaVM schedules every wakeup with `setTimeout(0)`, which
|
||||
browsers clamp to 4 ms once nested five deep: 16–22 s of idle waiting. In the worker, events due
|
||||
now drain from a `MessageChannel` instead. The page keeps timers unless `?wakeups=channel`
|
||||
(ADR 0043 found it unsafe there).
|
||||
- **`Math.floor`, `ceil`, `sqrt` as wasm instructions** (`MathIntrinsics`): TeaVM imported them from
|
||||
JavaScript, and noise floors every coordinate. All three are exact in IEEE 754 (`MathProbe`). Calls
|
||||
out fell from 18% to 1% of the worker's time.
|
||||
- **Spawn settings once per biome** (`SpawnCosts`) [`?spawncosts=game`, `?spawncosts=verify`]: the
|
||||
mob cap asked for spawn settings at every counted mob every tick; they depend only on the biome
|
||||
unless a timeline changes them. Verified over 580,000 lookups: no difference.
|
||||
- **Stronghold rings searched when needed** (`StrongholdRings`) [`?rings=game`]: the game started all
|
||||
128 biome searches as the overworld loaded, ahead of the spawn area on a one-thread worker. Now
|
||||
positions and random sources are worked out up front in the game's order, and each search runs the
|
||||
first time a chunk within reach needs it; the rest run in the background after a minute.
|
||||
`StrongholdRingsTest` checks identical positions for two seeds.
|
||||
|
||||
## Results
|
||||
|
||||
Singleplayer benchmark, Fast release:
|
||||
|
||||
| | Desktop before | after | `laptop-floor` before | after |
|
||||
| --- | ---: | ---: | ---: | ---: |
|
||||
| Create world | 29.4 s | 7.5 s | 61.6 s | 32.5 s |
|
||||
| Save and Quit | 5.7 s | 2.1 s | 10.7 s | 5.6 s |
|
||||
| Reopen | 7.9 s | 5.6 s | 32.1 s | 22.0 s |
|
||||
| Idle tick at spawn | 9.7 ms | 5.1 ms | 22.4 ms | 14.4 ms |
|
||||
| Fly-through tick | 4.4 ms | 2.5 ms | 14.5 ms | 4.6 ms |
|
||||
| Sections drawn, fly-through | | | 21 | 89 |
|
||||
|
||||
On the laptop the page now draws 3–4x more terrain, so its frame figures aren't comparable: on two
|
||||
cores, handling arriving chunks is now the page's cost, beside world generation. Baselines re-recorded.
|
||||
|
||||
## Consequences
|
||||
|
||||
- The page keeps TeaVM's timers; `wakeups.js` is one more script the loader serves.
|
||||
- World generation (noise, surface) is now the worker's cost. Compiling density functions at build
|
||||
time was the next idea; more generating workers would cost 260–420 MB each.
|
||||
- Worker profiles are part of `-Pbenchmark.profile`.
|
||||
- The desktop is unchanged.
|
||||
@@ -0,0 +1,92 @@
|
||||
# ADR 0041: Singleplayer's files in place, a direct line to storage, and cheaper world generation
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-08
|
||||
|
||||
## Context
|
||||
|
||||
Profiles after ADR 0040 (desktop, Fast build with names):
|
||||
|
||||
| Where | Time went to |
|
||||
| --- | --- |
|
||||
| Fly-through, server worker (56% busy) | surface 27.5%, noise 22%, features 11%, saving 12% |
|
||||
| Fly-through, page | passing the worker's file changes to storage: 10%, 4x the chunk packets themselves |
|
||||
| Creating a world, worker | surface 28%, noise 21%, features 8%, worker start 13% |
|
||||
| Idle at spawn | mob movement and collisions 43% of the tick; stronghold searches 33% |
|
||||
|
||||
Region files rewrite their 8 KiB header with every chunk saved, and a file kept only one changed
|
||||
range between flushes, so each 250 ms flush copied most of every touched region file about seven
|
||||
times, three on the page's thread. Both page and worker also held whole worlds in memory, which
|
||||
grows with exploring: on a 4 GB Chromebook that heap runs out.
|
||||
|
||||
In 26.3 the material system writes ~16,000 blocks a chunk through `ProtoChunk.setBlockState`.
|
||||
Density functions are already sampled over volumes, so compiling them would gain little.
|
||||
|
||||
## Decision
|
||||
|
||||
Nothing here is a mod's code. Bracketed options turn a change off.
|
||||
|
||||
- **World files left in place** [`?inplace=off`]: region files (`.mca`, `.mcc`) are never loaded
|
||||
whole when OPFS is the store and this tab holds it (`InPlaceFiles`). The page lists them by size
|
||||
and reads one only when it opens it. The server worker opens them with synchronous access handles
|
||||
(`OpfsFiles`), writing straight to the file. Hand-over sends sizes after a storage `sync`; hand-back
|
||||
releases handles and `stat`s the files. With IndexedDB or no sync handles, files travel with their
|
||||
bytes as in ADR 0039.
|
||||
- **A direct line to storage:** the worker sends file changes straight to the storage worker through
|
||||
a port the page hands it (`BrowserStore.connect`), in the page's queue. A file keeps up to 8
|
||||
changed ranges (writes <512 bytes apart merge), so a region write sends its header and its chunk.
|
||||
- **Packets a tick at a time** [`?packets=each`]: the page–worker link carries the game's stream,
|
||||
length-prefixed, one message per flush (`ChannelLink`). The server flushes once a tick.
|
||||
- **Worker started early:** the world list and create screen start the worker, which bootstraps and
|
||||
builds the data fixer before a world is chosen (`WorldWorker.warmUp`).
|
||||
- **Stronghold searches wait for quiet** while other background work is queued (`backgroundQueued`).
|
||||
- **Surface writes** [`?surface=game`]: `SurfaceWrites` writes the material system's column as
|
||||
`ProtoChunk` would, but looks up heightmaps and build height once per chunk and skips the
|
||||
one-thread-safe palette check. Other chunk kinds go the game's way.
|
||||
- **Biome cells** [`?biomecells=game|verify`]: when all eight biome cells around a 4×4×4 group agree,
|
||||
`BiomeCells` answers without the blur's hashing.
|
||||
- **Build heights cached** [`?heights=game`]: `Heights` keeps each level's and chunk's bottom and
|
||||
height (they never change).
|
||||
- **Criterion codecs built once** [`?criteria=game`]: DataFixerUpper names codecs eagerly; one per
|
||||
trigger saves 90–140 ms of worker start.
|
||||
|
||||
Looked at and left: collision sweeps (already direct; `Heights` fixed their cost), merging dropped
|
||||
items (0.2%), the aquifer's search (~1%), the light engine (3%, spread thin), compiling density
|
||||
functions (26.3 already samples volumes), TeaVM's byte copies (~0.6 ms/MiB; volume was the cost).
|
||||
|
||||
## Verified
|
||||
|
||||
- `TerrainEquivalenceTest` runs the real overworld terrain step on 4×4 chunks, 4 areas, 3 seeds,
|
||||
with and without the changes: every block and heightmap identical (a deliberately broken writer
|
||||
fails it).
|
||||
- `SurfaceWritesTest`, `BiomeCellsTest`, `DataFileTest`, `JournalTest`, `InPlaceTest`,
|
||||
`ChannelLinkTest`, and the storage worker's tests.
|
||||
- Whole worlds (`worldgenServer` + `tools/worldgen/compare.py`) can't be compared exactly: two runs
|
||||
with the changes off already differ in 108–147 of 1,764 chunks (feature order between chunks).
|
||||
- `singleplayer.steps` passes in a worker and on the page.
|
||||
|
||||
## Results
|
||||
|
||||
Singleplayer benchmark against ADR 0040:
|
||||
|
||||
| | Desktop before | after | `laptop-floor` before | after |
|
||||
| --- | ---: | ---: | ---: | ---: |
|
||||
| Create world | 7.5 s | 5.9 s | 32.5 s | 27.1 s |
|
||||
| Save and Quit | 2.1 s | 1.0 s | 5.6 s | 3.7–4.2 s |
|
||||
| Reopen | 5.6 s | 5.3 s | 22.0 s | 20.8–21.7 s |
|
||||
| Page heap peak | 725 MB | 599 MB | 760 MB | 506–532 MB |
|
||||
| Longest GC pause, spawn / fly-through | 74 / 49 ms | 0.8 / 15 ms | | |
|
||||
| 1% low, spawn / fly-through | 42 / 36 | 53 / 48 | 17 / 10 | 27–30 / 14–23 |
|
||||
|
||||
- World generation changes alone (`laptop-floor`): create 30.7 → 27.1 s, and the server keeps up
|
||||
with the camera longer (44 → 72–80 sections drawn in the fly-through).
|
||||
- `?inplace=off` grows the worker heap 18–40 MB; `?packets=each` shows no measurable difference (kept
|
||||
for fewer wake-ups).
|
||||
|
||||
## Consequences
|
||||
|
||||
- Memory no longer grows with a world's size while it isn't open on the page.
|
||||
- A world handed to the worker in place can't be renamed by it (the store has no rename for a file
|
||||
another program holds). The page renames, reading region files first.
|
||||
- Opening a region file on the page suspends while it's read.
|
||||
- The desktop is unchanged.
|
||||
@@ -0,0 +1,71 @@
|
||||
# ADR 0042: Density functions' branches sampled where used, terrain helpers, and goals' flags as masks
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-08
|
||||
|
||||
## Context
|
||||
|
||||
On `laptop-floor` the singleplayer server worker is 99% busy in the fly-through, drawing 55 terrain
|
||||
sections against the desktop's 860. Worker time: noise 28%, surface 20%, features 11%, biomes,
|
||||
carvers and light ~10%, saving 5%. Idle at spawn, mobs are 28% (movement sweeps and goal selection).
|
||||
|
||||
Two things stood out in 26.3. A range choice sampled over a volume samples **both** branches over the
|
||||
whole volume before picking per point (and `lerp` both sides): the overworld's caves sampled the whole
|
||||
cave stack even in the sky. And the terrain step reads only the seed, nearby biomes and structure
|
||||
pieces, so it could run off the server's thread.
|
||||
|
||||
## Decision
|
||||
|
||||
Nothing here is a mod's code. Bracketed options turn a change off.
|
||||
|
||||
- **Branches sampled only where used** (`DensityBranches`) [`?densitychoices=game`]: sample a choice's
|
||||
input first, then each branch only over the rows some point takes (likewise `lerp`'s sides).
|
||||
Values are exact: rows start at multiples of 48 blocks so interpolated cells line up, and caches
|
||||
are sampled no more than before. Only on cell-corner volumes (on single-block volumes it was slower).
|
||||
- **Terrain step in helper workers** (`RemoteTerrain`) [`?terrainworkers=N`, **off by default**]: other
|
||||
copies of the game in child workers build chunks' terrain from a `TerrainJob` (biomes and nearby
|
||||
structure pieces); the server keeps two jobs per helper out and builds the rest. Off because it
|
||||
showed no gain (the desktop keeps up anyway; `laptop-floor`'s two cores are already full) and a
|
||||
helper costs 150–270 MB.
|
||||
- **Goal flags as masks** (`GoalFlags`) [`?goalflags=game`]: each goal's control flags and the
|
||||
selector's disabled flags as bitmasks, answered as the game's loops would.
|
||||
|
||||
Looked at and left: `min`/`max` laziness (4% slower), per-column row ranges (no fewer rows), the
|
||||
palette's last-index search (no gain), skipping same-block writes (0.3%), chunk-aware block sweeps
|
||||
(≤ 2%), cheaper save compression (done in ADR 0043).
|
||||
|
||||
### A Chrome renderer crash, found and fixed
|
||||
|
||||
With a helper, Chrome's renderer died in every run's second session. The renderer process hit
|
||||
Chrome's 16 GB sandbox limit in V8's compilation zone: TurboFan was compiling
|
||||
`teavm@initReflection`, one 559 KB function TeaVM generates. Once enough instances of the module had
|
||||
started (page, server, helper, over two sessions), V8 tiered it up and ran out of memory.
|
||||
`ReflectionMetadataGenerator` (teavm-patches) now splits it into ~4000-instruction functions, and
|
||||
`WasmGCModuleGenerator` splits the 5 MB start function the same way. With both, every run finished
|
||||
at a 3.8–4.0 GB peak. Players' builds without helpers could have hit it too after opening enough worlds.
|
||||
|
||||
## Verified
|
||||
|
||||
- `TerrainEquivalenceTest` with lazy branches on and off: every block and heightmap identical.
|
||||
- `RemoteTerrainTest`: 16 chunks built by a helper equal those built in place.
|
||||
- `GoalFlagsTest`: masks answer as the game's loops for every flag combination.
|
||||
- JVM terrain step: noise fill 5% faster, the whole step ~1.5%.
|
||||
|
||||
## Results
|
||||
|
||||
Singleplayer benchmark, Fast release, helpers off, changes off vs on:
|
||||
|
||||
| | Desktop off | on | `laptop-floor` off | on |
|
||||
| --- | ---: | ---: | ---: | ---: |
|
||||
| Create world | 5.9 s | 5.9 s | 27.2–27.4 s | 26.6–27.0 s |
|
||||
| Server tick at spawn | 4.2 ms | 4.2–4.6 ms | 15.3–17.3 ms | 13.7–13.8 ms |
|
||||
| Fly-through sections drawn | ~866 | ~866 | 78–90 | 88–108 |
|
||||
|
||||
On `laptop-floor` the idle tick fell from 15–17 to 14 ms (likely the goal flags); the rest is within
|
||||
noise. The desktop keeps up either way.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Terrain helpers stay available behind `?terrainworkers=N`; nothing starts one by default.
|
||||
- A game worker unwinds its fibers before it closes, as the page does on `pagehide`.
|
||||
- The desktop is unchanged (`worldgenServer` turns the lazy branches on with ADR 0041's changes).
|
||||
@@ -0,0 +1,93 @@
|
||||
# ADR 0043: Less garbage in world generation, the client jar compacted, faster saves, and wasm-opt and channel wakeups measured again
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-09
|
||||
|
||||
## Context
|
||||
|
||||
Left after ADR 0042: singleplayer's server worker is saturated on `laptop-floor`; memory headroom is
|
||||
thin (a 4 GB Chromebook gives the tab ~3 GB; page and worker hold 350–400 MB of heap each, the
|
||||
renderer 2 GB+); and small leads (channel wakeups, wasm-opt, cold start).
|
||||
|
||||
Heap snapshots showed ~50 MB in every copy of the game is the program itself (vtables, wrappers,
|
||||
type data). The page also held 27 MB of Unicode font (271,000 glyphs, three objects each), and both
|
||||
page and workers kept the whole 40 MB client jar in a buffer.
|
||||
|
||||
## Decision
|
||||
|
||||
Nothing here is a mod's code. Bracketed options turn a change off.
|
||||
|
||||
### World generation: less garbage
|
||||
|
||||
A quarter of the terrain step's allocated bytes (`TerrainStepBench` on the JVM) were positional
|
||||
randoms: three objects to draw one number. In WebAssembly GC each is a real allocation.
|
||||
|
||||
- **First draw without the random** (`PositionalRandoms`) [`?randoms=game`]: a Xoroshiro128++
|
||||
generator's first number is a function of its seeds, so compute it directly.
|
||||
`PositionalRandomsTest` checks 100,000 positions bit for bit.
|
||||
- **Density buffers reused** (`SurfaceBuffers`) [`?surfacebuffers=game`]: ore-vein rules filled four
|
||||
~200 kB float arrays per chunk, too large for V8's young space. A thread now reuses them.
|
||||
- **Chunks saved at zlib level 1** (`ChunkCompression`) [`?deflate=game`]: 2.7x faster than level 6,
|
||||
2.4 vs 2.0 kB a chunk; region sectors are 4 KiB, so files barely grow.
|
||||
|
||||
`TerrainEquivalenceTest` covers the first two.
|
||||
|
||||
### Memory
|
||||
|
||||
- **Client jar compacted** (`ZipArchive.compact`): only the entries a mount needs are copied out,
|
||||
still compressed. The page keeps 7.6 MB (assets and data packs); workers 4.4 MB (data packs,
|
||||
languages, root files) [`?workerjar=all`].
|
||||
- **Unicode font packed** (`PackedUnihex`) [`?unihex=game`]: glyph rows in one byte array (~9 MB),
|
||||
rebuilt on request. `PackedUnihexTest` checks every glyph.
|
||||
|
||||
### Small leads
|
||||
|
||||
- **wasm-opt on by default for the Fast release build**: `-O3 --closed-world`, with inlining off
|
||||
(`-aimfs 0 -fimfs 0 -ocimfs 0 -pii 0`). Under a minute on Fast. ADR 0034's inlining made the
|
||||
fly-through's slowest frames slower; without it they aren't, and the module is 4.6 MB smaller.
|
||||
`-Pteavm.noWasmOpt` leaves it out.
|
||||
- **Channel wakeups stay off on the page** (`?wakeups=channel`): 6% faster warm start, but in one of
|
||||
two singleplayer runs the page hung at spawn. The worker keeps them (ADR 0040).
|
||||
- **`-Pbenchmark.heapSnapshot`** now snapshots the server worker too.
|
||||
|
||||
Looked at and left: smaller allocations (biome search 5%, aquifer 1.5%, ore randoms 1.3%); V8's lazy
|
||||
compilation (turning it off didn't speed creation and slowed cold start by 2 s); the per-instance
|
||||
program memory (the compiler's; closed world trims some); the 12 s cold start.
|
||||
|
||||
## Results
|
||||
|
||||
`laptop-floor`, Fast release, singleplayer benchmark, medians:
|
||||
|
||||
| | Before | After | After, changes off |
|
||||
| --- | ---: | ---: | ---: |
|
||||
| Create world | 27.7 s | 28.1 s | 27.8 s |
|
||||
| Save and Quit | 4.0 s | 3.2 s | 3.7 s |
|
||||
| Page heap live, spawn / fly-through | 384 / 367 MB | 334 / 318 MB | 352 / 335 MB |
|
||||
| Peak renderer memory | 2389–2569 MB | 2265–2299 MB | 2275–2397 MB |
|
||||
| Fly-through 1% low / combat 1% low | 16.4 / 34.2 | 20.4 / 39.3 | 18.0 / 23.2 |
|
||||
|
||||
The page holds ~50 MB less (jar ~32, font ~17). Creation time is within noise; the fly-through drew
|
||||
12% more terrain.
|
||||
|
||||
wasm-opt, same build with and without:
|
||||
|
||||
| | Without | With |
|
||||
| --- | ---: | ---: |
|
||||
| Module raw / gzip | 38.5 / 12.4 MB | 33.6 / 11.2 MB |
|
||||
| Warm start | 8.0 s | 7.5 s |
|
||||
| Join | 16.0 s | 14.7 s |
|
||||
| Singleplayer create / open | 28.1 / 21.4 s | 26.5 / 20.3 s |
|
||||
| Server tick at spawn | 15.6 ms | 13.2 ms |
|
||||
|
||||
The fly-through's longest GC pause varies 11–42 ms across all builds; none holds the 16 ms budget
|
||||
every run. `laptop-floor`'s baselines were re-recorded on this build (the multiplayer ones were still
|
||||
Compatible's: lobby 32 vs 61 fps on Fast).
|
||||
|
||||
## Consequences
|
||||
|
||||
- The page holds ~60 MB less; each worker ~35 MB less outside its heap.
|
||||
- Fast release builds need Binaryen (fetched to `work/cache/binaryen/`, Linux x86-64 only so far);
|
||||
elsewhere use `-Pteavm.noWasmOpt`.
|
||||
- Browser-saved chunks take about a fifth more bytes inside the same sectors.
|
||||
- The worker sees only the jar's data packs and languages (`?workerjar=all` to check if a server
|
||||
ever needs more).
|
||||
@@ -0,0 +1,48 @@
|
||||
# ADR 0044: Defaults and fixes before M4
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-09
|
||||
|
||||
## Context
|
||||
|
||||
Six things players met before any of the client's own features: picking a server's version meant
|
||||
clicking a cycle button through some forty releases; a first start used Fancy graphics at render
|
||||
distance 16 on a Chromebook; the tab list showed no heads on offline-mode servers; every join showed
|
||||
the "chat messages can't be verified" toast and every message a not-secure mark; `/login` and a
|
||||
login plugin's password dialog showed the password as typed; and a respawn sometimes paused the game
|
||||
as if the player had pressed Escape.
|
||||
|
||||
## Decision
|
||||
|
||||
- **Version list.** The edit-server screen's version button opens `VersionSelectScreen`: every
|
||||
version in one scrolling list, newest first under "Auto", with a search box ("1.8" leaves the
|
||||
1.8 releases). A double-click, Enter or Done picks; the button shows the pick. No patch changed:
|
||||
ADR 0017's hook adds whatever widget `ServerVersions.button` returns.
|
||||
- **Potato graphics, the default.** A Potato preset before Fast (`GraphicsPreset.POTATO`, its
|
||||
values in `PotatoGraphics`): render distance 4, simulation distance 5 (the game's floor), biome
|
||||
blend off, no smooth lighting, clouds, entity shadows, mip levels or menu blur, minimal particles,
|
||||
entity distance 50%, the smallest cloud and weather ranges. New installs start on it, and the game
|
||||
applies a saved preset at every start as it always has; a saved Fancy stays Fancy. The benchmarks
|
||||
and screenshot diffs pin their own options and don't change.
|
||||
- **Heads in the tab list** whatever the server's mode: the game drew them only on online-mode
|
||||
servers. On Eagler servers they are the players' Eagler skins (ADR 0016).
|
||||
- **No secure-chat warnings.** Offline-mode servers sign no messages, so the join toast and the
|
||||
per-message not-secure and modified marks are off.
|
||||
- **Passwords as stars** (`HiddenPasswords`): in chat, the arguments of a login plugin's commands
|
||||
(`/login`, `/l`, `/register`, `/changepassword` and their aliases, with or without a namespace);
|
||||
in a server dialog, a text box whose label names a password. Only the drawing changes, through the
|
||||
box's formatter; the text sent is what was typed. A selection or click inside the stars lands by
|
||||
the hidden characters' widths, a small error in exchange for no change to `EditBox`'s measuring.
|
||||
- **No Escape on respawn.** The page turned the end of Pointer Lock while the game wanted the mouse
|
||||
into an Escape (the browser keeps the player's Escape from the page). A death screen releases the
|
||||
mouse and a respawn a tick later takes it back, before the page reports the release, so the
|
||||
release looked like the player's and paused the game. The event queue now remembers that it asked
|
||||
for the release (`DomEventQueue.exitAsked`); that release makes no Escape, and if the game wants
|
||||
the mouse again by then it asks for the lock again (a lock the page let go of comes back without a
|
||||
click; a click takes it back if not).
|
||||
|
||||
## Consequences
|
||||
|
||||
- Four new patches (budget raised to 124).
|
||||
- Login commands are still kept in the game's chat history as typed (`command_history.txt`), as
|
||||
in vanilla.
|
||||
@@ -0,0 +1,55 @@
|
||||
# ADR 0045: An Eagler server's pause menu, voice chat in a panel, the player on the title screen
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-09
|
||||
|
||||
## Context
|
||||
|
||||
EaglerXServer customizes its clients' pause menu (`pause_menu.yml`): a "server info" button (a
|
||||
store, rules, a web page), a Discord button, and small icons beside the menu's buttons and title.
|
||||
It sends this only to clients that ask for the `PAUSE_MENU` capability at login, which Incari
|
||||
didn't, so servers' buttons were missing. Voice chat (ADR 0019) was a "Voice Chat..." button in the
|
||||
pause menu that opened a settings screen; Eagler's 1.8 client puts the channel switch in the pause
|
||||
menu's top right corner, one click away.
|
||||
|
||||
## Decision
|
||||
|
||||
- **The pause menu message.** Incari asks for `PAUSE_MENU` (capability bit 4) and reads V5 message
|
||||
`0x18` (`EaglerPauseMenu` in `net`): the two buttons, their modes and addresses, and the icons
|
||||
(16-bit images up to 64×64, each named by a key such as `icon_discord_L`). `ServerPauseMenu`
|
||||
keeps it for the connection, uploads each image once, and releases them when the connection
|
||||
ends.
|
||||
- **Buttons.** Below the row of icon buttons: the server info button and the Discord button, side
|
||||
by side when both fit in half the width, else one a row. They open their address in a new tab;
|
||||
only `http` and `https` addresses open. A server info button meant for an embedded web view of
|
||||
an address opens that address in a tab instead. One that shows markup the server downloads to a
|
||||
web view isn't shown: the page has no web view, and the markup can't be opened in a tab without
|
||||
running the server's HTML on the client's own origin.
|
||||
- **No Server Links button** when the server sent buttons of its own: they take its place.
|
||||
- **Icons** are drawn 16×16 beside the text of the buttons they name. The server's own buttons
|
||||
centre an icon and their text as one group, as Eagler's client does; on the vanilla buttons (back
|
||||
to game, advancements, statistics, options, disconnect) and the "Game Menu" title they're drawn
|
||||
over the widgets beside the centred text, so no vanilla button changes. The background and
|
||||
watermark images aren't drawn.
|
||||
- **Voice panel.** `VoicePanel` in the pause menu's top right on servers with voice: the channel
|
||||
as one segmented control (Off, Nearby, Global), whether the microphone is live or the player is
|
||||
talking, everyone connected with who is talking lit and a mute toggle each, and a link to the
|
||||
full settings (`VoiceScreen`: volumes, proximity range). Its width leaves the menu's buttons
|
||||
clear down to a GUI 432 pixels wide. The pause menu's "Voice Chat..." button is gone.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Three patches in `PauseScreen`: the button hook replaces the voice button's, one more after the
|
||||
menu's widgets adds the panel and the icons, and one leaves out Server Links.
|
||||
- Embedded web views (server info markup, and the web view message API) wait for a sandboxed
|
||||
iframe over the canvas.
|
||||
|
||||
## The player on the title screen
|
||||
|
||||
The title screen's "Edit Profile (name)" link in the top left corner (ADR 0029) gives way to the
|
||||
player beside the main buttons, on the right (`TitleProfile`): their model in 3D with their skin
|
||||
(the game's skin preview, as Edit Profile shows it), turning toward the pointer, their name over
|
||||
their head on a faint plate like a name tag, and an "Edit Profile" button below. A click on the
|
||||
model opens Edit Profile too. The model waits for the entity models, which load just after the
|
||||
title screen first shows (ADR 0026). A screen too narrow to fit it keeps the corner link. The
|
||||
patch is ADR 0029's title screen hook, which now adds Incari's widgets itself.
|
||||
@@ -0,0 +1,62 @@
|
||||
# ADR 0046: The module framework
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-09
|
||||
|
||||
## Context
|
||||
|
||||
The client's features number in the dozens, many written in parallel by agents. Each needs an on/off switch,
|
||||
keybinds, settings with a screen, a HUD place, game events, and saved state. This builds that once:
|
||||
done when a sample module's settings screen and keybind come from its schema alone.
|
||||
|
||||
The look will be redone, so nothing may tie features to the game's widgets. And on a
|
||||
Chromebook, a feature that's off must cost nothing, and one that's on must not allocate on hot paths.
|
||||
|
||||
## Decision
|
||||
|
||||
- **`:framework`**, a strict module with no game types: `Module`, `ModuleSystem`, the event bus,
|
||||
settings, HUD elements, profiles. Only the JDK, JSpecify and Gson's tree API (`BoundaryTest`).
|
||||
- **Features are `features/<name>` projects** depending on `:framework` only. `:client` lists them
|
||||
in `incari.client.modules.Features`: no reflection or service loading (the browser's closed world
|
||||
can't see them). Toggle Sprint is the first.
|
||||
- **Adapters in `incari.client.modules`** are the only code seeing both sides: hooks fire events,
|
||||
`ModuleHud` draws, `GameKeys` reads binds.
|
||||
- **A module declares; the framework runs it:** settings as fields, HUD elements and listeners in
|
||||
the constructor. Listeners are subscribed only while enabled.
|
||||
- **Events** are channels with their own listener interface (`TICK`, `MOVEMENT`, `JOIN`, `LEAVE`;
|
||||
later ADRs add more). Listeners are an array replaced on (un)subscribe: firing allocates nothing,
|
||||
and an unheard channel costs a length check. A listener that throws is logged and its module
|
||||
turned off.
|
||||
- **Settings are a typed schema:** boolean, integer, decimal, choice, colour, keybind; each with an
|
||||
id (config key), name, tooltip, default, optional `visibleWhen` and `hidden()`. `SettingVisitor`
|
||||
makes a new kind fail to compile wherever it isn't handled. Reads are primitive.
|
||||
- **Keybinds use the game's key handling:** each `KeySetting` gets its own `KeyMapping`, outside
|
||||
Controls and `options.txt`. Every module has a toggle key (unbound by default). The module menu is
|
||||
Right Shift.
|
||||
- **HUD elements** draw on a `HudCanvas` in GUI units. Placement (anchor of nine, offsets, scale) is
|
||||
settings saved with the profile; offsets are hidden, for the editor (ADR 0049). In the browser
|
||||
they're drawn into the HUD's cached texture (ADR 0030).
|
||||
- **Colours are tones** (`Tone`: text, muted, accent, positive, warning, negative, background) that
|
||||
the theme resolves. Player-picked `ColorSetting`s are drawn as given.
|
||||
- **Profiles:** named JSON sets of module states and settings in `incari/modules/profiles/`. A new
|
||||
one copies the active one. Saved a second after the last change, or at once on closing a module
|
||||
screen or leaving a world. Reading is forgiving: bad values keep defaults, broken files aren't
|
||||
overwritten until something changes, unknown modules keep their entries.
|
||||
- **The UI is generated through one seam:** `incari.client.ui` (`Theme`, `Ui`, `ControlList`,
|
||||
`ListScreen`, `SettingControls`) builds the module menu, settings screens and profiles screen. The
|
||||
restyle replaces `Theme` and `Ui`, and every screen follows.
|
||||
- **Two patches:** `KeyboardInput.tick` (keys to `ModuleInput`) and `Hud.extractRenderState`
|
||||
(`ModuleHud` before chat). Ticks, the menu key and the pause button use existing hooks.
|
||||
|
||||
## Not yet (at the time)
|
||||
|
||||
- World-render and packet events come with their first users, in the framework's own terms (done in
|
||||
ADRs 0050–0053).
|
||||
- **Server feature control**: `Module.setEnabled` is the one way on, so a server veto goes there.
|
||||
- **Language files:** names are English for now.
|
||||
|
||||
## Consequences
|
||||
|
||||
- A feature is one class plus tests, a dependency line and a line in `Features`. `TestGame` fakes the
|
||||
game for tests.
|
||||
- `smokeModules` (desktop) and `modules.steps` (page) check it end to end.
|
||||
@@ -0,0 +1,51 @@
|
||||
# ADR 0047: The game's screens changed and redrawn without a patch each
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-10
|
||||
|
||||
## Context
|
||||
|
||||
The restyle reaches Incari's screens through `incari.client.ui` (ADR 0046), but players mostly see
|
||||
the game's: title, pause, options. Each change to one had been its own patch; a restyle of a dozen
|
||||
screens would add dozens of hooks in vendor code that moves every release. And it must change how
|
||||
everything looks, not just where it sits.
|
||||
|
||||
## Decision
|
||||
|
||||
Five hooks; the rest in `incari.client.ui`.
|
||||
|
||||
**Changing what's on a screen:**
|
||||
|
||||
- **`ScreenEdits.edit(type, edit)`:** after each layout (`init`, `rebuildWidgets`, `resize`), edits
|
||||
get an `EditedScreen` to find widgets by their label's translation key and move, resize, relabel,
|
||||
remove, or add Incari's. Edits state where things go, so they're idempotent across resizes; what
|
||||
they added is removed before they run again.
|
||||
- **`ScreenEdits.replace(type, replacement)`:** `Gui.setScreen` shows Incari's screen instead.
|
||||
|
||||
Edits match a screen's exact class. One that throws is logged and skipped. Nothing registered: a map check.
|
||||
|
||||
**Redrawing**, through one `GuiSkin` (`Skins.use`). Each method is asked first and returns whether
|
||||
it drew, so a skin takes what it knows and the game draws the rest:
|
||||
|
||||
- **`widget`:** a whole widget (with `Skins.cursor`).
|
||||
- **`sprite`, `spritePart`, `texture`:** any GUI sprite or texture by name, wherever drawn, HUD
|
||||
included. The name carries the state (`widget/button_highlighted`).
|
||||
- **`background`:** the default backdrop.
|
||||
|
||||
While a skin draws, its own calls aren't skinned again. A skin that throws is dropped and the game's
|
||||
look returns. No skin: a field read. With one: a call per sprite, so skins must not allocate.
|
||||
|
||||
## Limits
|
||||
|
||||
- Text is the game's font; a new font is a resource, not a hook.
|
||||
- Screens that draw their own backdrop (title, pause, death, chat) skip `background`; their sprites
|
||||
still go through the skin.
|
||||
- A screen that re-lays out without a rebuild or resize puts edited widgets back until its next layout.
|
||||
- Widgets inside lists aren't the screen's children, so edits can't reach them (the skin can).
|
||||
- A replaced screen's class is no longer what the game finds: check `instanceof` uses first.
|
||||
- Existing per-screen patches stay where they add widgets inside layouts.
|
||||
|
||||
## Consequences
|
||||
|
||||
- The restyle is a `GuiSkin`, edits and replacements; Incari's screens follow with no change.
|
||||
- `smokeScreens` checks edits (also after a resize), a replacement, a test skin, and a throwing skin dropped.
|
||||
@@ -0,0 +1,75 @@
|
||||
# ADR 0048: The client's look, Frost, in Potato and Normal presets
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-10
|
||||
|
||||
## Context
|
||||
|
||||
ADRs 0046 and 0047 left a seam for the restyle: Incari screens draw through `incari.client.ui`, game
|
||||
screens can be edited or replaced, and a `GuiSkin` can redraw any widget or texture. The maintainer
|
||||
picked **Frost** from mockups: translucent white glass over a cold dimmed backdrop, white text, an
|
||||
ice-blue accent (`#A9DCFF`), Red Hat Display, compact sizes. Most of the game's GUI is replaced;
|
||||
health, hunger and experience stay.
|
||||
|
||||
It must cost almost nothing on the reference Chromebook, so it comes in two presets.
|
||||
|
||||
## Decision
|
||||
|
||||
### Presets
|
||||
|
||||
`GuiPreset` in `incari/look.txt`, switched live from the module menu's sidebar. Same layout, colours
|
||||
and font in both:
|
||||
|
||||
- **Potato** (default): solid darker panels, no blur, no animation (hover gets an accent edge).
|
||||
- **Normal:** menu blur (even when the game's blur option is 0), eased hover glows, a light sweep on
|
||||
buttons, title snow.
|
||||
|
||||
The HUD is never blurred or animated: its cost is every frame's. It gets tinted glass.
|
||||
|
||||
### Shapes without a shader
|
||||
|
||||
`RoundRects` draws rounded fills, outlines and soft shadows in screen pixels from small
|
||||
anti-aliased nine-slice textures made once per size: one pipeline (`GUI_TEXTURED`), batched, no
|
||||
custom shader. `Icons` draws line icons the same way.
|
||||
|
||||
### The skin
|
||||
|
||||
`FrostSkin` redraws by sprite and texture name: buttons, sliders, fields, checkboxes, tabs,
|
||||
scrollers, tooltips, toasts, slots, hotbar, and every backdrop. `ScreenPanels` draws glass panels
|
||||
under edited or Incari-laid-out screens.
|
||||
|
||||
### Fonts
|
||||
|
||||
Red Hat Display (text) and Michroma (wordmark), both OFL, in **Incari's built-in pack**
|
||||
(`IncariPack`, always on top). The browser has no FreeType, so **every** TrueType provider loads
|
||||
through `SmoothFont` over a new `PlatformFonts`: FreeType on the desktop, a 2D canvas in the
|
||||
browser (`CanvasFonts`: glyphs drawn white, alpha read back; coverage from the `cmap`, `FontCmap`).
|
||||
Glyphs are drawn at the GUI scale so they stay sharp, and again on a scale change. Resource packs'
|
||||
TrueType fonts now work in the browser too.
|
||||
|
||||
### Screens
|
||||
|
||||
- **Title** (`TitleLook`, two hooks; `TitleScreen` stays the class): wordmark and icon buttons on the
|
||||
left, the player on a glass card on the right, language and accessibility top right, version and
|
||||
copyright at the foot. Realms, the splash and Friends are left out. (The backdrop is now the
|
||||
menus' photo, `MenuBackdrop`.)
|
||||
- **Pause** (`PauseLook`): one centred card. Voice and Eagler server icons keep working.
|
||||
- **Module menu** (`ModuleListScreen`): categories with counts on the left, the preset and profile
|
||||
below, a search field over module cards with switches; the gear opens settings.
|
||||
- **Containers** (`ContainerSkin`): inventory, chests, shulker boxes, hoppers, dispensers, crafting
|
||||
table and furnaces become dark glass with a rounded well per slot. Others keep their texture,
|
||||
cooled to slate, so what the game draws on it stays put.
|
||||
- **HUD** (`HudLook`): tab list, sidebar, chat and chat field as rounded tinted glass; modules' HUD
|
||||
panels rounded.
|
||||
|
||||
## Limits
|
||||
|
||||
- Older Incari screens (voice, Edit Profile, version list) use the game's widgets, which the skin draws.
|
||||
- Uncommon containers keep their texture's shapes.
|
||||
- Normal's eased effects reset when a screen is recreated.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Patches: blur radius, `SmoothFont` load and rescale, Incari's pack, title (two), tab list,
|
||||
scoreboard, chat and its field, container labels (two).
|
||||
- `smokeLook` screenshots the main screens and HUD in both presets and fails if the skin was dropped.
|
||||
@@ -0,0 +1,70 @@
|
||||
# ADR 0049: The HUD editor
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-10
|
||||
|
||||
## Context
|
||||
|
||||
ADR 0046 gave every HUD element a placement (one of nine anchors, offsets, a scale) and left the
|
||||
offsets for an editor. The player needs to see elements where they'll be in play, tell them apart
|
||||
from the game's HUD, move and resize them, and reset them.
|
||||
|
||||
A blurred backdrop separates movable elements from everything else. But Potato exists because a
|
||||
full-screen blur every frame is what a Chromebook can't spare (ADR 0048).
|
||||
|
||||
## Decision
|
||||
|
||||
### The editor
|
||||
|
||||
`HudEditorScreen` opens from **Edit HUD** beside the module menu's search, and from a module's
|
||||
settings when it has HUD elements. It draws every enabled module's elements through the HUD's own
|
||||
canvas, so what's shown is what play shows.
|
||||
|
||||
- **Frames:** each element on rounded glass, highlighted on hover, accent-edged when chosen, with a
|
||||
name tag, a resize handle and a bar showing its anchor side.
|
||||
- **Moving:** drag snaps edges and middles to the screen's sides (2 units in), its middle, and other
|
||||
elements, with guide lines. Shift or the Snap toggle places freely. Arrows nudge (Shift: 10). Each
|
||||
move takes the **nearest anchor** (`Anchor.nearest`), so placement holds when the window or GUI
|
||||
scale changes.
|
||||
- **Resizing:** scroll over an element, or drag its corner.
|
||||
- **Undo and reset:** Ctrl+Z per action; Reset for the chosen element or all.
|
||||
- **Right-click** opens the module's settings. With nothing to place, a card says so.
|
||||
- **Samples:** elements with nothing to show draw a sample while editing (`HudCanvas.editing()`);
|
||||
ones a setting hides for good report `isPlaceable() == false`.
|
||||
|
||||
A glass toolbar at the top (title, Snap, Reset, Done) with a caption that explains or shows the
|
||||
anchor and offsets mid-drag.
|
||||
|
||||
### The backdrop: blurred in both presets, cheap on Potato
|
||||
|
||||
Both presets blur the backdrop, lightly tinted. On **Potato**, `BackdropCache` redraws it **10
|
||||
times a second** and copies it to a texture after the blur; frames in between skip the level and
|
||||
HUD entirely and reuse the copy. Elements and toolbar draw every frame, so dragging stays smooth.
|
||||
Normal blurs every frame. Three hooks: `GameRenderer.extract`, `GameRenderer.render` (don't age
|
||||
pooled render targets on reuse frames), `GuiRenderer.draw`.
|
||||
|
||||
## Results
|
||||
|
||||
`laptop-floor`, Fast release, `hudeditor.txt`, 20 s at spawn:
|
||||
|
||||
| | HUD only | Pause menu | Editor, Potato | Editor, Normal |
|
||||
| --- | ---: | ---: | ---: | ---: |
|
||||
| 1% low (fps) | 32.8 | 12.5 | 36.6 | 50.2 |
|
||||
| p99 frame (ms) | 26.8 | 21.4 | 20.5 | 19.1 |
|
||||
| GPU (ms) | 6.4 | 7.2 | 2.3 | 8.1 |
|
||||
|
||||
All hold 60 fps at the median; the Potato editor's GPU cost is under a third of Normal's. A first
|
||||
version recreated the render targets on each refresh (the pool aged them on skipped frames): fixed,
|
||||
p99 34.2 → 20.5 ms.
|
||||
|
||||
## Consequences
|
||||
|
||||
- One patch (three hooks).
|
||||
- `:framework` gains `Anchor.nearest`, `HudElement.bounds/place/resetPlacement/isPlaceable`,
|
||||
`HudCanvas.editing()`, and `ModuleSystem.drawHud` for one element.
|
||||
- `smokeHudEditor` and `hudeditor.steps` (with a new `drag:` step) cover it.
|
||||
|
||||
## Not yet
|
||||
|
||||
- Grouping, multi-element alignment, a grid.
|
||||
- Elements of disabled modules aren't shown.
|
||||
@@ -0,0 +1,61 @@
|
||||
# ADR 0050: The first modules, and what they read of the game
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-10
|
||||
|
||||
## Context
|
||||
|
||||
The next modules players asked for are PvP and QoL staples: **Low Fire**, **No Hurt Cam**, **Armor &
|
||||
Potion View** (with readable durability), **Clear Chat** and **Custom Scoreboard** (the server's
|
||||
sidebar, placed by the player). Each needs something the framework didn't expose: equipment and
|
||||
effects, game options, a game HUD part to move, and a say over the fire overlay. As ADR 0046 requires,
|
||||
all in the framework's terms, no game types.
|
||||
|
||||
## Decision
|
||||
|
||||
### Framework additions (`incari.framework.game`)
|
||||
|
||||
- **`Game`** (`ModuleSystem.game()`): the local player (`PlayerView`), a sample player for the HUD
|
||||
editor, and game options. `Game.NONE` outside a game; `TestGame` with a `FakePlayer` in tests.
|
||||
- **`PlayerView`, `ItemView`, `EffectView`:** equipment per slot (count, damage, max) and effects as
|
||||
the game's HUD shows them (name, level, ticks left, category). Reused holders; names made once per
|
||||
language, so reading them allocates nothing.
|
||||
- **`HudCanvas.item`, `HudCanvas.effect`:** draw item and effect icons (with durability bar and count).
|
||||
- **Held options, `Module.holdOption(GameOption, value)`:** while on, the option takes the module's
|
||||
value. Off gives back the player's (kept in a hidden setting across restarts). Moving the game's
|
||||
slider turns the module off and keeps the player's choice. So far `TEXT_BACKGROUND_OPACITY`,
|
||||
`DAMAGE_TILT`.
|
||||
- **Game parts, `GamePartElement(GamePart)`:** draws a game HUD part (`SCOREBOARD`) where the player
|
||||
places it; the game skips it while held. Sized as the game draws it, so the editor works normally.
|
||||
- **`Events.FIRE_OVERLAY`:** listeners may lower the flames.
|
||||
|
||||
### Modules
|
||||
|
||||
| Module | Category | What it does |
|
||||
| --- | --- | --- |
|
||||
| Low Fire | Visual | Fire overlay lowered 0–25% (default 10%; measured: at 30% it's gone) |
|
||||
| No Hurt Cam | Visual | Holds Damage Tilt at 0% |
|
||||
| Armor & Potion View | HUD | Armor and held item with durability (% / uses / of max / none; green, amber below half, red below a fifth); effects with level and time left |
|
||||
| Clear Chat | HUD | Holds Text Background Opacity at 0 (not Chat Text Opacity, which would hide chat) |
|
||||
| Custom Scoreboard | HUD | The server's sidebar as a placeable, scalable element |
|
||||
|
||||
Strings are made only when what they say changes.
|
||||
|
||||
### Patches
|
||||
|
||||
Two: the fire overlay's pose lowered (`ScreenEffectRenderer.submit`), and the sidebar handed to
|
||||
`GameParts` (`Hud`). Clear Chat and No Hurt Cam need none.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Two patches, 17 changed lines.
|
||||
- `smokeFeatures` checks all five in a world (options held and given back, a slider turning Clear
|
||||
Chat off, the sidebar moved) and screenshots them.
|
||||
- More game data goes into `PlayerView` or `GameOption`; more movable HUD parts are `GamePart`s
|
||||
with two hooks each.
|
||||
|
||||
## Not yet
|
||||
|
||||
- The game's own effect icons (top right) still show beside Armor & Potion View.
|
||||
- Custom Scoreboard's extras (hide red numbers, background opacity) need hooks inside the sidebar.
|
||||
- Only the main hand is shown with the armor.
|
||||
@@ -0,0 +1,77 @@
|
||||
# ADR 0051: Minimap and waypoints
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-10
|
||||
|
||||
## Context
|
||||
|
||||
Players asked for a good-looking **minimap**, and **waypoints** with a name, colour and icon, shown
|
||||
on the minimap and over the world with their distance and an optional beacon-like beam. Both must be
|
||||
easy to use and cheap on the reference Chromebook.
|
||||
|
||||
The framework couldn't yet tell a feature where the player is, draw more than text and rectangles,
|
||||
follow the camera, draw into the world, keep non-setting data, or open screens. And the browser
|
||||
refreshes the HUD only a few dozen times a second (ADR 0030), so anything that turns with the camera
|
||||
would lag.
|
||||
|
||||
## Decision
|
||||
|
||||
### Framework additions
|
||||
|
||||
- **Player position:** `PlayerView.x/y/z()` (interpolated), `heading()`, `dimension()`, `isDead()`;
|
||||
`Game.world()` names the world stably (`server/<address>`, `world/<folder>`).
|
||||
- **Waypoints belong to the framework** (`incari.framework.waypoint`), since minimap and waypoints are
|
||||
separate features. One file per world, `incari/modules/waypoints/<world>-<hash>.json`, saved a
|
||||
second after a change, independent of profiles. `ModuleSystem.waypoints()`.
|
||||
- **Drawing:** `HudCanvas.shape`, `disc`, `ring`, `terrain` (the minimap), the `EDGE` tone, fractional `push`.
|
||||
- **Live HUD elements** (`HudElement.isLive()`): drawn every frame with the crosshair, not with HUD refreshes.
|
||||
- **Events:** `OVERLAY` every frame on a `WorldOverlay` (with `project`: a world point on screen, or
|
||||
which way to turn); `WORLD` during the world's submit, on a `WorldCanvas` (`beam`).
|
||||
- **Screens:** `Game.openWaypoints()`, `Game.editWaypoint()`; `ActionSetting` for a button in settings.
|
||||
|
||||
### Modules
|
||||
|
||||
| Module | What it does |
|
||||
| --- | --- |
|
||||
| Minimap (HUD) | Live map; round or square; turning or north-up; 7 zooms (= and -); waypoints (on the edge when beyond); compass; coordinates; world map on M; explored map remembered |
|
||||
| Waypoints (Utility) | A glass tag per waypoint (icon, name, distance), a beam, edge arrows for those off screen; N marks here, U lists them; deaths leave one |
|
||||
|
||||
- **Tags** are drawn on the overlay, not in the world: crisp at any distance, never hidden by
|
||||
terrain, placed every frame. Off-screen waypoints get arrows on the screen's edge, spread apart.
|
||||
- **Beams** are the game's beacon beam, so they look like one and terrain hides them. Beyond the fog
|
||||
they're moved in along the line of sight and shrunk, so a waypoint 600 blocks off still shows.
|
||||
- **Minimap terrain** (`MapTerrain`): a wrapping 512×512 texture, one texel per block. Each chunk is
|
||||
drawn once into its square (map colour, biome tint, slope shading, water depth). Under a ceiling
|
||||
(the Nether) it's a slice at the player's height. Up to 1.5 ms a tick, nearest first; nearby chunks
|
||||
redrawn every half second. Drawn as a triangle fan, so turning is free; no custom shader.
|
||||
- **Screens:** the list (search, nearest first, hide, edit, delete with a second click) and the
|
||||
editor (tag preview, 12 colours or hex, 8 icons, coordinates, Here, beam). Frost look; new icons.
|
||||
|
||||
### World map and remembered map
|
||||
|
||||
- **World map** (`WorldMapScreen`, M): drag, zoom round the pointer, the player as an arrow, waypoint
|
||||
tags. Click a waypoint to edit; right-click to add one. Each 512×512 region is a texture made as it
|
||||
comes into view; up to 48 kept while open.
|
||||
- **Remembered map** (`MapMemory`): every chunk the minimap draws is kept as its 256 colours, by
|
||||
32×32-chunk region, per world and dimension. With **Remember explored map** on (default), regions
|
||||
are saved to `incari/map/<world>/<dimension>/<x>.<z>.map` (deflated RGB, 100–250 KB a full
|
||||
region). Only top-down colours are kept: chunks would be tens of times larger.
|
||||
|
||||
### Patches
|
||||
|
||||
Two: the live HUD beside the crosshair (`Hud.extractRenderState`), and the world event after
|
||||
particles (`LevelRenderer.submitFeatures`).
|
||||
|
||||
## Consequences
|
||||
|
||||
- Two patches, 6 lines.
|
||||
- `smokeWaypoints` and `waypoints.steps` cover both modules, the screens, the world map and saving.
|
||||
- Remembered maps grow with exploring (100–250 KB per 512×512 blocks).
|
||||
- Cost while on: ≤ 1.5 ms a tick drawing new chunks, 1 MB of texture, a few draws per waypoint a
|
||||
frame. Off: nothing.
|
||||
|
||||
## Not yet
|
||||
|
||||
- Cave maps in the Overworld; entities on the map; another dimension's world map.
|
||||
- Waypoints shared from servers or in chat; per sub-world sets.
|
||||
- Teleport to a waypoint; sorting the list by name.
|
||||
@@ -0,0 +1,54 @@
|
||||
# ADR 0052: The HUD modules: Keystrokes, CPS, FPS, Reach, Coordinates, Shield & Totem
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-10
|
||||
|
||||
## Context
|
||||
|
||||
Next the player asked for the PvP clients' HUD staples: **Keystrokes**, **CPS**, **FPS Display**,
|
||||
**Reach Display**, **Coordinates**, and a **Shield & Totem HUD**. Each needs something the framework
|
||||
didn't offer: clicks, a hit's distance, held binds, frame rate, biome, item ids, cooldowns, counts.
|
||||
|
||||
## Decision
|
||||
|
||||
### Framework additions
|
||||
|
||||
- **Events:** `CLICK` (mouse presses over the world, no screen open) and `ATTACK` (an entity hit,
|
||||
with the reach from the eyes to where the crosshair met its box).
|
||||
- **`ClickCounter`:** a ring of 64 press times; `perSecond(now)`.
|
||||
- **`Game`:** `isDown(GameKey)` and `keyName(GameKey)` for the nine movement/attack/use binds as
|
||||
bound ("W", "LMB"); `fps()`; `millis()`; `item(id)`.
|
||||
- **`PlayerView`:** `biome()` (localized, cached) and `count(id)`. **`ItemView`:** `id()` and
|
||||
`cooldown()`.
|
||||
- **`TextElement`:** one line of text on glass, in a tone or a chosen colour, width kept steady as
|
||||
digits change. **`Tone.ON_ACCENT`.**
|
||||
- `TestGame`/`FakePlayer` fake all of it.
|
||||
|
||||
### Modules
|
||||
|
||||
| Module | Shows | Default place |
|
||||
| --- | --- | --- |
|
||||
| Keystrokes | W A S D, LMB/RMB with clicks per second, space; lit while held | Top right, below the minimap |
|
||||
| CPS | "12 \| 4 CPS" (left, right or both) | Left, stacked |
|
||||
| FPS Display | "120 FPS" (three formats), optional colour by rate | Left, stacked |
|
||||
| Reach Display | "3.04 blocks" for 3 s after a hit; long hits amber if asked | Left, stacked |
|
||||
| Coordinates | X Y Z, facing and axis, biome, the matching Nether/Overworld spot | Left, below |
|
||||
| Shield & Totem HUD | The shield's durability by wear, "Disabled" during an axe cooldown; totems carried | Beside the hotbar |
|
||||
|
||||
Keystrokes shows the player's own bindings (AZERTY reads "Z Q S D") and what the game reads as held,
|
||||
not Toggle Sprint's latch. Text is rebuilt only when it changes; none of these is live.
|
||||
|
||||
### Patches
|
||||
|
||||
Two, three lines each: `MouseHandler.onButton` (clicks) and `Minecraft.startAttack` (attacks).
|
||||
|
||||
## Consequences
|
||||
|
||||
- Two patches, six changed lines.
|
||||
- `smokeHudModules` clicks a villager, holds keys, and checks clicks, reach (~2.3 blocks), FPS,
|
||||
bind names, totem count, shield id and biome. `newmodules.steps` covers the page.
|
||||
|
||||
## Not yet
|
||||
|
||||
- Keystrokes lights at the HUD's refresh rate (every 50 ms in the browser), without a fade.
|
||||
- Reach is measured client-side; a server's lag compensation may differ.
|
||||
@@ -0,0 +1,61 @@
|
||||
# ADR 0053: The visual and combat modules: Cooldown, Crosshair, Freelook, Weather, Low Shield, 1.7
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-10
|
||||
|
||||
## Context
|
||||
|
||||
The second set the player asked for changes how the game looks: **Cooldown Indicator**,
|
||||
**Crosshair Editor** (presets, sliders, a 15×15 grid), **Freelook** (hold Left Alt; toggle and
|
||||
invert options; no per-server blocking, by choice), **Weather Changer** (client weather and a held
|
||||
time of day), **Low Shield**, and **1.7 Animations** (block-hit and held-item poses only).
|
||||
|
||||
## Decision
|
||||
|
||||
### Framework additions
|
||||
|
||||
- **Events:** `CROSSHAIR` (draw your own; the game's is then skipped), `TURN` (the mouse's turn,
|
||||
consumable), `CAMERA` (yaw and pitch, settable without turning the player), `HELD_ITEM` (per hand
|
||||
in first person: lower, legacy poses, swing while using). Each is one reused object and costs a
|
||||
length check when nobody listens.
|
||||
- **`Game`:** `attackStrength()`, `onTarget()`, `perspective()`/`setPerspective()`, `overrideSky(Weather, timeOfDay)`.
|
||||
- **`GameOption.ATTACK_INDICATOR`**, held by index; options gained `max()` so a held choice survives.
|
||||
- **`GridSetting`** with `GridScreen` (draw, erase, clear, reset, preview).
|
||||
- **`HudCanvas`:** coloured `disc`/`ring` and `arc`.
|
||||
|
||||
### Modules
|
||||
|
||||
| Module | Category | What it does |
|
||||
| --- | --- | --- |
|
||||
| Cooldown Indicator | Combat | Holds the game's indicator Off and draws the charge as a bar, ring or percentage; hidden when charged unless on a target |
|
||||
| Crosshair Editor | Visual | Cross, T, circle or dot from sliders, or a pixel grid; colour, opacity, on-target colour; presets |
|
||||
| Freelook | Visual | Left Alt (hold or toggle) turns the camera, not the player; release restores the view |
|
||||
| Weather Changer | Visual | Clear, rain, thunder or snow, and an optional held hour. Answers where the client reads weather; the server's weather runs on underneath |
|
||||
| Low Shield | Visual | First-person shield lowered (default 35%), optionally only when not blocking |
|
||||
| 1.7 Animations | Visual | Block-hit swing; 1.7's flat item, rod and sword-blocking poses (where swords block, ADR 0020) |
|
||||
|
||||
The **block-hit** only animates the arm on the client (`LivingEntity.swing`); no extra packet reaches
|
||||
the server. The **1.7 poses** are 1.7's own transforms, applied after undoing today's first-person
|
||||
display transform. Their numbers were checked against Animatium (a PolyForm Shield mod); none of its
|
||||
code is used, only the figures, which are Mojang's own.
|
||||
|
||||
### Patches
|
||||
|
||||
Four: crosshair blit skip (`Hud.extractCrosshair`); turn and camera (`MouseHandler.turnPlayer`,
|
||||
`Camera.alignWithEntity`); held item (`FirstPersonHandsAndItemsRenderer`, four hooks); weather
|
||||
(`Level`, `WeatherEffectRenderer`, `ClientClockManager`). Cooldown Indicator needs none.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Four patches, 42 changed lines.
|
||||
- `smokeVisualModules` screenshots every crosshair preset, the cooldown bar and ring (checking the
|
||||
game's option is held and given back), weather over the server's rain, Freelook, Low Shield and
|
||||
1.7 poses. `TestGame` gains matching fixtures. `newmodules.steps` covers the page.
|
||||
|
||||
## Not yet
|
||||
|
||||
- **Legal review of 1.7 Animations' figures before release** (numbers from Animatium, a
|
||||
PolyForm Shield mod, though they are Mojang's own).
|
||||
- 1.7 Animations isn't checked beside a real 1.7.10 client; the bow's pull isn't 1.7's.
|
||||
- Crosshair Editor blends normally; the game's inverts what's behind it.
|
||||
- Weather Changer's held time applies to the dimension's day clock only.
|
||||
@@ -0,0 +1,57 @@
|
||||
# ADR 0054: The screen modules: Shulker Tooltips, Screenshot Manager, Theme Editor
|
||||
|
||||
- Status: accepted; Screenshot Manager and the Theme Editor changed in ADR 0062 (the gallery is the
|
||||
client's; Theme is always on, with fonts)
|
||||
- Date: 2026-10-10
|
||||
|
||||
## Context
|
||||
|
||||
The third set the player asked for adds screens: **Shulker Tooltips** (contents at a glance), a
|
||||
**Screenshot Manager** (view, name, sort, download; F2 optionally to the clipboard), and a **Theme
|
||||
Editor** (presets, colours, opacity, rounding, live on menus and HUD, shared as a code; no extra
|
||||
fonts at the time, for download size).
|
||||
|
||||
## Decision
|
||||
|
||||
### Framework additions
|
||||
|
||||
- **Events:** `CONTAINER_TOOLTIP` (whether Shift is held; listeners set `preview`, `tinted`) and
|
||||
`SCREENSHOT` (the saved file's name, on the game thread).
|
||||
- **Menu buttons:** `Module.menuButton(...)` shows a module's buttons on the title and pause menus
|
||||
while it's on.
|
||||
- **`Game`:** `openScreenshots()`, `copyScreenshot()`, `applyTheme(ThemeColors)`, `clipboard()`,
|
||||
`copy()`. **`ThemeColors`** with `FROST`.
|
||||
- **`PlatformShell.setClipboardImage(png)`:** the browser's Clipboard API; false on the desktop.
|
||||
|
||||
### The theme became the player's
|
||||
|
||||
`Theme`'s colours and radii were constants. Now they're static fields every screen reads as it draws,
|
||||
and `Theme.apply` derives them all from `ThemeColors` (button edges from the text colour, HUD glass
|
||||
from the panel colour, readable text on the accent). Frost's own values are restored exactly.
|
||||
|
||||
### Modules
|
||||
|
||||
| Module | What it does |
|
||||
| --- | --- |
|
||||
| Shulker Tooltips | A container item's tooltip shows its slots nine across with counts, on the box's dye colour, in place of the first five names; optionally only with Shift |
|
||||
| Screenshot Manager | A gallery (`ScreenshotsScreen`): thumbnails sorted by date or name; a viewer with arrows; rename, delete (confirmed), download or copy; select several to download as one zip. "Copy to clipboard" for each F2 |
|
||||
| Theme Editor | Presets (Frost, Midnight, Ember, Mint, Rose, Mono) or custom colours, opacity and rounding, applied next tick; copy and paste theme codes (`incari-theme:…`) |
|
||||
|
||||
Thumbnails are made one a frame as they scroll into view (a full PNG decode costs tens of ms on a
|
||||
Chromebook). The gallery works on the screenshots folder, kept in OPFS.
|
||||
|
||||
### Patches
|
||||
|
||||
Two: `Screenshot.grab` (the event after saving) and the tooltip image path (`ItemStack`,
|
||||
`ClientTooltipComponent`, `ItemContainerContents`), answered from one event so they agree.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Two patches, 13 changed lines.
|
||||
- `smokeScreenModules` covers the tooltip, F2 events, the gallery and viewer, themes on menus and
|
||||
HUD, and Frost restored. `newmodules.steps` covers the page.
|
||||
|
||||
## Not yet
|
||||
|
||||
- Copying a picture works only in the browser.
|
||||
- The gallery has no search and no grouping by day.
|
||||
@@ -0,0 +1,29 @@
|
||||
# ADR 0055: The built-in packs in the page, and Old Textures
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-11
|
||||
|
||||
## Context
|
||||
|
||||
The game's built-in packs, **Programmer Art** (pre-1.14 textures) and **High Contrast**, are zips in
|
||||
the asset index, not the jar. The page never fetched them, so the Resource Packs screen listed
|
||||
neither. Players asked for **Old Textures**, a module that switches Programmer Art and follows the
|
||||
pack screen.
|
||||
|
||||
## Decision
|
||||
|
||||
- **Fetched at start** (`WebAssets`, 0.7 MB, before the game starts, since the repository lists them
|
||||
before the first reload) and **copied by `./incari build`**. Mojang's files on the builder's machine,
|
||||
as with sounds; nothing committed. A failed fetch leaves them out.
|
||||
- **`Game.packSelected(id)` / `selectPack(id, on)`:** select as the Resource Packs screen does (at
|
||||
the pack's default place, under Incari's fixed pack), then save and reload. No patch.
|
||||
- **`Module.followPack(id)`:** on turns the pack on, off turns it off; each tick the module's switch
|
||||
follows the game's pack, so the pack screen moves the module too. At start the game's choice wins
|
||||
(no extra reload).
|
||||
- **Old Textures** (Visual): `followPack("programmer_art")`, no other settings.
|
||||
|
||||
## Consequences
|
||||
|
||||
- 0.7 MB more on a first visit.
|
||||
- Toggling reloads resources, as the pack screen does: seconds on the floor device.
|
||||
- `smokeFeatures`, `PackSwitchTest`, `OldTexturesTest` and `old-textures.steps` cover it.
|
||||
@@ -0,0 +1,53 @@
|
||||
# ADR 0056: The look's first performance pass
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-11
|
||||
|
||||
## Context
|
||||
|
||||
The look (ADR 0048) builds screens from rounded rectangles, icons and shapes, each a small texture.
|
||||
Nobody had measured it. Four costs grew with the number of controls:
|
||||
|
||||
- **A shape was many render states:** a rounded rectangle was nine blits, each a state with its own
|
||||
pose copy, bounds, texture setup and lookup. A button was up to 26; the inventory over 800.
|
||||
- **The GUI places each state by searching what's under it,** which grows with the square of the
|
||||
states, and an edge over its fill always starts a new layer.
|
||||
- **A texture per corner size and icon,** so each change cost a draw call.
|
||||
- **The skin matched sprite names with an `equals` chain** (up to 35 comparisons) before every sprite.
|
||||
|
||||
## Decision
|
||||
|
||||
- **One atlas for the look's images** (`UiAtlas`): corners, icons, shapes, and a white square for
|
||||
plain fills, in shared 512-pixel pages, so they batch.
|
||||
- **One render state per shape** (`RoundRects.box`: shadow or glow, fill and edge as one object).
|
||||
Buttons, wells, tabs, toasts, panels, slot wells, chat field and HUD editor frames use it. Icons
|
||||
and shapes go straight in as plain blits. The title's 110 snowflakes are one state.
|
||||
- **Two accessors on `GuiGraphicsExtractor`** (one patch): the current scissor and a submit, so
|
||||
states built outside it clip inside scrolled lists. `Circles` now clips too.
|
||||
- **`FrostSkin.sprite` uses a map** from name to kind.
|
||||
- **A GUI player skin is redrawn only when it changes** (`SkinPictures`, one patch): the title
|
||||
screen's player was re-rendered every frame. The title player's turn now settles instead of easing forever.
|
||||
- **`Circles` uses a corner table;** menus stop building strings every frame.
|
||||
|
||||
Nothing looks different (checked with `smokeLook` and side-by-side crops).
|
||||
|
||||
## Results
|
||||
|
||||
`menus.txt` benchmark, desktop with CPU throttled 4x, Fast release, means per frame:
|
||||
|
||||
| Scenario | Extract (ms) | Render submit (ms) | Draws | GCs / 20 s |
|
||||
| --- | ---: | ---: | ---: | ---: |
|
||||
| HUD alone | 0.52 → 0.49 | 1.14 → 1.13 | 27 → 26 | 8 → 7 |
|
||||
| Module menu, Potato | 2.87 → 1.02 | 2.60 → 1.69 | 56 → 44 | 300 → 184 |
|
||||
| Pause menu, Potato | 1.29 → 0.62 | 1.85 → 1.48 | 51 → 44 | 226 → 117 |
|
||||
| Inventory, Potato | 7.13 → 0.75 | 3.41 → 1.80 | 57 → 48 | 170 → 97 |
|
||||
| Inventory, Normal | 7.12 → 0.71 | 3.58 → 1.96 | 68 → 54 | 170 → 112 |
|
||||
|
||||
The inventory's 7 ms was mostly the layer search over 800 blits. The page is capped at 60 fps, so
|
||||
the saving is CPU a Chromebook doesn't have.
|
||||
|
||||
## Left for later
|
||||
|
||||
- The screenshot gallery decodes full screenshots on the render thread for thumbnails.
|
||||
- The game's GUI sort boxes keys and hashes texture records on every comparison.
|
||||
- The atlas never frees a page; a GUI scale change paints every size again.
|
||||
@@ -0,0 +1,54 @@
|
||||
# ADR 0057: One HTML file (`./incari build --html`)
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-11
|
||||
|
||||
## Context
|
||||
|
||||
The goal: an offline HTML file a player opens from disk, as Eaglercraft's offline download
|
||||
works. ADR 0028 left it out because `file://` pages can't do what the folder relies on. Measured in
|
||||
Chromium:
|
||||
|
||||
- `fetch` of a neighbouring file fails, and so does `<script src>` unless it's a Blob URL.
|
||||
- Module workers can't start from a Blob URL; classic ones can.
|
||||
- A worker can't read the page's Blob URLs, only its own.
|
||||
- OPFS throws; IndexedDB works (shared with Blob URL workers). No service worker.
|
||||
|
||||
The game loads files from the page and from four kinds of worker (storage, mesher, the server worker
|
||||
and its terrain helpers), each fetching by URL.
|
||||
|
||||
## Decision
|
||||
|
||||
- **`./incari build --html [--out <file>]`** writes the web folder (without sound files) and
|
||||
`:app-web:singleFile` (`SingleFile`) packs it into one file, default `dist/incari.html`.
|
||||
- **Every file is a `<script type="application/x-incari-file">`** with path, type and base64
|
||||
contents (gzipped where it saves a tenth). Service worker, `.htaccess` and `README.txt` stay out.
|
||||
- **A file shim in every realm** (`offline.ts`): `fetch` of an embedded file answers from a Blob;
|
||||
`importScripts` and `new Worker` of embedded scripts start classic workers from the shim's own
|
||||
source, which installs the shim, receives the files (shared Blobs), then runs the script
|
||||
(`import()` for modules, with relative imports rewritten). Everything else (WebSockets, servers)
|
||||
goes to the browser as usual.
|
||||
- **Lazy decoding:** scripts are decoded at once; everything else on first fetch, so the unpicked
|
||||
build and unused languages are never decoded. Workers ask the page for files they lack.
|
||||
- **Two hooks** where scripts load without `fetch` (`boot.ts` and `game-worker.ts` use
|
||||
`incariFiles.url`). The game's Java code is unchanged.
|
||||
- **The notice travels with the file:** a comment at the top says never to share it; `SingleFile`
|
||||
only overwrites its own files; the build refuses an output git would track.
|
||||
- **`browserCheck -Pbrowser.html=<file>`** runs checks against a file.
|
||||
- **The folder's client jar is cut to resources only** (`WebFolder.resourcesOnly`): 41 → 12 MB, for
|
||||
both outputs.
|
||||
|
||||
## Results
|
||||
|
||||
87 MB with both builds (languages, panorama, font and packs 32 MB, Compatible 28, Fast 15, jar 10);
|
||||
~60 MB with `--only fast`. From `file://` in headless Chromium: title at 60 fps in both builds; in
|
||||
Fast, singleplayer creates, saves, survives a reload from IndexedDB and reopens. Firefox reaches the
|
||||
title. Not measured: the Chromebook, Firefox singleplayer, Compatible singleplayer.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Undecoded file text stays in the DOM (15–28 MB for the unpicked build, 24 for languages), and the
|
||||
browser parses the whole file before the loader starts.
|
||||
- The file was silent at first; ADR 0062 added every sound but music, re-encoded smaller.
|
||||
- Every page opened from disk shares one origin in Chrome, so copies of the file share worlds.
|
||||
- Licensing is unchanged: it's a build, for the person who made it.
|
||||
@@ -0,0 +1,95 @@
|
||||
# ADR 0058: Incari accounts and the online service (client side)
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-12
|
||||
|
||||
## Context
|
||||
|
||||
Friends, messages, cosmetics and seeing who else uses Incari need an identity that lasts across
|
||||
servers. A Minecraft name can't be it: on offline-mode and Eagler servers anyone can take any name.
|
||||
|
||||
Incari runs its own online service. Its server is closed source and not in this repository; the
|
||||
protocol is public ([`docs/online-protocol.md`](../online-protocol.md)). This ADR is the client side.
|
||||
|
||||
Already decided: accounts are **optional**; a **username and password** only (no email or personal
|
||||
data); **recovery codes** instead of email; cosmetics belong to the account; players can block.
|
||||
|
||||
Constraints: many players are students playing at school, so collect little and never let strangers use the
|
||||
service to find someone. Schools may block the service but not game servers, and the game mustn't
|
||||
notice. The page may run from `file://` (origin `null`). The browser has only WebSockets.
|
||||
|
||||
## Decision
|
||||
|
||||
### Connection
|
||||
|
||||
- **One `wss://` connection**, opened after the title screen on the background pool, never holding
|
||||
up a join. JSON text frames with numbered requests, answers and events. The first message each way
|
||||
states the protocol version.
|
||||
- **URL set at build time** (`incari.online.url`; empty turns accounts off). No keys or secrets in
|
||||
the client.
|
||||
- **Back-off:** 1 s doubling to 5 minutes with jitter, reset after a minute connected. Offline, the
|
||||
game carries on; nothing waits on the service.
|
||||
|
||||
### Accounts
|
||||
|
||||
- **Sign-up:** username (3–16 of `[A-Za-z0-9_]`, unique ignoring case, separate from any Minecraft
|
||||
name), password (10+ characters, not a common one), and a **proof of work** sized for about a
|
||||
second on the reference Chromebook, solved on the background pool, in place of a CAPTCHA.
|
||||
- **Recovery codes:** ten at sign-up, shown once with Copy and Download, and the player confirms
|
||||
saving them. One code plus a new password resets it. No password and no code: the account is
|
||||
lost, and the screens say so.
|
||||
- **Sign-in** returns a session token, stored in `incari/online/session.json` (never the password).
|
||||
- **Account screen** from the title screen's player card (not a module): Sign In, Create Account,
|
||||
Forgot Password; signed in, Change Password, New Recovery Codes, Sign Out, Sign Out Everywhere,
|
||||
Delete Account. Password fields are starred whole (`HiddenPasswords`).
|
||||
- **Errors are general:** a failed sign-in says only "wrong username or password", and rate limits
|
||||
look the same, so usernames can't be probed.
|
||||
|
||||
### Presence and lookups
|
||||
|
||||
- **Joining a world** reports a `serverHash` (SHA-256 of the normalized address, or a relay code),
|
||||
the Minecraft name there, and the plain address only if "Show friends which server I'm on" is on
|
||||
(default on; friends only). Singleplayer sends nothing. Leaving clears it.
|
||||
- **Lookups:** the client sends tab-list names; the service answers only for names an account has
|
||||
reported on the asker's own `serverHash` right now, with a per-server id (so accounts can't be
|
||||
followed between servers), friend status and cosmetics. Two accounts claiming one name get nothing.
|
||||
- **Modules see it** through `ModuleSystem.online()` (`incari.framework.online.Online`): signed in,
|
||||
account name, `incariPlayer(UUID)`, friends, events.
|
||||
|
||||
### Blocking and reporting
|
||||
|
||||
- **Blocks are on accounts** and **enforced by the service**: no requests, no messages, neither shown
|
||||
to the other as an Incari player. The blocked player isn't told.
|
||||
- **Reports** carry a reason; the service keeps the reported account's recent messages to the reporter.
|
||||
|
||||
### Code
|
||||
|
||||
- **`:online`** (depends on `platform-api`, `framework`): connection, protocol, session store, proof
|
||||
of work, presence and lookups. No game types; tested against an in-process fake.
|
||||
- **`client`'s `incari.client.online`:** the screens, and a tick that reports joins and reads the
|
||||
tab list, so no patch is needed.
|
||||
- **`framework`'s `incari.framework.online`:** the `Online` view, events, a test fake.
|
||||
|
||||
## Consequences
|
||||
|
||||
- With the service blocked, the game is unchanged apart from "offline" on the account screen.
|
||||
- The service learns, per signed-in player: username, server hashes and names there, the plain
|
||||
address if shared, friends, blocks, messages, and connection IP. Its privacy notice says how long.
|
||||
- `serverHash` keeps plain addresses out of storage and logs; it isn't protection against someone
|
||||
with the database and a list of popular servers.
|
||||
- Different addresses for one network split players into groups that can't see each other (accepted).
|
||||
- A stored token is readable by anything in the page's origin. The page loads no third-party
|
||||
scripts, and must stay that way. Sign Out Everywhere is the remedy.
|
||||
- The service must accept origin `null` for offline HTML builds; it yields nothing without credentials.
|
||||
|
||||
## Built (2026-10-12)
|
||||
|
||||
- `:online`: `OnlineService`, `WorldPlayers`, `ServerHash`, `ProofOfWork` (4,096 nonces a step, no
|
||||
allocation), `SessionStore`, `Backoff`, `Credentials`, `RecoveryCodes`.
|
||||
- `incari.framework.online`: `Online`, `IncariPlayer`, `FakeOnline`.
|
||||
- `incari.client.online`: the account screens on one `FormScreen`.
|
||||
- `tools/onlinedev` serves the fake service on `ws://127.0.0.1:8090/v1/ws` for trying the screens.
|
||||
- `smokeOnlineA` + `smokeOnlineB`: two clients make accounts, see each other, go through friends,
|
||||
messages and blocking (ADR 0059), then delete their accounts. Passed against Incari's service.
|
||||
- Since built: the Incari badge (ADR 0062).
|
||||
- Friend requests from the tab list were settled by ADR 0059 (by per-server id).
|
||||
@@ -0,0 +1,78 @@
|
||||
# ADR 0059: Incari chat: friends, messages and the chat menu
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-12
|
||||
- Builds on: ADR 0058 (accounts and the online service)
|
||||
|
||||
## Context
|
||||
|
||||
ADR 0058 left friends, messages, and where blocking and reporting happen in a world for this ADR.
|
||||
The client's documents set the wire format.
|
||||
|
||||
Decided by the maintainer:
|
||||
|
||||
- **One place for people: the Incari chat menu**, from a key or a button below the chat box.
|
||||
- **Laid out like Discord:** people on the left, the conversation on the right.
|
||||
- **Friends always above other Incari players**, and styled differently.
|
||||
- **Messages and friend requests can each be turned off completely.**
|
||||
- **Block, Add Friend, Accept and the like are easy to reach.**
|
||||
- **No age gate:** no real names, active moderation, free blocking. An age question only teaches
|
||||
people to type a higher age.
|
||||
|
||||
## Decision
|
||||
|
||||
### The chat menu
|
||||
|
||||
- **Opens with the Friends key** (O) and an **Incari Chat** button below the chat box (with an
|
||||
unread count). Mojang's Friends overlay needs a Microsoft account, so the key was dead; one patch
|
||||
hands it to `ChatMenu.toggle`. The button is a `ScreenEdits` edit, no patch.
|
||||
- **Left bar:** Add Friend; **Friend Requests** (Accept and Decline on the row, Cancel for sent);
|
||||
**Friends** (online first, presence dot, server if shared); **On This Server** (other Incari
|
||||
players, with skin faces, below every friend); your own strip with Chat Settings.
|
||||
- **Conversation:** a header with labelled Unfriend/Add Friend, Block (second click within 4 s),
|
||||
Report. Messages grouped by sender, Discord-style. Sending shows dimmed; refused shows red "Not
|
||||
delivered". Scroll up for older pages.
|
||||
- **Chat Settings:** who can message you, friend requests on/off, sharing your server, Blocked
|
||||
Players, account.
|
||||
- **Signed out**, it explains accounts and offers Sign In. If the service lacks friends support, it
|
||||
says so; blocking and reporting still work.
|
||||
- **Toasts** for messages and requests while the menu is closed.
|
||||
|
||||
### Friends
|
||||
|
||||
- **Requests go to a username, or to an Incari player on your server** (by `pid`). Usernames are
|
||||
shared only between friends; sending a request shares yours.
|
||||
- **A request to someone with requests off, or across a block, answers `ok` and is never
|
||||
delivered.** Unknown usernames are `bad_request`.
|
||||
- **Crossing requests make a friendship.** Friends see each other's usernames, online state, and
|
||||
server if shared. **Blocking a friend ends the friendship** on both sides.
|
||||
|
||||
### Messages
|
||||
|
||||
- **Who can message you:** `everyone` (friends and Incari players on your server), `friends`
|
||||
(default), or `nobody`. Refused or blocked messages both answer `closed`, indistinguishably.
|
||||
- **Friends' messages are kept 30 days** and delivered later, with unread counts and history pages.
|
||||
- **Same-server messages** go by `pid` and live only in the client while both are there (the service
|
||||
keeps them for reports, never as history).
|
||||
- **≤ 500 characters**, trimmed. Shown at once as sending, then sent or failed.
|
||||
|
||||
### Code
|
||||
|
||||
`:online`'s `Social` and `OnlineService` requests (`FakeService` answers them); `client`'s
|
||||
`ChatMenuScreen`, `ChatMenu`, `ChatToast`, `Avatars`, and new icons. Wire format in
|
||||
`docs/online-protocol.md` (new types only; older services answer `bad_request`).
|
||||
|
||||
## Consequences
|
||||
|
||||
- With messages `nobody` and requests off, nobody can reach the player through Incari; they can
|
||||
still reach out themselves.
|
||||
- A `pid` conversation can't continue after either player leaves the server.
|
||||
- The Friends key opens Incari Chat; Mojang's friends screen never worked without a Microsoft account.
|
||||
- One more patch.
|
||||
- Tests: `SocialTest`; tried on the desktop against `tools/onlinedev` with scripted peers;
|
||||
`smokeOnlineA` + `smokeOnlineB` end to end (see each other, `pid` request, messages, a block, accounts deleted).
|
||||
|
||||
## Open
|
||||
|
||||
- Group conversations, read receipts and typing indicators aren't planned.
|
||||
- Unread counts for same-server players live only in the client.
|
||||
@@ -0,0 +1,54 @@
|
||||
# ADR 0060: The update notice
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-12
|
||||
- Builds on: ADR 0058 (the online service)
|
||||
|
||||
## Context
|
||||
|
||||
Incari Client is published as source, and players play builds that whoever hosts them made
|
||||
(`./incari build`, `docs/self-hosting.md`). Nothing told a player, or the person hosting their
|
||||
build, that a newer release is out. The maintainer asked for a notice on the title screen when there is
|
||||
one, linking to the public GitHub repository, with the information coming through the backend, and
|
||||
for dev builds never to show it (tests aside).
|
||||
|
||||
The client had no version of its own until now: only the game's (26.3).
|
||||
|
||||
## Decision
|
||||
|
||||
- **The client has a version**, `incari.version` in `incari.properties` (`0.1.7` now), raised with
|
||||
each release, and the public repository's URL, `incari.repository`
|
||||
(`https://github.com/incari-client/incari-client`). `:client`'s `buildInfoSource` writes
|
||||
both into `incari.client.IncariBuild`, with `RELEASE`: whether the build is a release build
|
||||
(`-Pteavm.release`, which `./incari build` and `:app-web:webFolder` require).
|
||||
- **The service names the latest release in its `hello` answer** (`release: {"version"}`,
|
||||
`docs/online-protocol.md`). Every connection says hello, signed in or not, so no extra request
|
||||
and no new connection. `OnlineService.latestRelease()` keeps the last one named, checked against
|
||||
`Releases`' form (one to four whole numbers) so nothing else the service sends reaches the screen.
|
||||
- **The client compares**, and shows the notice only when the named release is newer than its own
|
||||
(`Releases.newer`). A service answering `update` (this protocol no longer served) shows it too,
|
||||
without a version.
|
||||
- **The URL is the client's, not the service's.** The notice always leads to the built-in
|
||||
repository, through the game's own link confirmation (`ConfirmLinkScreen`), so a wrong or
|
||||
compromised service can't send players elsewhere.
|
||||
- **Release builds only.** A dev build's version is the one being worked toward, and its developer
|
||||
doesn't need telling. Tests turn it on: `-Dincari.updates=on` on the desktop
|
||||
(`-Pincari.updates=on` for `:app-desktop:run`), `?updates=on` on the page.
|
||||
`tools/onlinedev --release <version>` names a release to test against.
|
||||
- **On the title screen**, centered at the top: "Incari Client 0.2.0 is out", with a "GitHub" hint
|
||||
and a tooltip, in the menu buttons' look. It's laid out with the screen, hidden until the service
|
||||
answers, and kept clear of the small screens' links and the language and accessibility buttons.
|
||||
It isn't dismissible: it goes away when the build is updated.
|
||||
|
||||
## Consequences
|
||||
|
||||
- With no online service (`incari.online.url` empty, or unreachable), there's no notice.
|
||||
- The backend has to be told the latest version at each release (its configuration), as well as
|
||||
`incari.version` being raised here. A release whose `incari.version` wasn't raised would tell its
|
||||
own players to update to what they have only if the backend were ahead of it.
|
||||
- Switching between release and dev builds rewrites `IncariBuild`, so `:client` recompiles the
|
||||
classes that use it.
|
||||
- Tests: `:online`'s `ReleasesTest` and `OnlineServiceTest` (`release` from hello, ill-formed ones
|
||||
ignored), `:client`'s `UpdateNoticeTest` (a dev build never shows it; newer shown, the same or
|
||||
older not). The notice was checked on the desktop against `tools/onlinedev --release 0.2.0`: shown
|
||||
at the top, its link confirmation opening the repository's URL.
|
||||
@@ -0,0 +1,98 @@
|
||||
# ADR 0061: Cosmetics: the Wardrobe, worn cosmetics, emotes and personal effects
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-12
|
||||
- Builds on: ADR 0058 (cosmetics belong to the account), ADR 0046 (modules), ADR 0048 (the look)
|
||||
|
||||
## Context
|
||||
|
||||
ADR 0058 made cosmetics belong to an Incari account, and its lookups already carry cosmetic ids.
|
||||
This ADR decides what they are, how they're drawn and picked, and how the service learns what's worn.
|
||||
|
||||
Asked for: capes (animated too), hats, wings and back items, name tag colours, trails, emotes, saved
|
||||
outfits, and personal effects only the player sees; easy and familiar to use; a switch to hide
|
||||
others' cosmetics.
|
||||
|
||||
Constraints: nothing may cost a frame where it isn't seen (4 GB Chromebook); no Mojang art; no
|
||||
one-of-a-kind cosmetics (they'd let an account be followed between servers); the service is one
|
||||
WebSocket, no HTTP.
|
||||
|
||||
## Decision
|
||||
|
||||
### Two kinds
|
||||
|
||||
- **Worn cosmetics** (others see them): capes, hats, wings and back items, name tags, trails (one of
|
||||
each), and emotes (owned and played). Picked in the **Wardrobe**, not the module menu.
|
||||
- **Personal effects** are ordinary modules only the player sees: Block Outline, Hit Color, Enchant
|
||||
Glint, Hit & Kill Effects.
|
||||
|
||||
### Catalog and art
|
||||
|
||||
- **37 cosmetics** in `:online`'s `Catalog`: 7 capes (4 animated), 6 hats, 4 back items, 8 name tags,
|
||||
4 trails, 8 emotes. Ids `<slot>.<name>` never change. All free for now; the service decides ownership.
|
||||
- **Art is painted in code** (`CosmeticArt`, `CosmeticModels`): no images, nothing of Mojang's. Moving
|
||||
capes repaint 10x a second, only while seen in the last 2 s.
|
||||
- **The service sends only ids;** unknown ids are skipped, so the catalog can grow on the service first.
|
||||
- **No uploads, no unique cosmetics.**
|
||||
|
||||
### Drawing
|
||||
|
||||
| Cosmetic | How |
|
||||
| --- | --- |
|
||||
| Hats, back items | One render layer (`CosmeticsLayer`) through the game's model submits, so instancing takes them. Hidden under helmets and elytras; not drawn past 48 blocks or on invisible players |
|
||||
| Capes | The game's own cape with the cosmetic's texture, so physics, elytra and the Cape option all work. A backpack hides the cape |
|
||||
| Name tags | Restyle the name unless the server colours it (a team colour means something) |
|
||||
| Trails | The game's particles behind a moving player: every other tick, ≤ 12 a tick in total, within 32 blocks |
|
||||
| Emotes | Pose arms and head at the end of `setupAnim`, eased over 4 ticks; legs still walk. Your own emote turns the camera to face you; moving ends it |
|
||||
|
||||
`Cosmetics` works out each player's `Worn` once, when their list or emote changes, not per frame.
|
||||
|
||||
### Wardrobe
|
||||
|
||||
- **Laid out like the module menu:** kinds on the left with counts, a card grid, the player in 3D on
|
||||
the right. Hover tries on; click wears; click again (or None) takes off. The preview turns to show
|
||||
capes and wings and can be dragged.
|
||||
- **Outfits:** up to 12 saved per device; **Take Off All**.
|
||||
- **Under the preview:** "Incari players see these" or "Only you see these" with Sign In, and the
|
||||
**Show others' cosmetics** switch (per device).
|
||||
- **Opens from** the title card's Cosmetics button, Incari Settings, and the module menu.
|
||||
- **Emote wheel:** hold **G** in a world.
|
||||
|
||||
### Service sync
|
||||
|
||||
- `:online`'s `Wardrobe` keeps worn, owned, outfits and the switch in `incari/online/wardrobe.json`.
|
||||
Everything works without an account (you see your own).
|
||||
- Changes apply at once; `equip` is sent once clicking stops (≤ 1/s), and after a reconnect.
|
||||
- On sign-in the account's wardrobe wins, unless it wears nothing and the device does: then the
|
||||
device's carries over.
|
||||
- Protocol: `wardrobe`, `equip`, `emote`, their events, and `not_owned`. A service without them
|
||||
answers `bad_request` and the client stays device-only.
|
||||
|
||||
### Personal effects
|
||||
|
||||
- **Block Outline:** colour, opacity, width, optional fill. High contrast keeps the game's outline.
|
||||
- **Hit Color:** the hurt tint's colour and strength (repaints the overlay texture's rows).
|
||||
- **Enchant Glint:** the glint textures repainted in the chosen colour; off restores the game's.
|
||||
- **Hit & Kill Effects:** one of 10 particle effects on hits, bigger on kills (within 3 s), optional sound.
|
||||
- Framework: `Game.overrideBlockOutline`, `overrideHitColor`, `overrideGlintColor`, `effectOnTarget`,
|
||||
`Effect`, and the `KILL` event.
|
||||
|
||||
### Patches
|
||||
|
||||
Four: a field on `AvatarRenderState` and the layer in `AvatarRenderer`; emotes' pose in
|
||||
`PlayerModel.setupAnim`; Block Outline in `LevelRenderer.submitBlockOutline`; Hit Color in `OverlayTexture`.
|
||||
|
||||
## Consequences
|
||||
|
||||
- No cost for a player who wears and sees none: the layer returns at once.
|
||||
- Others' cosmetics need both players signed in on the same server address, with a service that
|
||||
speaks cosmetics. Singleplayer and LAN show only your own.
|
||||
- New cosmetics need a client release for their art (until art can be fetched), but no protocol change.
|
||||
- `smokeCosmetics` and `WardrobeTest` cover it.
|
||||
|
||||
## Not yet
|
||||
|
||||
- Fetching new art from the service.
|
||||
- Earning or buying cosmetics (`owned` is ready; selling needs Mojang's commercial guidelines checked first).
|
||||
- Whole-body emotes, shoulder pets, a hand position module.
|
||||
- Cosmetics in the tab list.
|
||||
@@ -0,0 +1,64 @@
|
||||
# ADR 0062: Incari Settings, and the 2026-10-12 batch
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-12
|
||||
- Builds on: ADRs 0019, 0039, 0046, 0048, 0054, 0058–0061
|
||||
|
||||
## Context
|
||||
|
||||
One batch of seventeen features and two fixes, with these decisions made up front:
|
||||
|
||||
- **Short Swords:** first-person swords smaller, with a slider; other items unchanged.
|
||||
- **An Incari icon**, drawn in code (there was only the wordmark).
|
||||
- **Theme fonts:** a few open fonts in Incari's pack, loaded only when picked.
|
||||
- **Usage counts:** on by default with a switch; anonymous, once a day.
|
||||
- **Featured server:** Carrotcraft, pinned, clearly Sponsored, not deletable; replaceable by the service.
|
||||
- **Incari's badge** beside other Incari players' names, with an opt-out.
|
||||
- **Presets:** 1.8 PvP, Modern PvP, QoL (module lists in `Presets`).
|
||||
- **Feedback** to GitHub Discussions, **bugs** to Issues.
|
||||
- **Shared worlds** through Eaglercraft's public relays; **the recorder** as Eaglercraft 1.8's.
|
||||
- **The pause menu** keeps one Incari button.
|
||||
|
||||
## Decision
|
||||
|
||||
| Item | What was built |
|
||||
| --- | --- |
|
||||
| Incari Settings | One pause-menu button with the new icon (`Icons.INCARI`, a hexagon with an I). `IncariSettingsScreen` opens the module menu, HUD editor, Wardrobe, screenshot gallery, recorder, chat and account, and holds the device's own switches (`ClientSettings`, `incari/settings.txt`) |
|
||||
| Screenshots | No longer a module: the gallery is the client's, from Incari Settings. "Copy screenshots" is a switch there |
|
||||
| Always-on modules | `Module.alwaysOn`: on from load, hidden from cards and presets, no toggle key. Theme is one: **Theme** in the module menu's sidebar |
|
||||
| Theme fonts | `UiFont`: Red Hat Display, Minecraft (pixel), Inter, Nunito, Poppins, JetBrains Mono, Michroma. The four new ones are OFL, subset to 406 characters (72 KB gzip together). `SmoothFont.useFont` swaps the font in place, scaled to Red Hat Display's metrics. Share codes gain an eighth field; old codes still paste |
|
||||
| Short Swords | `HeldItem.sword()` and a scale; 40–100%, default 70%, optionally not while blocking |
|
||||
| Presets | `ModuleSystem.applyPreset`: switch to a profile of the preset's name (copied the first time) with exactly its modules on; settings kept |
|
||||
| Featured server | `incari.featured` in `incari.properties`; `hello` may replace it. `FeaturedServers` adds them on each load, never saves them, and protects them from edit and delete; a **Sponsored** label |
|
||||
| Usage counts | `count`: random install id, version and build kind, once a UTC day; off in Incari Settings. The service keeps a keyed hash per day (35 days) |
|
||||
| Badge | Account setting "Show others I use Incari" (default on). `Badges` puts one glyph of a bitmap font (`incari:badge`) before the name tag, the tab list name and the first mention of the player's name in each chat line (matched by tab list name, since most servers send chat as plain text): no new drawing in the world. Only signed-in players see badges |
|
||||
| Screen recorder | `PlatformRecorder` (browser only): canvas + game sound (+ mic) into a `MediaRecorder` (MP4 or WebM), downloaded on stop. F8 or Incari Settings; blinking REC. ~19 MB a minute in memory |
|
||||
| Shared worlds | World Options' LAN shares a worker world through a relay (`RelayHost`): a join code in chat, up to 8 players. WebRTC lives on the page (`WorldSharing`) and relays to the worker (`GuestLink`). Incari hosts send a `HostHello`, so Incari guests join natively; Eaglercraft 1.8 clients can't join an Incari host (would need ViaRewind) |
|
||||
| Repository and links | `github.com/incari-client/incari-client`; Report Bugs → issue template; Give Feedback → Discussions |
|
||||
| Mojang's social features | Player Reporting removed; every Friends button opens Incari Chat |
|
||||
| Tab title | Stays "Incari Client" |
|
||||
| Death waypoints | Removed when the player returns within 4 blocks after being 8 away |
|
||||
|
||||
### Fixes
|
||||
|
||||
- **Text drawn over itself:** the game's shadow and bold redraw text a whole GUI unit away, which
|
||||
reads as a second copy with anti-aliased fonts. `SmoothFont` uses half a unit.
|
||||
- **Missing sounds:** a failed first download left a sound silent all session and held its channel.
|
||||
Downloads now retry three times (`Fetch.bytesRetrying`); a sound that still fails plays a moment
|
||||
of silence so the channel returns, and retries five seconds later (`sound-retry.steps`).
|
||||
- **The HTML file's sounds:** it had none. Now it carries every sound but music, re-encoded by ffmpeg
|
||||
as 22 kHz Ogg Vorbis (84 → 40 MB; file 87 → 133 MB). Without ffmpeg, only common sounds (~10 MB).
|
||||
|
||||
## Alternatives rejected
|
||||
|
||||
- **Fonts from Google Fonts at run time:** a third-party request from school devices, and nothing offline.
|
||||
- **A drawn quad or entity for the badge:** a font glyph rides the name tag's existing drawing and culling.
|
||||
- **Data channels moved into the worker:** Chrome can't hand them over reliably.
|
||||
- **ViaRewind for Eaglercraft 1.8 guests:** another GPL component, and a 26.3 world shown to 1.8 loses most blocks.
|
||||
|
||||
## Verified
|
||||
|
||||
- Desktop: `smokeScreenModules`, `smokeLook`; unit tests across the framework, Theme, Short Swords,
|
||||
Waypoints, `:online` (`Adr0062Test`), `:net` (`RelayHostTest`), `FeaturedServersTest`.
|
||||
- Chrome: `incari-settings.steps` (recording, sounds), `share-host.steps` + `share-guest.steps` (a
|
||||
guest joins, sees the world, chats). A pattern `switch` broke TeaVM's linking; `RelayHost` uses `instanceof`.
|
||||
@@ -0,0 +1,62 @@
|
||||
# ADR 0063: The modules' first performance pass
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-14
|
||||
|
||||
## Context
|
||||
|
||||
A new benchmark script, `features.txt`, plays the page's own world with every HUD and play module
|
||||
on (`?modules=`, a development option) and with none, standing at spawn and flying east over new
|
||||
terrain. With all on, the page spent about 1 ms more CPU a frame at 4x throttle, a third more than
|
||||
without. The modules' own code was careful; the cost was under them:
|
||||
|
||||
- **The minimap redrew every drawn chunk on a timer**, changed or not: 2 to 3 chunks of 256 columns
|
||||
a tick, each with a texture upload and a world-map record.
|
||||
- **Its refresh loop read the clock up to 729 times a tick.** In the browser each reading is a call
|
||||
out to the page.
|
||||
- **The player's view was rebuilt on every call** (equipment, sorted effects, position), 30 times
|
||||
or more a refresh with a full HUD. Coordinates looked the biome up three times a refresh; Totems
|
||||
counted the inventory three times.
|
||||
- **Saving the explored map deflated every changed region in one tick**, every 30 seconds.
|
||||
|
||||
## Decision
|
||||
|
||||
- **The minimap redraws a chunk only when the game marks it changed**, through one patch: a hook
|
||||
beside the particle light's in `LevelExtractor.setSectionDirty`, which every block change, light
|
||||
update and chunk load passes. Changed chunks near the player redraw at most every half second,
|
||||
the rest every second. A redraw that comes out the same isn't uploaded or recorded.
|
||||
- **The minimap's tick reads the clock only after a redraw.**
|
||||
- **The player's view refreshes once a frame and once a tick** (`ModuleGame.newTick`, and the
|
||||
frame's partial tick). The biome's name is kept until the player changes block; an item count
|
||||
until the next refresh.
|
||||
- **The HUD canvas keeps the last 128 text widths** (by hash), forgotten when the font changes and
|
||||
every 64 draws.
|
||||
- **The explored map saves one region a tick** when its half minute comes round.
|
||||
- **The minimap's round mesh uses `Circles`' corner table**, not two trig calls a corner a frame.
|
||||
- **The pixel-grid crosshair's outline is drawn as runs**, not four 1x1 fills a lit cell.
|
||||
|
||||
Nothing looks different: the benchmark's HUD and minimap screenshots match, and `smokeWaypoints`,
|
||||
`smokeHudModules`, `smokeVisualModules` and `smokeFeatures` pass.
|
||||
|
||||
## Results
|
||||
|
||||
`features.txt`, desktop, CPU throttled 4x, Fast release, CPU a frame (tick + extract + render
|
||||
submit). Mean of runs: before 2, after 3 with modules; 2 each without.
|
||||
|
||||
| Scenario | Modules | Before (ms) | After (ms) | Over none, before → after |
|
||||
| --- | --- | ---: | ---: | ---: |
|
||||
| Standing | none | 3.06 | 3.16 | |
|
||||
| Standing | all | 4.02 | 3.65 | +0.96 → +0.49 |
|
||||
| Flying | none | 4.45 | 4.44 | |
|
||||
| Flying | all | 5.51 | 5.31 | +1.06 → +0.87 |
|
||||
|
||||
The tick's share is gone: 1.54 → 1.26 ms standing (1.28 with none), 1.42 → 1.23 flying (1.11). The
|
||||
page is capped at 60 fps, so the saving is CPU a Chromebook doesn't have.
|
||||
|
||||
## Left for later
|
||||
|
||||
- **Drawing remains:** about 0.25 ms extract and 0.3 ms render submit a frame. `?drawcensus` counts
|
||||
9.3 GUI draws a frame with all modules against 1.3 with none, mostly the minimap's. It draws every
|
||||
frame, and its backdrop, terrain, rim, arrow, badges and letters stack into separate GUI layers;
|
||||
each pipeline change in a layer is a draw.
|
||||
- `Circles` gives a circle a side every 0.8 pixels round; fewer would look the same.
|
||||
@@ -0,0 +1,95 @@
|
||||
# ADR 0064: TeaVM 0.16.0
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-20
|
||||
|
||||
## Context
|
||||
|
||||
TeaVM 0.16.0 (2026-10-02) is mostly C backend work, but it also fixes several of the bugs
|
||||
`tools/teavm-patches` carried for the browser build, adds class library methods, makes some
|
||||
WebAssembly GC code faster, and ships WebGPU bindings. The patches are copies of TeaVM's own
|
||||
classes, so each one was merged onto 0.16.0's source (three-way, with 0.15.0 as the base) and
|
||||
checked by hand.
|
||||
|
||||
## Decision
|
||||
|
||||
Pin TeaVM 0.16.0 (and its jzlib 1.1.3, unchanged).
|
||||
|
||||
**Patches dropped**, 0.16.0 having the same fix: `WasmTypeInference`, `TThrowable`, `Heap`,
|
||||
`WasmGCInstructionGenerationVisitor`.
|
||||
|
||||
**Patches cut down** to what 0.16.0 still lacks:
|
||||
|
||||
| Class | Still ours | Now TeaVM's |
|
||||
| --- | --- | --- |
|
||||
| `CoroutineTransformation` | Nullable block types; nullable locals | The type after a suspending `c ? a : b` |
|
||||
| `WasmGCSupertypeFunctionGenerator` | Binary search of tag ranges (ADR 0026) | `instanceof Item[]` |
|
||||
| `TByteBufferImpl`, `TByteBufferNative` | Absolute `getLong(int)` keeps the position | Absolute bulk `put` |
|
||||
| `TCollections` | `unmodifiableCollection` lookups | `unmodifiableSet` and `unmodifiableMap` lookups |
|
||||
| `TDefaultPath` | `resolve` | `iterator`, `equals` |
|
||||
|
||||
**Patches rebased** with the fix unchanged: `TTemplateCollections`, `ReflectionMetadataGenerator`,
|
||||
`Fiber` (`Fiber.Jspi`), `TObject`, and the rest as they were. The probes that guarded the dropped
|
||||
patches still run, now guarding TeaVM's fixes.
|
||||
|
||||
**A new patch: the coroutines' fiber checks.** 0.16.0 has every coroutine call
|
||||
`Fiber.isPresentAndSuspending(fiber)` after each call that may suspend, and
|
||||
`isPresentAndResuming(fiber)` in its prologue, where 0.15 called `fiber.isSuspending()` and
|
||||
`fiber.isResuming()`. The new ones accept a null fiber, which takes a test and a branch: twice the
|
||||
code. Profiles of the lobby showed the game's own small methods (`ChunkPos.isValid`,
|
||||
`LevelHeightAccessor.isInsideBuildHeight`, `getMaxY`, `ItemStack.isEnchanted`) no longer inlined
|
||||
into their callers, their bodies unchanged: V8 spends its inlining budget on the checks first. The
|
||||
Compatible build was 17% slower in the lobby. `CoroutineFunctions` (with `WasmGCDependencies`
|
||||
linking the instance methods) goes back to 0.15's checks. The game runs coroutines only on fibers,
|
||||
so the fiber is never null there. Reading the field in `isPresentAndSuspending` instead of calling
|
||||
`isSuspending` won back only half; typing coroutine values as 0.15 did (no `forceNullable`) won
|
||||
nothing.
|
||||
|
||||
**Using what 0.16.0 adds:**
|
||||
|
||||
- `web-classlib`: `RandomAccessFile.read()` is TeaVM's own (it now reads bytes unsigned);
|
||||
`LocaleAdditions` uses `Locale.of`.
|
||||
- `WebGpuCallProbe` uses `org.teavm.jso.webgpu` (`GPUDevice`, `GPUBindGroup`,
|
||||
`GPURenderPassEncoder`) and record-style `@JSProperty` getters. It keeps one overload TeaVM's
|
||||
binding lacks: `setBindGroup` with a range of the offsets array, without which each draw would
|
||||
allocate a subarray.
|
||||
- With no code: `Math.min`/`max` as WebAssembly instructions, `getEnumConstants` cached
|
||||
(`Enum.valueOf`, `EnumSet`, `EnumMap`), `System.getLogger` (Via's snakeyaml now links it instead
|
||||
of having it removed).
|
||||
|
||||
Not taken: the C backend, Maven toolchains. Nothing in the survey's rules covered what 0.16.0 adds.
|
||||
|
||||
**Found on the way, fixed here:** `buildManifest` could hash the module while `teavm` was still
|
||||
writing it, in the same run (`mustRunAfter` now orders them). The page then had a manifest for the
|
||||
last build, and a benchmark's cold start right after a compile never reached its first frame.
|
||||
And `checkDownloadSize` failed before measuring: three loader scripts had no classification, and
|
||||
two limits were already passed (`index.html` with its inline images, the pack with Incari's own
|
||||
textures and fonts); they're raised in `download-budget.properties`, which says why.
|
||||
|
||||
## Results
|
||||
|
||||
The desktop (Ryzen 5 9600X, RX 9060 XT), CPU throttled 4x as a stand-in for the floor laptop,
|
||||
which was down. Release builds; CPU a frame is tick + extract + render submit; means of runs.
|
||||
|
||||
| Build | Runs | Flythrough (ms) | Combat (ms) | Lobby (ms) | Lobby fps | Warm start (s) | Join (s) |
|
||||
| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
|
||||
| Compatible, 0.15.0 | 3 | 5.15 | 5.04 | 33.07 | 27.8 | 9.75 | 21.9 |
|
||||
| Compatible, 0.16.0 without the fiber checks | 3 | 5.54 | 5.73 | 38.55 | 24.3 | 10.08 | 21.4 |
|
||||
| Compatible, 0.16.0 | 2 | 5.03 | 5.20 | 32.59 | 27.9 | 9.68 | 19.9 |
|
||||
| Fast, 0.15.0 | 2 | 3.51 | 3.14 | 17.89 | 50.8 | 7.83 | 16.4 |
|
||||
| Fast, 0.16.0 | 2 | 3.28 | 2.96 | 17.68 | 51.8 | 7.73 | 15.6 |
|
||||
|
||||
Two runs of one build differ by up to 12% in flythrough and combat and 6% in the lobby, so 0.16.0
|
||||
is as fast as 0.15.0, not measurably faster. Memory is unchanged (lobby live heap 361 against
|
||||
362 MB).
|
||||
|
||||
The modules grew: Compatible 66.3 to 68.2 MB raw (21.7 MB gzip), Fast 33.0 to 34.7 MB. Not broken
|
||||
down; by its source, 0.16.0 gives nearly every class a supertype function, where 0.15 gave one only
|
||||
to classes something tested against, and its field metadata grew for `Field.get*`/`set*`. Well
|
||||
inside the budget (40 MB gzip).
|
||||
|
||||
## Left for later
|
||||
|
||||
- Report upstream: the fixes still in `tools/teavm-patches`, and the fiber checks' cost to inlining.
|
||||
- `FileInputStream.read()` still reads bytes signed, and `RandomAccessFile`'s `"rw"` still
|
||||
empties the file; `web-classlib` still covers both.
|
||||
@@ -0,0 +1,41 @@
|
||||
# ADR 0065: Wispcraft: Java servers through a Wisp proxy
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-25
|
||||
- Builds on: ADR 0009 (the transport), ADR 0017 (a version per server)
|
||||
|
||||
## Context
|
||||
|
||||
A page has only WebSockets, so the browser build joins only Eagler servers (ADR 0016).
|
||||
[Wispcraft](https://github.com/MercuryWorkshop/wispcraft) lets Eaglercraft join plain Java servers
|
||||
by tunnelling TCP over [Wisp](https://github.com/MercuryWorkshop/wisp-protocol), a protocol for TCP
|
||||
streams over one WebSocket, through a public proxy. The maintainer asked for the same, switched per
|
||||
server on the add and edit server screens, like the version.
|
||||
|
||||
## Decision
|
||||
|
||||
- **Transport, not a proxy in the page.** `incari.net.wisp.WispConnection` is a `NetConnection`: a
|
||||
WebSocket to the proxy, one Wisp v1 stream to the server, its bytes passed up as TCP's. The game's
|
||||
own TCP pipeline (framing, encryption, compression) and Via run on top unchanged. Wispcraft
|
||||
re-implements the protocol in JavaScript; Incari already has the game's.
|
||||
- **v1 only.** No `Sec-WebSocket-Protocol` header, so v2 proxies speak v1. Flow control is honoured
|
||||
(CONTINUE); what's sent between flushes goes as one DATA packet.
|
||||
- **SRV through the proxy.** A host with no port asks `1.1.1.1:53` over DNS-over-TCP on a second
|
||||
stream, as the game does over JNDI. No answer: the address as written.
|
||||
- **Per server, saved with it.** `ServerData.incariWisp` (on/off and the proxy, default Wispcraft's
|
||||
`wss://anura.pro/`). The edit-server screen's version button is halved and a Wispcraft button sits
|
||||
beside it (a screen edit, no patch); it opens a screen to switch it and set the proxy.
|
||||
- **The last proxy is remembered.** Done saves it to `incari/wisp-proxy.txt` at once; a server
|
||||
not yet set up (off, default proxy) starts from it, so it's typed once.
|
||||
- **Routing by thread.** The connect screen and the pinger name the server before resolving
|
||||
(`WispServers.route`); the resolver hook then hands back a `WispAddress` with no DNS lookup.
|
||||
`ServerConnections` gives it the plain pipeline. `ws://` addresses never go through Wisp.
|
||||
|
||||
## Limits
|
||||
|
||||
- **Offline-mode servers only**, like any join from Incari: there's no Microsoft sign-in, which
|
||||
Wispcraft adds for online-mode servers. (Superseded: ADR 0070 adds it.)
|
||||
- Everything the player sends passes through the proxy; the screen says so. On an online-mode
|
||||
server it's encrypted once the login handshake is done (ADR 0070).
|
||||
- A server's transfer packet to another host keeps the server's choice only when the game reuses its
|
||||
list entry.
|
||||
@@ -0,0 +1,51 @@
|
||||
# ADR 0066: Schematics, written clean-room
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-10-25
|
||||
- Builds on: ADR 0002 (the license)
|
||||
|
||||
## Context
|
||||
|
||||
Players asked for Litematica. Litematica and malilib are LGPL-3.0. Incari's Minecraft exception
|
||||
(ADR 0002) can't be added to their code, so a port would have to stay LGPL in its own modules, carry
|
||||
rebuild duties for anyone hosting a build, and risks LGPL §2 (a modified library that depends on the
|
||||
application may have to go plain GPL). The author can't be expected to answer. A port is close to a
|
||||
rewrite anyway: mixins become patches, malilib duplicates `framework`, the renderer must move to
|
||||
`GpuDevice`.
|
||||
|
||||
## Decision
|
||||
|
||||
- **Clean-room implementation.** No Litematica or malilib code. Nobody writing it reads their source.
|
||||
Work from the file format and observed behaviour only.
|
||||
- **Compatible, not branded.** Reads `.litematic` files. Not called Litematica.
|
||||
- **Formats:** `.litematic` first; vanilla structure `.nbt` and Sponge `.schem` after. All are NBT.
|
||||
- **Where code goes:** `features/schematics`: format readers, placement, material list, verifier,
|
||||
no game types. `client` adapter: block-state lookup, world reads, ghost rendering through
|
||||
`GpuDevice`. Hooks are patches, per AGENTS.md.
|
||||
- **First version:** load, place, move, rotate, mirror, ghost render, material list, highlight
|
||||
missing and wrong blocks. Not in scope: easy-place, schematic editing and saving, area tools.
|
||||
|
||||
## `.litematic` format
|
||||
|
||||
Gzipped NBT. Enough to implement without reading Litematica:
|
||||
|
||||
- Root: `Version` (int), `MinecraftDataVersion` (int), `Metadata` (compound: `Name`, `Author`,
|
||||
`EnclosingSize`, `TotalBlocks`, `TimeCreated`, ...), `Regions` (compound, one entry per region).
|
||||
- Region: `Position` and `Size` (`x y z` ints; size components can be negative, meaning the region
|
||||
extends the other way from `Position`), `BlockStatePalette` (list of `{Name, Properties}`),
|
||||
`BlockStates` (long array), `TileEntities`, `Entities`, `PendingBlockTicks`,
|
||||
`PendingFluidTicks`.
|
||||
- `BlockStates`: palette indices, `max(2, ceil(log2(paletteSize)))` bits each, packed tightly so
|
||||
an entry can span two longs (unlike vanilla's padded chunks). Index order is
|
||||
`y * sizeX * sizeZ + z * sizeX + x` over absolute sizes.
|
||||
- Upgrade block states older than the target's `MinecraftDataVersion` with the game's DataFixer.
|
||||
|
||||
Check each point against real files before relying on it.
|
||||
|
||||
## Consequences
|
||||
|
||||
- No LGPL modules, no extra notices, no rebuild duties on hosted builds.
|
||||
- Reviewers reject code that mirrors Litematica's structure or names. `./incari copycheck` covers
|
||||
only game code, so this is review-enforced.
|
||||
- AI-written code: the model may have seen Litematica in training. Implement from this ADR and real
|
||||
files, and keep the design Incari's own.
|
||||
@@ -0,0 +1,31 @@
|
||||
# ADR 0067: Custom Sky: resource packs' OptiFine skies
|
||||
|
||||
- Status: proposed
|
||||
- Date: 2026-10-30
|
||||
- Builds on: ADR 0046 (modules), ADR 0007 (the renderer's backend API)
|
||||
|
||||
## Context
|
||||
|
||||
Most PvP resource packs ship a custom sky in OptiFine's format: `optifine/sky/world0/sky<N>.properties`
|
||||
(MCPatcher's `mcpatcher/sky/world0` in older packs), each naming a texture of a cube's six faces in a
|
||||
3 by 2 grid, with fade times, a blend and a rotation. The game ignores them. Players asked for them.
|
||||
|
||||
## Decision
|
||||
|
||||
- **A module, Custom Sky** (`customsky`), off by default, with a brightness. It parses the files
|
||||
(`SkyLayer`, no game types) and asks for them through `Game.showPackSkies`.
|
||||
- **Two hooks in `SkyRenderer`**: `extractRenderState` reads the time and the weather as shown
|
||||
(so Weather Changer's held time and weather apply), and `render` draws the layers after the
|
||||
sunrise, before the sun, moon and stars, as OptiFine does. A new `SkyRenderer` (made after every
|
||||
resource reload) means the packs may have changed: no reload listener.
|
||||
- **The end sky's shader, nine pipelines.** Each OptiFine blend is a pipeline over
|
||||
`core/position_tex_color` with OptiFine's blend factors, so the browser needs no new shader.
|
||||
- **Loaded only while on.** Sky textures are large; they're loaded the first frame the module is on
|
||||
and released when it's off.
|
||||
|
||||
## Limits
|
||||
|
||||
- Overworld only. `biomes`, `heights`, `days`, `transition`, `sun.properties` and
|
||||
`moon_phases.properties` aren't read yet: a layer shows everywhere, every day.
|
||||
- The face layout, rotation axis and blend factors follow OptiFine's; check them against a pack in
|
||||
OptiFine before calling it exact.
|
||||
@@ -0,0 +1,85 @@
|
||||
# ADR 0068: An experimental Rust build on Horizon
|
||||
|
||||
- Status: proposed
|
||||
- Date: 2026-11-01
|
||||
- Builds on: ADR 0001 (patch-only repo), ADR 0036 (Fast and Compatible builds), ADR 0046 (modules)
|
||||
|
||||
## Context
|
||||
|
||||
[Horizon](https://github.com/horizon-rust/horizon) (MIT) is Minecraft: Java Edition 26.3 rewritten
|
||||
in Rust and checked against the Java game by differential harnesses. A fork,
|
||||
[horizon-web](https://github.com/nobuildersnotools/horizon-web) (branch `web`), compiles its client
|
||||
to `wasm32-unknown-unknown` with threads as Web Workers and draws through WebGPU. It opens
|
||||
single-player worlds, joins Eagler servers and plays sound, and runs well in early tests.
|
||||
|
||||
Incari's two builds compile the same Java to WebAssembly two ways. Horizon shares none of that code,
|
||||
so it can't be a third way to compile Incari: Incari's features have to be written again for it.
|
||||
The aim is to ship it beside Fast and Compatible without a second project to maintain.
|
||||
|
||||
## Decision
|
||||
|
||||
- **A third build, Rust, marked experimental.** It's listed in `build.json` beside `fast` and
|
||||
`compatible` as `"rust": {"page": "rust/index.html"}` (format 2 still: older pages ignore it). The
|
||||
loading screen offers it only where `navigator.gpu` gives an adapter, never recommends it, and
|
||||
`?build=rust` picks it. Browsers without WebGPU are out of scope.
|
||||
- **Its own page.** Picking Rust opens `rust/index.html`: Horizon's page, files and service worker,
|
||||
untouched. Incari's worker leaves `rust/` alone, and its file list doesn't name Horizon's files.
|
||||
- **Horizon is pinned, fetched and never committed**, as the game is (ADR 0001).
|
||||
`incari.properties` names `horizon.repository` and `horizon.revision` (a commit on the fork's
|
||||
`web` branch). `./incari setup` clones it into `work/horizon` (a warning, not a failure, when
|
||||
it can't). `INCARI_HORIZON_DIR=<path>` builds a local checkout instead, for work on Horizon itself (its files
|
||||
as git sees them, copied into `work/horizon-override`: horizon-mixins refuses the symlink a
|
||||
checkout's own web build leaves).
|
||||
- **One game download.** `horizon-prepare` reads the pinned 26.3 jars, libraries and assets
|
||||
`./incari setup` and `./incari assets` already fetched (`--client-jar`, `--libraries-dir`,
|
||||
`--assets-dir`, `--server-jar`). The prepared resources stay in `work/horizon-resources/` and are
|
||||
never committed or published.
|
||||
- **Incari's changes are Horizon native mods**, in `rust/mods/<name>/`: horizon-mixins bundles that
|
||||
use only Horizon's native hook points (`"hooks": N`, never a pinned commit), so they keep building
|
||||
as Horizon moves. A missing hook point is added to the fork, and offered upstream. A change no
|
||||
mod can make is committed to the fork and the pin bumped; there's no second patch system. What
|
||||
every mod shares (settings pages, HUD boxes by corner) is a bundle of its own, `rust/mods/common`,
|
||||
with no hooks.
|
||||
- **One build command.** `./incari build` builds Rust before Fast and Compatible: horizon-mixins
|
||||
(pinned too) applies `rust/mods` into `work/horizon-stage`, then Horizon's `web/package.py`
|
||||
builds its threaded module (the fork dropped the single-threaded one) into `app-web/build/rust/`. `--only rust` builds
|
||||
it alone. The web folder has it in `rust/`; the single file doesn't (`--html` leaves it out:
|
||||
Horizon's offline file is a page of its own).
|
||||
- **Its tools are optional.** It needs Rust `nightly-2026-10-14` with `rust-src` and the
|
||||
`wasm32-unknown-unknown` target, `wasm-bindgen-cli` 0.2.129 and binaryen. Without them
|
||||
`./incari build` skips Rust and says why; Fast and Compatible still build.
|
||||
- **Contracts are shared, code isn't.** Java and Rust can't share modules, so both read one source:
|
||||
|
||||
| Contract | Source |
|
||||
| --- | --- |
|
||||
| Version, featured servers, online URL | `incari.properties`, turned into Rust constants at build time |
|
||||
| Accounts, friends, cosmetics | `docs/online-protocol.md` |
|
||||
| Settings and profiles | One file format in browser storage, so switching builds keeps them |
|
||||
| What a feature does | The feature's `README.md`, the spec for both ports |
|
||||
|
||||
- **Tracked per feature.** `features/README.md` has a Rust column (Ported, Not yet, Won't port), and
|
||||
`tools/ci/check-rust-status.sh` fails when a feature has none.
|
||||
- **Releases don't wait for it.** When Horizon is behind (Incari on a newer game version, or a
|
||||
broken pin), `build.json` marks `rust` unavailable with a reason and the release goes out.
|
||||
Bumping `horizon.revision` is its own pull request.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Every feature is written twice. Rust ports start with the PvP HUD and visual modules.
|
||||
- No ViaVersion in the client: Horizon speaks only 26.3, so it joins servers whose proxy translates
|
||||
(Eagler servers with ViaVersion, Horizon servers). Servers that cap the version refuse it.
|
||||
- Horizon's web port is experimental: its README lists page-side locks that can stop the game, no
|
||||
screenshots or world icons, and no online mode.
|
||||
- CI runs the mods' own tests (`rust/`'s `cargo test`, `clippy`, `fmt`), not the Rust build: that
|
||||
needs the game's files. Whether headless Chromium (SwiftShader) can run WebGPU for `browserCheck`
|
||||
is unchecked.
|
||||
- Renderer, networking and licensing reviewers (`.github/CODEOWNERS`) review the Rust build.
|
||||
Horizon is MIT, which GPL-3.0 Incari may include.
|
||||
- `rust/` isn't a Gradle module, so `gradle/module-boundaries.txt` doesn't list it; its rules are in
|
||||
`rust/AGENTS.md`.
|
||||
|
||||
## Open questions
|
||||
|
||||
- Upstreaming the web port to horizon-rust/horizon, which would leave only the mods to maintain.
|
||||
- Measurements: Rust against Fast on the same machine (`docs/benchmark.md` scenarios) before the
|
||||
loading screen describes it as faster.
|
||||
@@ -0,0 +1,56 @@
|
||||
# ADR 0069: Incari Client itself on Horizon
|
||||
|
||||
- Status: proposed
|
||||
- Date: 2026-11-01
|
||||
- Changes: ADR 0068 (its mods' settings pages and HUD corners)
|
||||
|
||||
## Context
|
||||
|
||||
ADR 0068's Rust build ported Incari's features as Horizon mods: each listed in Horizon's
|
||||
Options > Mods, settings as cycling buttons, HUD boxes in four corners, on Horizon's vanilla title
|
||||
and pause screens. It played like Horizon with some extras, not like Incari: a player had to learn
|
||||
it anew, and their profiles didn't carry over.
|
||||
|
||||
## Decision
|
||||
|
||||
The Rust build is the same client: at first glance it looks and works as the Java build does.
|
||||
|
||||
- **The client is one crate**, `incari_core` (`rust/mods/incari/core`, a horizon-mixins bundle
|
||||
crate), with no game types: the Frost look (theme, rounded glass, icons, the mark, the wordmark),
|
||||
Incari's screens (title, pause, module menu, module settings, HUD editor, Incari Settings,
|
||||
profiles), the module framework with every module declared with the Java ids
|
||||
(`modules.rs`), and profiles in the Java JSON format. It draws by listing fills, canvas images
|
||||
and text; `rust/mods/incari/glue.rs` replays the list into Horizon's HUD batch and does what the
|
||||
client asks of the game through `native_*` helpers.
|
||||
- **Feature mods keep their hooks, not their pages.** Each reads its module's settings
|
||||
(`incari_client::settings`) and draws its HUD elements where the player placed them
|
||||
(`incari_client::element`). Nothing is listed in Horizon's Options > Mods.
|
||||
- **The fork gains generic hook points** (pending fragment `incari_shell_hooks.json`), offered
|
||||
upstream: a mod draws a screen itself (`native_screen_claim`), draws over every screen and hears
|
||||
input first (`native_overlay`, `native_overlay_input`), draws its own backdrop in place of the
|
||||
panorama (`native_backdrop_claim`, `native_backdrop`), and paints images at run time into a
|
||||
2048x1024 atlas slot (`native_canvas_upload`). A GUI skin (`hud::set_skin`) is asked first for
|
||||
every sprite drawn by name, so Frost covers Horizon's own screens and HUD, as `FrostSkin` covers
|
||||
the game's in Java. Helpers: `native_open`, `native_connect`, `native_translate`,
|
||||
`native_own_skin`, `native_clipboard`, `native_atlas` and others in the fragment.
|
||||
- **Incari's pack is always on**, as in Java: `./incari build` copies it over Horizon's prepared
|
||||
resources (Red Hat Display as the game's font) and the bundle's data (the mark, the backdrop,
|
||||
Michroma) from `client/src/main/resources/incari-pack`. One copy in the repo.
|
||||
- **Settings are shared with the Java build's files**: `incari/modules/profiles/*.json`,
|
||||
`incari/look.txt` and `incari/settings.txt`, same keys.
|
||||
|
||||
## Consequences
|
||||
|
||||
- A screen of Incari's is written twice (Java and Rust), from the same layout constants. The
|
||||
Java one is the spec.
|
||||
- Ported besides the modules: Incari accounts, chat and friends (`incari_core::online`, the
|
||||
socket only in the threaded browser build), screenshots, the screen recorder (the page's
|
||||
`MediaRecorder`, browser only), credits, featured servers (the fork's
|
||||
`multiplayer::set_featured`), waypoints and the world map (its land from the fork's
|
||||
`native_map_tile`), Custom Sky (the fork's `native_sky_layers`, a render pass of sky layers), Schematics (the fork's
|
||||
`native_ghosts`, ghost blocks meshed from the game's models).
|
||||
- Cosmetics and the Wardrobe (the fork's `native_player_look`, name tag, tab list and chat hooks);
|
||||
their previews are drawn by the client, not the game's renderer.
|
||||
- Still open: linear sampling of the backdrop (Horizon's HUD samples nearest), and the Theme
|
||||
Editor's font choice.
|
||||
- Renderer reviewers review the fork's skin and canvas; they touch every GUI draw.
|
||||
@@ -0,0 +1,72 @@
|
||||
# ADR 0070: Microsoft sign-in for online-mode servers
|
||||
|
||||
- Status: proposed
|
||||
- Date: 2026-11-04 (security review the same day: key-size limits, server-auth usage, file mode)
|
||||
- Builds on: ADR 0065 (Wispcraft), ADR 0006 (the link step), ADR 0009 (the transport)
|
||||
|
||||
## Context
|
||||
|
||||
Through Wispcraft (ADR 0065) Incari joins plain Java servers, but only offline-mode ones: an
|
||||
online-mode server sends an encryption request, and the client has to tell Mojang's session server
|
||||
it's joining as a real account. Players asked for it; Wispcraft and other Eagler clients have it.
|
||||
|
||||
A page can't call Microsoft's, Xbox's or Mojang's APIs directly: they send no CORS headers.
|
||||
Wispcraft gets past that by running TLS in the page over a Wisp stream (epoxy-tls, AGPL-3.0, wasm).
|
||||
|
||||
## Decision
|
||||
|
||||
- **The launcher's client id.** Sign-in asks `login.live.com` for tokens as the official Minecraft
|
||||
launcher (`00000000402b5328`, scope `service::user.auth.xboxlive.com::MBI_SSL`), as other Eagler
|
||||
clients do. An app of Incari's own would need Mojang's approval for `login_with_xbox`. It's one
|
||||
constant, `MicrosoftEndpoints.CLIENT_ID`.
|
||||
- **Device code flow.** The game shows a code; the player types it at `microsoft.com/link` on any
|
||||
device. The password never reaches Incari.
|
||||
- **TLS in Java, over any connection** (`incari.net.tls`). Bouncy Castle's lightweight TLS client
|
||||
(MIT) in its non-blocking mode, over a `NetConnection`: a socket on the desktop, a Wisp stream in
|
||||
the browser, through the player's last proxy (or Wispcraft's default). End to end: the proxy sees
|
||||
only ciphertext. Chosen over epoxy-tls for its licence, and because it runs and is tested on the
|
||||
JVM like the rest of `net`.
|
||||
- **Pinned roots, strict checks** (`CertificateChain`). Only the four roots Microsoft's hosts chain to
|
||||
(DigiCert Global Root G2 and G3, Microsoft RSA and ECC Root 2017). The leaf must name the host
|
||||
(subject alternative names, one-label wildcards) and server auth; a CA that names purposes must
|
||||
include it. Every link must be in date, a CA's, and signed with RSA 2048 to 4096 bits (exponent
|
||||
≤ 32 bits) or ECDSA P-256/P-384 over SHA-2. Sizes are checked from the raw numbers before any key
|
||||
is read, so a hostile proxy can't stall the client with huge keys. TLS 1.2 and 1.3 only.
|
||||
- **A small HTTPS client** (`incari.net.https`): one request per connection, `Connection: close`,
|
||||
capped sizes, 30 s limit, and an allow-list of the five hosts sign-in uses. Nothing else can be
|
||||
reached through it, so a token can't be sent elsewhere.
|
||||
- **The token chain** (`incari.net.msa`): Microsoft → Xbox Live (`RpsTicket "t="`, retried once as
|
||||
`"d="`) → XSTS → `login_with_xbox` → profile. Microsoft's refresh token is kept, so the account
|
||||
lasts past the Minecraft token's 24 hours. A token about to expire is renewed before a join.
|
||||
- **The game's own handshake.** On the web, `web-classlib` now supplies the JCA classes the
|
||||
handshake and chat signing call (`Cipher` for RSA/PKCS#1 and AES/CFB8, `KeyFactory`,
|
||||
`Signature` for SHA256withRSA, `KeyGenerator`), over Bouncy Castle's engines, tested against the
|
||||
JDK. They replace removals the survey made only because they were missing. `KeyFactory` refuses
|
||||
RSA keys over 4096 bits or with exponents over 64 bits, as a server's key arrives unchecked. `KeyPairGenerator`
|
||||
stays missing, so the worker's integrated server still makes no key pair.
|
||||
- **Two hooks.** `authenticateServer` joins through `ServerJoins` (and, offline, says how to sign in
|
||||
instead of "invalid session"); `getProfileKeyPairManager` gives the account's chat key, fetched
|
||||
from `/player/certificates`. A launcher's own account (desktop, real token) keeps the game's path.
|
||||
- **Stored on the device.** `incari/microsoft-account.json` in the game directory (OPFS in a page)
|
||||
holds the name, id, Minecraft token and refresh token. Never logged; Sign Out deletes it. On the
|
||||
desktop it's owner-only (0600) and replaced atomically.
|
||||
- **Screen**: Edit Profile's "Microsoft Sign-In" link opens `MicrosoftScreen`. Signed in, the name
|
||||
is the account's and can't be edited. Accounts can't change while in a world.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Online-mode Java servers work through Wisp and on the desktop, with secure chat.
|
||||
- Bouncy Castle is in both builds (credits and `NOTICE.md`). Only the classes reached are linked.
|
||||
- If a host moves to a root that isn't pinned, sign-in fails ("not issued by a trusted root") until
|
||||
`TrustAnchors` is updated. No revocation checks, as browsers soft-fail them.
|
||||
- Using the launcher's id borrows its identity: Microsoft's page names it, and Microsoft could block
|
||||
it for everyone at once.
|
||||
- The refresh token on disk is as safe as the device's storage for the page. Anyone with the
|
||||
player's browser profile can use it, and so can any page on the same origin: host Incari on an
|
||||
origin of its own (not a shared `user.github.io`); `docs/self-hosting.md` says so.
|
||||
- On the desktop, a signed-in token reaches vanilla code too (Realms, over the JDK's trust store),
|
||||
as a launcher's would.
|
||||
- CFB8 runs one AES block per byte: the cost of every byte on an online-mode server. Measure it on
|
||||
a Chromebook before calling it free.
|
||||
- Not in the Rust build: Horizon has no Wisp and no online mode (ADR 0068).
|
||||
- Networking and licensing reviewers (`.github/CODEOWNERS`) review it.
|
||||
@@ -0,0 +1,31 @@
|
||||
# ADR 0071: Via is off unless the player turns it on
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-11-04
|
||||
- Amends: ADR 0017 (Via in the client), ADR 0018 ("Auto" finds the version by joining)
|
||||
|
||||
## Context
|
||||
|
||||
"Auto" (ADR 0018) joined every server through version detection: pings, quick probes, retries on a
|
||||
refusal, guesses after a silent Eagler drop, learned versions. It caused more trouble than it fixed:
|
||||
wrong guesses, extra logins, and wrong versions remembered for multi-version servers.
|
||||
|
||||
## Decision
|
||||
|
||||
- **Each server's Via choice is Off, Auto or a release; Off is the default**, like Wispcraft. The
|
||||
edit-server screen's button reads "Via: Off" and opens the list, with Off first.
|
||||
- **Off joins as the game's own version**: no ping, probe, retry or learned version. The server list
|
||||
marks other versions incompatible, as the game does.
|
||||
- **Saved as `incariVia`**, not `incariVersion`. Older builds saved "Auto" as their default, so their
|
||||
choices are left unread and every existing server starts with Via off.
|
||||
- **A hint on refusal**: with Via off, a join refused for its version ("Outdated server!",
|
||||
"Incompatible client!") or dropped during an Eagler login shows the server's reason with a line
|
||||
below it: edit the server and set Via to Auto (`ViaHint`, one hook in `DisconnectedScreen`).
|
||||
- **Auto for the smoke tests' servers**, and for a quick play join whose page asks with `?via=auto`
|
||||
(the browser checks of other versions). A server an Eagler server redirects to gets Auto if Via
|
||||
was on for the one that sent the player. Featured servers keep the default: they run the game's version.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Players of 1.8 servers turn Via on once per server.
|
||||
- The Rust build has no Via, so it has nothing to change.
|
||||
@@ -0,0 +1,30 @@
|
||||
# ADR 0072: A hidden page keeps time in a worker
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-11-04
|
||||
|
||||
## Context
|
||||
|
||||
The page runs the game on timers: TeaVM wakes every thread with `setTimeout`, and a hidden tab's
|
||||
frames come from a quarter-second `setTimeout` (no animation frames when hidden). Chrome holds a
|
||||
hidden page's chained timers to one wake-up a second, and after five minutes hidden and silent to
|
||||
one a minute. Packets reach the game once a frame and Netty's threads wake on timers, so the
|
||||
server's keep-alive went unanswered and players came back to "Timed out".
|
||||
|
||||
## Decision
|
||||
|
||||
- While the page is hidden, every TeaVM wakeup and both quarter-second fallbacks (frames,
|
||||
background pool) go to a small Blob worker's `setTimeout`, which answers with a message
|
||||
(`wakeups.ts`: `createPageTimer`, `createPageAsyncImports`; `window.incariTimer`).
|
||||
- While visible, nothing changes: TeaVM's own `setTimeout`, and animation frames.
|
||||
- Not the `MessageChannel` wakeups of ADR 0040: on the page they once hung singleplayer at spawn
|
||||
(ADR 0043), and a spinning wait would busy a hidden tab's core.
|
||||
- `?wakeups=timers` turns it off.
|
||||
|
||||
## Consequences
|
||||
|
||||
- A hidden tab runs the game at about four frames a second instead of
|
||||
one a minute: more battery used in the background.
|
||||
- Not measured in a real browser yet: whether Chrome exempts a dedicated worker's timers from its
|
||||
intensive throttling is from its documentation, not a test. `browserCheck` can't hide its page
|
||||
for five minutes.
|
||||
@@ -0,0 +1,31 @@
|
||||
# ADR 0073: Combat modules predict; they never play for the player
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-11-06
|
||||
|
||||
## Context
|
||||
|
||||
Players asked for Fast Crystal: an end crystal or respawn anchor gone as soon as they break it, not
|
||||
a ping later, so the next one goes in its place sooner. The same name also covers cheats that place
|
||||
and hit crystals by themselves (CrystalAura, AutoCrystal).
|
||||
|
||||
## Decision
|
||||
|
||||
- **A combat module may predict what the player's own click already did, and nothing more.** One
|
||||
click sends the one packet the game sends, at the time the game sends it. No packet is added,
|
||||
repeated, sent sooner or sent without a click. No cooldown or reach check is skipped.
|
||||
- **What the server keeps comes back.** A crystal comes back after twice the ping (0.6 to 3 s)
|
||||
without the server's removal. An anchor is predicted inside the game's own block prediction, so
|
||||
the server's acknowledgement puts it back.
|
||||
- **Only where the server agrees:** no crystal is taken away for a hit doing no damage (weakness
|
||||
with a bare hand) or for an invulnerable crystal; no anchor where it sets the spawn (the Nether).
|
||||
- **Off by default**, with a toggle key like every module, since some servers ban even prediction.
|
||||
- In code: `Game.predictBreaks` (`:framework`), `ModuleBreaks` (`:client`), three one-line hooks.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Fast Crystal sends exactly what the vanilla client sends, so an anticheat sees nothing new.
|
||||
- Auto-place, auto-hit and similar requests are refused under this ADR.
|
||||
- The Rust build has it as a mod (`rust/mods/fastcrystal`) on the fork's prediction hooks
|
||||
(`object_attacked`, `block_used`, `native_take_crystal`, `native_predict_air`: fragment
|
||||
`incari_fast_crystal`), which keep to the same rule.
|
||||
@@ -0,0 +1,36 @@
|
||||
# ADR 0074: The browser build never calls Mojang's services on its own
|
||||
|
||||
- Status: accepted
|
||||
- Date: 2026-11-13
|
||||
- Builds on: ADR 0070 (Microsoft sign-in)
|
||||
|
||||
## Context
|
||||
|
||||
The browser build started the game as an online client with token `0`. Mojang's authlib then
|
||||
called out at once and kept retrying: service discovery, the services' public keys, the player's
|
||||
profile, user properties, the chat key pair, telemetry. Mojang's APIs send no CORS headers
|
||||
(ADR 0070), so a page can't reach them: every request failed, each one a console error and wasted
|
||||
work on a slow Chromebook.
|
||||
|
||||
## Decision
|
||||
|
||||
- **Off in the browser.** `WebMain` calls `OnlineServices.disableMojang()` and starts the game with
|
||||
`--offlineDeveloperMode`: no profile, property, key pair or telemetry requests.
|
||||
- **Offline discovery.** The game's discovery service comes from `OnlineServices.discovery` (one
|
||||
hook in `Minecraft`): the offline one, which never fetches. The singleplayer worker's server
|
||||
uses it too.
|
||||
- **Skins without the services** (`ProfileTextures`, one hook in `SkinManager`). With no discovery
|
||||
there is no texture host list, so every skin and custom head would stay the default. Textures
|
||||
are accepted from Mojang's domains (`*.minecraft.net`, `*.mojang.com`) over http(s), and a
|
||||
signed property counts as signed: its signature can't be checked without Mojang's keys.
|
||||
- **Microsoft sign-in is unchanged.** It reaches Mojang over TLS in the page, only when the player
|
||||
signs in or joins an online-mode server.
|
||||
- The desktop keeps the game's own behaviour.
|
||||
|
||||
## Consequences
|
||||
|
||||
- No requests to Mojang from the browser build unless the player signs in with Microsoft. Skin
|
||||
images still come from `textures.minecraft.net`, where profiles say they are.
|
||||
- A server can show a player with another real Mojang skin; never an image from another host.
|
||||
- Other players' chat keys still can't be checked in the browser (no Mojang keys), as before.
|
||||
- The Rust build makes no Mojang requests, so it has nothing to change.
|
||||
@@ -0,0 +1,81 @@
|
||||
# ADR 0075: Server messages reach the game within a frame in the browser
|
||||
|
||||
- Status: proposed
|
||||
- Date: 2026-11-16
|
||||
- Builds on: ADR 0009 (WebSocket transport), ADR 0072 (hidden-page wake-ups)
|
||||
|
||||
## Context
|
||||
|
||||
In the browser a server message went from the socket's callback to a JavaScript queue, to the
|
||||
game's thread at the next frame's `pollEvents`, to the connection's event loop (a Java thread,
|
||||
which runs only when the render thread suspends), and back to the game's thread at the next frame.
|
||||
Measured from the socket's `onmessage` (`desktop-cpu4`, release build, in play): **decoded after
|
||||
~37 ms, handled by the game after ~40 ms**, two and a half frames.
|
||||
|
||||
A profile of the flythrough put the whole network path at ~6% of the page's time (event loop 1.7%,
|
||||
sending 0.6%, packet handling 3.4%). So the cost to fix was the latency, not the CPU.
|
||||
|
||||
Splitting the time by stage showed the wait wasn't in Incari's code. In play, Chrome runs a
|
||||
zero-delay `setTimeout` set from a socket's `onmessage` **~36 ms late**, and a `MessageChannel`
|
||||
message ~70 ms late, while animation frames and socket messages come on time. TeaVM wakes every
|
||||
thread through `setTimeout` (`teavmAsync.offer`), so the connection's thread, woken to read a
|
||||
message, waited two frames. `EventLoopHopProbe` shows the hand-off itself is immediate when the
|
||||
page isn't busy.
|
||||
|
||||
## Decision
|
||||
|
||||
| Change | Where |
|
||||
| --- | --- |
|
||||
| The render thread waits for the next frame **or** a socket message (`window.__incariNetWake`), and delivers a message as it comes | platform-web `Dom`, `WebPlatform`, `WebSocketNetwork` |
|
||||
| The woken connection thread runs at once: the wake calls `incariRunWoken`, which runs the events offered during it (and those they chain, at most 32), not leaving them to their timers [`?netwake=timers`] | app-web `wakeups.ts` (`runWoken`), `boot.ts` |
|
||||
| A burst of messages reaches the pipeline as one event-loop task with one read-complete | net `NetConnectionChannel` |
|
||||
| `Inflater.reset` and `Deflater.reset` reset jzlib's stream in place, not a new one per packet; `TInflater` reads and writes a buffer's own array | web-classlib `TInflater`, `TDeflater`, `StreamResets` |
|
||||
| A whole-array send skips one copy | platform-web `WebSocketNetwork` |
|
||||
|
||||
Only the events a wake caused run early. Each still has its timer, which finds nothing to do.
|
||||
Events offered before the wake (the background pool's runners) stay on their timers.
|
||||
|
||||
## Results
|
||||
|
||||
`desktop-cpu4` (RX 9060 XT, Chrome 151, CPU throttled 4x), release build, wsbridge server.
|
||||
Latency is from `onmessage`, in 10 s windows during play (temporary instrumentation):
|
||||
|
||||
| | Before | Wake only | Wake + `runWoken` |
|
||||
| --- | ---: | ---: | ---: |
|
||||
| Decoded, mean | ~37 ms | ~35 ms | **~2 ms** |
|
||||
| Handled by the game, mean / p95 | ~40 / ~53 ms | ~38 / ~50 ms | **~4 / ~8 ms** |
|
||||
|
||||
Frames, benchmark reports: medians, with ranges. "Without" is 7 runs (before, and the wake
|
||||
without `runWoken`); "with" is 6:
|
||||
|
||||
| | Without `runWoken` | With |
|
||||
| --- | --- | --- |
|
||||
| Median fps, flythrough / combat / lobby | 59.8 / 59.5 / 28.1 | 61.0 / 61.8 / 28.0 |
|
||||
| 1% low, flythrough | 25.9 (24.4–29.4) | 24.7 (22.3–29.7) |
|
||||
| 1% low, combat | 30.8 (26.1–34.5) | 28.3 (25.3–32.4) |
|
||||
| 1% low, lobby | 15.9 (14.2–16.5) | 15.2 (14.9–15.9) |
|
||||
| 99th percentile frame, lobby | 56.1 ms (55.7–57.3) | 58.8 ms (56.7–61.1) |
|
||||
|
||||
Median frame rates hold. The slowest frames pay: the lobby's (the busiest traffic) are ~2.5 ms
|
||||
longer, clear of noise; the 1% lows are 4–8% lower, inside the run-to-run spread but in every
|
||||
scenario. That is the price of ~34 ms less latency, so `?netwake=timers` turns it off, and the
|
||||
default is for a reviewer to settle on a Chromebook (`laptop-floor`).
|
||||
|
||||
Compression (Wisp's Java servers; Eagler servers and the benchmark send uncompressed),
|
||||
`InflatePacketProbe`, best of six alternated rounds, per packet: inflate **14.2 → 11.2 µs**,
|
||||
deflate **74.5 → 60.4 µs**, and no 32 KB window or deflate state allocated per packet.
|
||||
|
||||
## Looked at and left
|
||||
|
||||
- **One wake each 8 ms:** messages come in bursts, so most were held back, and every message not
|
||||
handed over by a wake still waited two frames (decoded ~33 ms). No gain.
|
||||
- **Running every due event on a wake:** decoded in 0.5 ms, but it pulled the background pool's
|
||||
meshing out of its idle slots into the tasks before a frame. Lobby slowest frames +7 ms.
|
||||
- **`MessageChannel` wake-ups on the page** (ADR 0043): later still in play (~70 ms).
|
||||
- **Waking the event loop for a sent packet as the frame ends** (marked wake-ups run when the
|
||||
frame's callback returns): no change. A packet the game sends reaches its event loop ~3-8 ms
|
||||
later in the flythrough and combat and ~26-30 ms in the lobby, with or without it: the send's
|
||||
wake isn't held back as a message's was; the loop just waits for the render thread to finish
|
||||
its frame. Less would need the pipeline to run on the render thread.
|
||||
- **Per-message delivery cost** (`SocketDeliveryProbe`): 0.49 µs a message, nearly all the copy
|
||||
out of the page's buffer. Not worth changing.
|
||||
@@ -0,0 +1,96 @@
|
||||
# Architecture decision records
|
||||
|
||||
Each ADR records one decision: the problem, what was chosen and why, and what it costs. They're
|
||||
the project's memory. Read the ones for the area you're changing before you change it, and add one
|
||||
when you make a decision someone would otherwise have to rediscover.
|
||||
|
||||
## Writing one
|
||||
|
||||
- Copy the header of a recent ADR: `- Status`, `- Date`, and `- Builds on` when it extends
|
||||
earlier ones. Then **Context**, **Decision**, **Consequences**, and measurements when
|
||||
there are any.
|
||||
- Number it after the last one, and add it to the table below.
|
||||
- Status is `accepted` once the change is merged. When a later ADR replaces part of one, say so in
|
||||
its status line ("superseded in part by ADR NNNN") rather than editing the old decision.
|
||||
- Write for someone who wasn't there. Measurements say where they were taken (the machine names in
|
||||
[`docs/benchmark.md`](../benchmark.md)).
|
||||
|
||||
## Index
|
||||
|
||||
| ADR | Decision |
|
||||
| --- | --- |
|
||||
| [0001](0001-patch-only-repo.md) | The repo is patch-only, built on the Spigot/Paper model |
|
||||
| [0002](0002-license-gpl3-with-minecraft-exception.md) | GPL-3.0-or-later with a Minecraft additional permission, and DCO sign-off |
|
||||
| [0003](0003-module-boundaries-and-quality-gates.md) | Enforced module boundaries and one set of quality gates |
|
||||
| [0004](0004-vendor-tree-builds-from-source.md) | The game is built from the patched source tree, starting with decompile fixes |
|
||||
| [0005](0005-platform-layer.md) | The platform layer: whole-class replacements over Platform interfaces |
|
||||
| [0006](0006-browser-build-link-step.md) | How the browser build links: removals by rule, a class library for the rest |
|
||||
| [0007](0007-webgl2-backend-and-build-time-shaders.md) | The WebGL2 backend, under Mojang's frontend, with shaders translated at build time |
|
||||
| [0008](0008-off-heap-memory-in-linear-memory.md) | Off-heap memory in the module's linear memory, and Netty in heap mode |
|
||||
| [0009](0009-websocket-transport.md) | A WebSocket transport under the game's Connection, one packet per message |
|
||||
| [0010](0010-browser-input.md) | Browser input: focus, a text input element, an asynchronous clipboard, dropped files |
|
||||
| [0011](0011-storage.md) | Storage: the file system in memory, written behind to OPFS by a worker |
|
||||
| [0012](0012-webgl2-backend-complete-and-screenshot-diffs.md) | Every pipeline in WebGL2, and screenshot diffs against the desktop |
|
||||
| [0013](0013-web-audio.md) | Sound over Web Audio, with the browser's decoder and the desktop's panning |
|
||||
| [0014](0014-loader-and-packaging.md) | The loader page, the build manifest, the service worker and the asset pack |
|
||||
| [0015](0015-background-work-between-frames.md) | The background pool runs between frames, and the render thread's waits are counted |
|
||||
| [0016](0016-eagler-handshake-in-the-client.md) | The Eagler handshake in the client, and Eagler skins |
|
||||
| [0017](0017-via-in-the-client.md) | Via in the client, and choosing a server's version |
|
||||
| [0018](0018-auto-finds-the-version-by-joining.md) | "Auto" finds a server's version by joining |
|
||||
| [0019](0019-eagler-extras.md) | Eagler's extras: passwords, cookies, redirects, voice chat and shared worlds |
|
||||
| [0020](0020-legacy-behaviour-layer.md) | The legacy behaviour layer: playing 1.8 servers as 1.8 did |
|
||||
| [0021](0021-profiler-and-benchmark.md) | The profiler, the benchmark and the performance gate |
|
||||
| [0022](0022-terrain-multi-draw.md) | Terrain in a few multi-draws a frame |
|
||||
| [0023](0023-worker-mesher.md) | Terrain meshed in Web Workers by Incari's own mesher |
|
||||
| [0024](0024-entities-particles-text.md) | Entities, particles and text |
|
||||
| [0025](0025-memory-diet.md) | The memory diet |
|
||||
| [0026](0026-startup.md) | Start-up |
|
||||
| [0027](0027-performance-follow-ups.md) | Performance follow-ups: the compile, the backend's calls, and the game's own costs |
|
||||
| [0028](0028-web-folder.md) | The web folder (`./incari build`) |
|
||||
| [0029](0029-edit-profile.md) | Edit Profile |
|
||||
| [0030](0030-game-side-optimizations.md) | Ideas from the Java optimization mods: draw lists, facing culling, sprite animation |
|
||||
| [0031](0031-floor-device-profiles.md) | What the floor stand-in's profiles found: items, ambient particles, glyphs, tints, indices |
|
||||
| [0032](0032-pacing-tables-light-particles.md) | Catch-up ticks paced, mesher tables kept, light maps updated in place, particles instanced |
|
||||
| [0033](0033-packet-handoff.md) | Throws off the page's main thread: the packet handoff, and Via's dropped packets |
|
||||
| [0034](0034-fixed-orders-lookups-and-sweeps.md) | Fixed translucent orders, the class library's lookups, collision sweeps, and Binaryen |
|
||||
| [0035](0035-pool-floor.md) | A floor for the background pool's share of a late frame |
|
||||
| [0036](0036-fast-and-compatible-builds.md) | Fast and Compatible builds (JSPI instead of coroutines) |
|
||||
| [0037](0037-index-assets.md) | The Unicode font and the languages from the asset index |
|
||||
| [0038](0038-singleplayer-in-the-page.md) | Singleplayer in the page |
|
||||
| [0039](0039-singleplayer-server-in-a-worker.md) | Singleplayer's server in a Web Worker |
|
||||
| [0040](0040-singleplayer-server-speed.md) | Singleplayer's server, faster: wakeups, math, spawn settings, stronghold rings |
|
||||
| [0041](0041-singleplayer-storage-and-world-generation.md) | Singleplayer's files in place, a direct line to storage, and cheaper world generation |
|
||||
| [0042](0042-lazy-density-branches-terrain-helpers-goal-flags.md) | Density functions' branches sampled where used, terrain helpers, and goals' flags as masks |
|
||||
| [0043](0043-world-generation-garbage-jar-compaction-wasm-opt.md) | Less garbage in world generation, the client jar compacted, faster saves, and wasm-opt and channel wakeups measured again |
|
||||
| [0044](0044-defaults-and-fixes-before-m4.md) | Defaults and fixes before M4 |
|
||||
| [0045](0045-eagler-pause-menu-and-voice-panel.md) | An Eagler server's pause menu, voice chat in a panel, the player on the title screen |
|
||||
| [0046](0046-module-framework.md) | The module framework |
|
||||
| [0047](0047-screen-edits-and-skins.md) | The game's screens changed and redrawn without a patch each |
|
||||
| [0048](0048-the-clients-look.md) | The client's look, Frost, in Potato and Normal presets |
|
||||
| [0049](0049-hud-editor.md) | The HUD editor |
|
||||
| [0050](0050-first-modules-game-view.md) | The first modules, and what they read of the game |
|
||||
| [0051](0051-minimap-and-waypoints.md) | Minimap and waypoints |
|
||||
| [0052](0052-hud-modules.md) | The HUD modules: Keystrokes, CPS, FPS, Reach, Coordinates, Shield & Totem |
|
||||
| [0053](0053-visual-and-combat-modules.md) | The visual and combat modules: Cooldown, Crosshair, Freelook, Weather, Low Shield, 1.7 |
|
||||
| [0054](0054-screen-modules.md) | The screen modules: Shulker Tooltips, Screenshot Manager, Theme Editor |
|
||||
| [0055](0055-built-in-packs-and-old-textures.md) | The built-in packs in the page, and Old Textures |
|
||||
| [0056](0056-the-looks-first-performance-pass.md) | The look's first performance pass |
|
||||
| [0057](0057-single-file.md) | One HTML file (`./incari build --html`) |
|
||||
| [0058](0058-incari-accounts-client-side.md) | Incari accounts and the online service (client side) |
|
||||
| [0059](0059-incari-chat-friends-and-messages.md) | Incari chat: friends, messages and the chat menu |
|
||||
| [0060](0060-update-notice.md) | The update notice |
|
||||
| [0061](0061-cosmetics.md) | Cosmetics: the Wardrobe, worn cosmetics, emotes and personal effects |
|
||||
| [0062](0062-incari-settings-and-the-2026-10-12-batch.md) | Incari Settings, and the 2026-10-12 batch |
|
||||
| [0063](0063-the-modules-first-performance-pass.md) | The modules' first performance pass |
|
||||
| [0064](0064-teavm-0-16.md) | TeaVM 0.16.0 |
|
||||
| [0065](0065-wispcraft.md) | Wispcraft: Java servers through a Wisp proxy |
|
||||
| [0066](0066-schematics-clean-room.md) | Schematics, written clean-room |
|
||||
| [0067](0067-custom-sky.md) | Custom Sky: resource packs' OptiFine skies |
|
||||
| [0068](0068-rust-build.md) | An experimental Rust build on Horizon |
|
||||
| [0069](0069-incari-client-on-horizon.md) | Incari Client itself on Horizon |
|
||||
| [0070](0070-microsoft-sign-in.md) | Microsoft sign-in for online-mode servers |
|
||||
| [0071](0071-via-off-by-default.md) | Via is off unless the player turns it on |
|
||||
| [0072](0072-hidden-page-wakeups.md) | A hidden page keeps time in a worker, so servers don't time it out |
|
||||
| [0073](0073-combat-prediction-not-automation.md) | Combat modules predict; they never play for the player |
|
||||
| [0074](0074-no-mojang-services-in-the-browser.md) | The browser build never calls Mojang's services on its own |
|
||||
| [0075](0075-network-latency-in-the-browser.md) | Server messages reach the game within a frame in the browser |
|
||||
Reference in New Issue
Block a user