Protected exports
Status: shipped (2026-11-07): phases 1–4. Moved from docs/design/future/ when phase 4 landed; the design below is
the proposal as accepted on 2026-11-04, with each phase’s “Changes from the proposal” at the end.
Milestone: G19 ✅
Decisions: ADR 0239, ADR 0240,
ADR 0247, ADR 0259,
ADR 0260
Problem
Section titled “Problem”An exported game is easy to copy wholesale. Its Assets/ folder ships as loose files (.mfscene and .mfres JSON,
.rml, PNGs, OGGs, project.mfproj), and the game’s code is a managed assembly that ILSpy turns back into near-source
C#. Anyone, or any AI agent, pointed at the install folder gets the game’s structure, data and code in minutes. Every
game made with the engine has this problem, so the engine should fix it in mf-export, not each game.
This is deterrence. The key that decrypts a pack ships inside the game, so a determined reverse engineer still gets in. The goal is to remove the low-hanging fruit: no readable files, no decompilable code.
- One content file-system seam that every runtime content read goes through. Mobile needs it anyway
(
IContentFileSystem, M12.1). - Exports put the game’s and the engine’s
Assets/andproject.mfprojin oneAssets.mfpakbeside the executable. The format is the one mobile describes (M12.5), pulled forward for desktop. - Packs are encrypted by default, with a stable key per project, so rebuilds are byte-identical and Steam patches stay small.
- A
nativeAotpreset key, once the engine is trim- and AOT-clean, so shipped game code is machine code. - Nothing changes for game code, the editor or Play. Only exports change.
Non-goals
Section titled “Non-goals”- Anti-tamper, anti-cheat, DRM or licence checks. Steam’s DRM wrapper remains the game’s own choice.
- Resisting a determined reverser, a memory dump or a GPU capture. RenderDoc still sees textures and SPIR-V.
- Protecting game design. Gameplay can always be recorded and cloned.
- An IL obfuscator. The owner chose NativeAOT instead (it removes the IL, and obfuscation would break every
name-based contract:
[Export],[Signal],[Rpc], save schemas). - Cooking (KTX2 textures, binary scenes,
.mfmesh). That is mobile’smf-cook(M12.5). Packs carry the source formats. - A mod-loading policy. A game that wants moddable files sets
pack: falseor lists them inloose.
Design
Section titled “Design”From a game developer’s view
Section titled “From a game developer’s view”Export presets gain these keys (rows for Game export → Preset schema):
| Key | Targets | Default | Meaning |
|---|---|---|---|
pack | all | true | Stage Assets/ and project.mfproj into Assets.mfpak; no loose Assets/ ships. false is today’s layout. |
encrypt | all | true | Encrypt the pack with the project’s pack key. Ignored when pack is false. |
loose | all | [] | Globs of Assets/ files kept as loose files beside the pack (still readable at the same content path). |
nativeAot | desktop | false | Phase 4: -p:PublishAot=true. Overrides readyToRun, singleFile and trim. |
A packed export folder holds the executable, the runtime and natives, Assets.mfpak and any loose files. Game code
does not change: it already loads content through ResourceLoader, UiDocument.Source, AudioStream paths and so on.
The project keeps one pack key beside its export presets, export.packKey in project.mfproj (32 random bytes,
base64). Project format 6’s migration generates it once. The key is committed with the project: it ships inside the game anyway, and a committed
key makes CI exports reproduce. MF_PACK_KEY overrides it, like MF_SIGN_IDENTITY. The exported project.mfproj
(inside the pack) has no key and no presets.
Content file system (phase 1)
Section titled “Content file system (phase 1)”Built (2026-11-04; see “Changes from the proposal, phase 1” below). ContentFiles (MainframeEngine/Src/Core/Content/)
is a static, read-only file system with mounts:
public static class ContentFiles{ public static IDisposable Mount(IContentSource source, int priority = 0); // dispose to unmount public static Stream OpenRead(string path, FileShare share = FileShare.Read, int bufferSize = 4096); public static bool Exists(string? path); public static bool DirectoryExists(string? path); public static ContentFileInfo GetInfo(string path); // exists, length, last write public static byte[] ReadAllBytes(string path); public static string ReadAllText(string path, Encoding? encoding = null); public static IEnumerable<string> EnumerateFiles(string directory, string pattern = "*", bool recursive = false); public static IEnumerable<string> EnumerateDirectories(string directory, string pattern = "*", bool recursive = false);}- Paths are what
Filetakes: callers resolve"Assets/…"withContentPaths.Resolvefirst, and other relative paths resolve against the working directory. Every call is a one-for-one swap of theFile/Directorycall. - An
IContentSourceis mounted at a directory (itsRoot) and serves the absolute paths under it, so code that keeps absolute paths (AssetDatabase.ToAbsolutePath,Texture2D, shader paths) works unchanged. A path is looked up in the mounts whose root holds it, highest priority first, then on the disk. Paths outside every mount read the disk. - With nothing mounted, every call is the
File/Directorycall it replaced.Exists/GetInfoon absolute paths allocate 0 B, mounted or not. PackContentSource(phase 2, built) reads a.mfpakand is mounted atContentPaths.BaseDirectory. Loose files beside the executable (loose) are the disk fallthrough.GameHostmountsAssets.mfpakwhen it exists next to the executable, before it readsproject.mfproj. Otherwise it mounts nothing and reads loose files, as before.
Every runtime content read moved to it. That means ResourceLoader, AssetDatabase (it reads the shipped
assets.index.json; ToAbsolutePath callers become OpenRead callers), Texture2D/Png, Font, ShaderModuleCache
and the canvas Shader, UiFileInterface and RmlContentFileInterface (RmlUi already reads through a managed
Stream, fonts included), Tr/TranslationSet/FontFallbackTable, AudioStream/AudioDecoder (streaming needs
seekable streams), MusicManifest/AdaptiveMusic, SpineNode/SpineTextureLoader, SkyEnvironment, TerrainData,
LightProbeData, TreeMaterials, Label3D and ProjectSettings loading.
- Assimp.
ModelImporterimports at run time withImportFileExWithProperties(fullPath, …, (FileIO*)null, …). It gets anaiFileIObridge overContentFilesstreams (AssimpContentIO, used only when the model lies under a mount), so glTF files with external.binbuffers and textures load from a pack. - Not content, so unchanged: saves and
settings.json(DurableFile,ConfigFile), logs, crash reports, recording, the Vulkan pipeline cache, bake caches,steam_appid.txt, native libraries (the OS loads them by path), and editor-only builds (SurfaceShaderBuild,GameAssemblyLoader). - Spine reads through the vendored runtime’s stream overloads (
SpineContent). RmlUi’sLoadFontFace(path)reads through the managed file interface, so fonts need no change. - An audit test fails when
MainframeEngine/SrccallsFile.*,FileStreamorDirectory.*outside an allowlist of those files, unless the line carries// disk-io: <reason>. It is a plain source scan, so no analyzer package is needed.
Pack format (phase 2)
Section titled “Pack format (phase 2)”Built (2026-11-06); see “Changes from the proposal, phase 2” below and Asset pipeline → Packs.
.mfpak v1 is little-endian and versioned:
- Header. Magic
MFPK, format version, flags (encrypted), index offset and length, the index nonce, and a 16-byte key check (the first keystream block of a fixed nonce), so a wrong key fails at mount, not mid-load. - Entries. Sorted by path. Each entry is stored or Brotli-compressed (
System.IO.Compression, built in, so no new package). Already-compressed or streamed formats (.ogg,.png,.jpg,.ktx2, video) are stored and 16 KB aligned, as mobile needs, so they stay seekable. Compressed entries are decoded whole on open; they are small text and data files. - Index. Every content path (
Assets/…,/-separated, case-sensitive), with offset, stored and original length, codec and nonce. Directory listings come from it. It is compressed and, when the pack is encrypted, encrypted too, so file names are not visible. - Deterministic. The same input and key give the same bytes: sorted order, no timestamps, nonces derived from content. A change to one asset changes only its entry, the index and the offsets after it.
PackWriter lives in the export library (Tools/MainframeEngine.Export); PackReader lives in the engine
(Src/Core/Content/). The export’s stage step changes:
- As today:
ContentFilter, the exportedproject.mfproj,assets.index.json.ContentFilter.Shipsalready refuses the editor-only folder (ContentPaths.IsEditorOnly:Assets/Video, ADR 0241), and the build never copies it to the stage; the pack writer must not read the project’sAssets/directly, or it would pack video mode’s media. - With
pack: write<stage>/Assets.mfpakfromAssets/+project.mfprojminusloose, then delete what was packed. The engine’s ownAssets/(shaders, widgets, fonts) go in the same pack, under the same paths.
Encryption (phase 3)
Section titled “Encryption (phase 3)”Built (2026-11-06); see “Changes from the proposal, phase 3” below.
- Cipher. AES-256-CTR, with the keystream from
Aes.EncryptEcb(built in; supported on every desktop and mobile target, with hardware AES on x64 and arm64). CTR can decrypt any byte range, so audio streaming and seeking work on encrypted entries. There is no authentication tag, because tamper resistance is a non-goal; the key check catches a wrong key. - Nonces. Each entry’s 12-byte nonce is the first 12 bytes of SHA-256(path ‖ content). It is unique per content and stable across builds. The 4-byte block counter limits an entry to 64 GB.
- No allocation.
PackStreamdecrypts in place into the caller’s buffer, using a pooled keystream buffer per stream. Reads allocate 0 B, so audio streaming stays inside the allocation gate. - Getting the key into the game, not the engine.
mf-exportpublishes with-p:MainframePackKey=<base64>.MainframeGame.propsmakes it aCompilerVisibleProperty, andMainframeEngine.Generators(already an analyzer of every game library) emits a[ModuleInitializer]in the game assembly. It registers the key withContentFiles, split into XOR-masked constants. The module initializer runs whenGameHost.Run(args, typeof(X).Assembly)loads the game assembly.- Never put the key in the runtimeconfig, an AppContext switch or any file beside the executable: those are plain JSON.
- Builds without the property (the editor, Play,
dotnet run) register no key and read loose files. - Until phase 4 the key is recoverable from the IL. That is accepted: the pack still defeats “read the folder”, and NativeAOT buries the key in machine code.
NativeAOT (phase 4)
Section titled “NativeAOT (phase 4)”Built (2026-11-07); see “Changes from the proposal, phase 4” below, ADR 0259 and Game export → NativeAOT.
- Set
IsAotCompatibleonMainframeEngine(and the generator’s output), turning the trim and AOT analyzers on, then fix the warnings. Known sites:TypeRegistryfallbacks, JSON outside source-generated contexts,SteamworksLoader(loads a shim assembly by path; under AOT the shim must be linked statically per RID), Assimp and Silk.NET interop, SoundFlow, GetText.NET, Jitter2 and Box2D.NET. nativeAot: truepublishes with-p:PublishAot=true. NativeAOT does not cross-compile between OSes, so the validator errors when the host OS is not the target’s, and CI builds each OS on its own runner.- Symbols: NativeAOT’s
.pdb/.dbg/.dSYMgo into thesymbols: separatezip, andmf-symbolicatelearns native frames. - This is M12.6’s work (“trim/AOT analyzers clean”) and C0’s “desktop NativeAOT smoke”. If either lands first, this phase shrinks to the preset key and its tests.
Scenarios
Section titled “Scenarios”Phase 1: content file system
Section titled “Phase 1: content file system”- Given a loose game, when
ContentFiles.OpenRead(ContentPaths.Resolve("Assets/UI/hud.rml"))runs, then it returns the file’s bytes, exactly asContentPaths.Resolvewould locate it. Test:LooseSourceReadsAssetsPathsLikeContentPathsResolve. - Given
ContentPaths.ProjectDirectoryis set and a file exists only underBaseDirectory, when it is opened, then the base copy is read. Test:LooseSourceFallsBackToTheBaseDirectory. - Given a legacy
"Content/x.png"path, when it is opened, thenAssets/x.pngis read. Test:LegacyContentPathsReadTheAssetsFolder. - Given a source is mounted, when a path outside its root is opened, then the disk is read and the source is not
consulted. Test:
PathsOutsideEveryMountReadTheDisk. - Given a source is mounted, when an absolute path under its root is opened, then the source is read. Test:
AbsolutePathsUnderAMountReadTheMount. - Given a missing content path, when it is opened, then
FileNotFoundExceptionnames the path and each mount searched. Test:MissingContentNamesThePathAndTheMounts. - Given the engine sources, when the audit scans
MainframeEngine/Src, then no file outside the allowlist callsFile.*,FileStreamorDirectory.*. Test:RuntimeContentCodeDoesNotCallFileApis. - Given an in-memory test source holding a glTF scene with an external
.binand a PNG, whenResourceLoader.Load<PackedScene>loads it, then the meshes and texture match loading the same files from disk. Test:ModelImporterLoadsAGltfWithExternalBuffersThroughTheContentFileSystem.
Phase 2: packs
Section titled “Phase 2: packs”- Given a staged
Assets/folder, whenPackWriterwrites it twice, then the two packs are byte-identical. Test:PackWriterIsDeterministic. - Given a pack of a staged folder, when every file is read back, then contents,
Exists,DirectoryExistsandEnumerate(with patterns, recursive or not) match the folder. Test:PackRoundTripsAStagedFolder. - Given an
.oggin a pack, when its stream seeks to random offsets and reads, then the bytes match the file, and the entry is stored and 16 KB aligned. Test:StoredEntriesAreAlignedAndSeekable. - Given a template game with default presets, when it is exported, then the output has
Assets.mfpak, noAssets/folder and no looseproject.mfproj, and the game runs headless with--max-framesand exits 0. Test: the existingExportsATemplateGameForThisMachineAndRunsIt, extended. - Given a preset with
pack: false, when it is exported, then the output layout is today’s. Test:PackFalseKeepsLooseAssets. - Given
loose: ["Assets/Mods/**"], when the game readsAssets/Mods/a.json, then the loose file wins over the pack, and the pack does not contain it. Test:LooseGlobsShipBesideThePackAndStillLoad. - Given a packed export of a game that uses RmlUi documents, fonts,
.mocatalogs and streamed music, when it starts, then its UI, translations and music load from the pack. Test:PackedGameLoadsUiFontsCatalogsAndStreamsFromThePack(a headless test host over a pack built in the test).
Phase 3: encryption
Section titled “Phase 3: encryption”- Given an encrypted pack of files containing known strings, when the raw pack bytes are searched, then no file path
and no known plaintext appears. Test:
EncryptedPackContainsNoPlaintextPathsOrContent. - Given an encrypted pack, when it is mounted with a different key, then the mount fails with
PackKeyMismatchbefore any read, andGameHostlogs it and exits non-zero. Test:WrongKeyFailsAtMountWithAClearError. - Given a stable key, when the pack is written twice, then it is byte-identical; when one asset changes, then only that
entry, the index and later offsets change. Tests:
EncryptedPackIsDeterministicForAStableKey,ChangingOneAssetChangesOnlyItsEntryAndTheIndex. - Given a format-5 project, when it is migrated, then it gains a pack key; when the saved project is loaded again,
then the key is unchanged. Test:
FormatSixMigrationAddsAPackKeyOnce. - Given a project file on disk without a pack key, when
mf-exportruns a preset withencrypt: true, then validation fails withPackKeyMissingand a fix (mf-export --init-pack-key, or open the project in the editor). Test:ExportWithoutASavedPackKeyFailsWithAFix. - Given
MF_PACK_KEYis set, when exporting, then the pack is encrypted with it, not the project’s key. Test:PackKeyEnvironmentVariableOverridesTheProject. - Given an encrypted export, when every output file is searched for the key’s raw bytes and its base64, then none
contains them, and the packed
project.mfprojhas no key and no presets. Tests:ExportedFilesDoNotContainThePackKey,ExportedProjectFileOmitsThePackKey. - Given a game library built without
MainframePackKey, when it is run from the editor or Play, then no key is registered and loose files load as today. Test:BuildsWithoutAPackKeyReadLooseFiles.
Phase 4: NativeAOT
Section titled “Phase 4: NativeAOT”- Given
nativeAot: trueon a host of the target OS, when the template game is exported, then the output has no managed game or engine assembly, and the game runs headless and exits 0. Test:NativeAotExportHasNoManagedAssemblies. - Given
nativeAot: truefor another OS’s target, when validating, then it fails withNativeAotNeedsTargetHost. Test:NativeAotNeedsAHostOfTheTargetOs. - Given
nativeAot: truewithreadyToRunorsingleFileset, when validating, then a warning says they are ignored. Test:NativeAotIgnoresReadyToRunAndSingleFile.
Testing
Section titled “Testing”- Allocation gate:
PackStreamreads (stored, encrypted and compressed entries) allocate 0 B after open, measured withAllocationGate.SmallestWindow, because audio streaming reads them on its worker. - Benchmark: a new
ContentLoadBenchmarks: scene, texture and UI load from loose files, a stored pack, a compressed pack and an encrypted pack. Load time from a pack must not regress against loose files by more than 10 % (to confirm on the baseline machine). - Render tests stay on loose files (unchanged). The Demo gets a packed export smoke test:
just demo-screenshotsrun against a packed, encrypted export must match its loose screenshots (a newjust export-smokerecipe, run locally; CI’s template job covers the template game). - CI: the template job’s export (
build/template-smoke.sh) becomes packed and encrypted by default, so every PR exercises the default path on Linux. Phase 4 adds a NativeAOT export per OS runner. GitHub Actions minutes are scarce, so phase 4’s runs are one job per OS, not per preset. (Built: CI’snative-aotjob, one per OS runner, runsNativeAotExportHasNoManagedAssemblieswithMAINFRAME_NATIVE_AOT_TESTS=1; owner, 2026-11-07. Locallyjust template-smoke-aotandjust template-smoke-aot-linux. Since the editor moved out (ADR 0289), the job runsbuild/template-smoke.shwithNATIVE_AOT=1 HEADLESS_ONLY=1instead.) - Gates as usual:
just build, the Release build,just test,just test-render,just format-check,just shaders-check.
Human checklist
Section titled “Human checklist”- Point ILSpy and an AI agent at a packed, encrypted export folder, before and after NativeAOT, and record what each recovers (the point of this work).
- Upload two builds that differ by one asset to a Steam depot branch and check the patch size SteamPipe reports.
- Load times of the Forest and Neon showcases from a pack feel no slower than from loose files, on a Mac and on Windows.
- Music streaming and seeking from an encrypted pack sound clean (no glitches at seek points).
Task list
Section titled “Task list”- Phase 1:
ContentFiles,IContentSource,MemoryContentSource; move every runtime content read; the AssimpaiFileIObridge; the audit test; updatedocs/design/asset-pipeline.mdand AGENTS.md’s project structure. - Phase 2:
.mfpakv1 (PackWriterin the export library,PackReader/PackContentSourcein the engine);GameHostmounting; thepackandloosepreset keys; stage changes;ContentLoadBenchmarks;just export-smoke;game-export.mdrows. - Phase 3: AES-256-CTR
PackStream; project format 6 with the pack key and its migration;--init-pack-key;MF_PACK_KEY;MainframePackKeythroughMainframeGame.propsand the generator’s module initializer; theencryptpreset key; validator issues. - Phase 4:
IsAotCompatibleand the analyzer fixes (shared with M12.6/C0); the static Steamworks shim under AOT; thenativeAotpreset key; NativeAOT symbols insymbols: separateandmf-symbolicate; a NativeAOT export per OS in CI (thenative-aotjob, owner 2026-11-07).
Changes from the proposal, phase 1
Section titled “Changes from the proposal, phase 1”- Mounts are anchored at a directory. The engine’s content identity is an absolute path almost everywhere, so rather than converting it to content paths, a source serves the absolute paths under its root. “Rooted paths bypass the mounts” became “paths outside every mount read the disk” plus “absolute paths under a mount read the mount”.
- No
IContentFileSystem/ContentFileSystem.CurrentorLooseContentSource. The staticContentFileswith mounts is the seam; the disk fallthrough is the loose source. Mobile can put its own source behind a mount. - Paths resolve like
File, not likeContentPaths.Resolve. Resolving insideContentFileschanged the meaning of repo-relative paths (mf-shaders checkreported every shader stale), so callers resolve first, as they did. SurfaceShaderBuildstays on the disk for the build and check, but its run-time lock read goes throughContentFiles.
Changes from the proposal, phase 2
Section titled “Changes from the proposal, phase 2”- The writer is in the engine (
Src/Core/Content/PackWriter.cs), not the export library: engine tests and benchmarks build packs with it, and mobile’smf-cookwill too. The export’s stage step calls it. - Anchors instead of plain packing (ADR 0247). This
answers the SteamPipe open question. Valve’s uploading guide says SteamPipe diffs in ~1 MB chunks and recommends a
1 MB padding alignment and per-asset compression. Laying entries out back to back would shift every later chunk after
one change, and even “never cross a page” re-flows every later page. So entries of a page or more, and about one
entry per 16 MB picked by its path’s hash and its own size, start on a page boundary: a change re-lays out entries
only up to the next anchor.
InsertingAnAssetShiftsEntriesAfterTheNextAnchorByWholePageschecks it. - Codec choice. Media extensions are always stored; other files are Brotli only when it saves 1/16 or more.
- Header. The flags field is
PackOptions(CA1711). The phase 3 fields (index nonce, key check) are written now, so the format does not change for encryption. - The packed-game scenario is the existing mounted-content tests (UI documents and fonts, catalogs, streamed audio, glTF with external buffers, Spine, scenes) run as theories over the in-memory source and a real pack, rather than one new test host.
mf-export --pack-listand--pack-extract, not in the proposal: the template smoke checks a packed export through them, and developers can see what shipped.just export-smokecompares 8 of 12 Demo scenes pixel for pixel (all 8 match exactly): the physics, particle and tile-map scenes differ between two runs of the same loose build, so they are run from the pack and checked for errors only.ContentLoadBenchmarkscompares loose files and a pack (scene text, PNG decode, UI text); the stored-versus- compressed split is the codec each file gets, and the encrypted case comes with phase 3.assets.index.jsonand the UID map live only inside the pack:AssetDatabasereads them throughContentFiles, and the packed template export runs (ExportsATemplateGameForThisMachineAndRunsIt).
Changes from the proposal, phase 3
Section titled “Changes from the proposal, phase 3”packKeyis a top-level key, notexport.packKey:exportis the presets array. ADR 0240’s decision is otherwise unchanged.- The mask is SHA-256(“MainframePackKey:” + assembly name), not random, so the same key gives the same assembly (reproducible exports). It only hides the key from string and byte searches, as intended.
- The stream is
PackEntryStreamwith aPackCipher(AES-ECB keystream through one reusedICryptoTransform, 4 KB per AES call), not a separatePackStream; Brotli entries are decrypted whole before decoding. - Module initializers do not run on
typeof(X).Assembly, soGameHost.Runruns the game assemblies’ (and the entry assembly’s) withRuntimeHelpers.RunModuleConstructorbefore mounting. OnlyMainframeGame.propsmakesMainframePackKeycompiler-visible, so a checkout build never compiles the key into the engine. - The editor saves the key on the first encrypted export from File › Export (#222: until then it saved it when it
opened a project whose file had none, which wrote to projects just by opening them).
mf-export --init-pack-keynever replaces a saved key. The template stays format 5 without a key; each new game gets its own on its first encrypted editor export (or--init-pack-key; the template smoke runs it). - Tests:
WrongKeyFailsAtMountWithAClearErrorchecksPackReader;GameHostreports aPackKeyExceptionlike any failed start (exit 1) through its existing catch, not a test of its own.BuildsWithoutAPackKeyReadLooseFilesis covered by the loose demo export ofExportsATemplateGameForThisMachineAndRunsItand every Play/editor run, which register no key.--pack-list/--pack-extracttake--projectorMF_PACK_KEY. ContentLoadBenchmarksgainsEncrypted.
Changes from the proposal, phase 4
Section titled “Changes from the proposal, phase 4”-p:MainframeNativeAot=true, not-p:PublishAot=true(ADR 0259): a globalPublishAotreaches the netstandard2.0 generator project of a checkout build (NETSDK1207) and the tools a game’s build references.MainframeGame.propsturns the property intoPublishAotfor the game’s own projects, which also runs the trim and AOT analyzers over game code.- Analyzers are errors in all of
MainframeEngine/Src, not onlySrc/Saves, and the Steamworks shims areIsAotCompatibletoo. The sites the proposal named were mostly clean already (Silk.NET, SoundFlow, GetText.NET, Jitter2, Box2D.NET and the source-generated JSON raised nothing in engine code); the real ones were:Node’s reflection overGetType()for overridden callbacks (without it no node processed under NativeAOT: the loading screen never faded). Fixed with a type-level[DynamicallyAccessedMembers]onNode(methods and public properties) and onResource(public properties, for tweens).Tweenproperty paths (nodes and resources annotated;ColorandQuaternioncomponents without reflection).SdlEventBatch(Silk internals kept with[DynamicDependency], so the 0 B event pump installs under NativeAOT too).ConfigFile,TypeRegistry’s referenced-assembly scan,GameAssemblyLoader(editor-only:[RequiresUnreferencedCode]),SteamworksLoader,CrashBundleWriter.
- Steamworks under NativeAOT: the target OS’s shim and Facepunch assembly are ILC references (compiled in), and
Steamtreats the shim as present without its.dll. Facepunch reads callbacks withMarshal.PtrToStructure(ptr, typeof(T)), for which ILC generates structure marshalling only for structs that need a stub: blittable callbacks (PersonaStateChange_t, …) threw “missing structure marshalling data” against a running Steam client.build/steamworks/Facepunch.Steamworks.{Posix,Win64}.rd.xmlasks for it for each of Facepunch’s 301 marshallable structs (NativeAotTestsgenerates and checks the lists against the vendored assemblies). Third-party ILC warnings (Silk.NET, DependencyModel, Facepunch: IL2104, IL3053, IL3000, IL3002) do not fail a warnings-as-errors publish. - macOS bundles: the NativeAOT executable alone is in
Contents/MacOSand the rest inContents/MonoBundle, as for JIT builds;NativeAppBundle(first thing inGameHost.Run) makesMonoBundlethe base directory of a NativeAOT process started there. The bundle apphost step (BundleAppHost.targets) is skipped. - Validation: the error is
native-aot-host(the scenario’sNativeAotNeedsTargetHost); macOS targets keep their existinghost-unsupported.readyToRundefaults on, sonative-aot-ignoredwarns only for keys set away from their defaults (singleFile,trim,selfContained: false); readyToRun is simply not passed. - Symbols:
symbols: separatemoves<assembly>.dSYM,.dbgor.pdb(with the executable, Windows) into the zip;shipleaves them in the publish. Managed PDBs and XML docs of referenced assemblies are not published at all. - Native crash frames (ADR 0260): a NativeAOT frame records
nativeImage,nativeOffsetandnativeImageId(Mach-O UUID, ELF build id or PE CodeView id, read from the image in memory);mf-symbolicateresolves them withllvm-symbolizer,atosoraddr2linefrom a symbol file of the same id. - Tests: the NativeAOT export is checked by
build/template-smoke.shwithNATIVE_AOT=1(no managed assembly, PDB or runtimeconfig; native symbols in the symbols zip; a headless run), outsidejust testso unit-test jobs don’t pay minutes of ILC; CI’snative-aotjob (one per OS runner,HEADLESS_ONLY=1: no GPU needed),just template-smoke-aotandbuild/linux/run.sh aotrun it. (Until ADR 0289 it was the editor testNativeAotExportHasNoManagedAssemblies.)
Open questions
Section titled “Open questions”- Is Brotli enough, or is a zstd or LZ4 package (needs the dependency discussion) worth it for load time? Owner.
Phase 2’s
ContentLoadBenchmarkson the M5 MacBook (2026-11-06, not re-checked on a fully quiet machine): a 512² PNG decode 2.79 → 2.85 ms (+2 %, stored); a UI document 14.2 → 8.5 µs (faster); a 200 KB scene’s text 103 → 125 µs (+21 %, about 22 µs: the Brotli entry is decoded whole into its own buffer, ~200 KB more allocated). Only Brotli text is over the 10 % target, and by microseconds per file. SteamPipe chunking: answered in phase 2 (anchors, ADR 0247); the human checklist’s depot upload confirms it.Does the editor save a project right after migrating it?No; since phase 3 it saves when it opens a project whose file has no key.Does phase 4 stay here, or move to M12.6?Here (owner, 2026-11-07; ADR 0259); M12.6 and C0 reuse it.Add one NativeAOT export job per OS runner to CI?Yes (owner, 2026-11-07): thenative-aotjob, part ofci-success.ShouldYes; confirmed in phase 2 (nothing reads them by OS path).assets.index.jsonand the UID map live only inside the pack?
Related
Section titled “Related”- Game export, ADR 0229, ADR 0230
- Mobile:
IContentFileSystem,.mfpak,mf-cookand AOT; ADR 0100 - Consoles (C0: desktop NativeAOT smoke)
- Crash reporting → Symbols, Asset pipeline, Distribution (NuGet)