Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

magic-unity-coexist

A minimal Unity project that regression-tests which Clojure runtime the Editor loads, in both of the states the magic-unity package supports. It is the in-repo stand-in for the private consumer project where the coexistence bug class (#25, #30) was first observed. The driver, and the reasoning behind every check, is bb/magic/coexist.clj.

What it checks

The package ships both runtimes and MAGIC_RUNTIME_IN_EDITOR selects the Editor's; player builds always get MAGIC. So there are two valid steady states, and they assert opposite things:

state symbol Editor loads preloaded-clj core-clj-loadable clojure-versions
clojure-clr (default) unset ClojureCLR 1.11.0 0 false [1.11.0.0]
magic set the MAGIC fork 39 true [1.0.0.0]

Both must be silent: 0 Assembly is incompatible with the editor lines, 0 Duplicate assembly 'Clojure.dll' lines, and 0 Unloading broken assembly lines. player-clj-refs must not move between them. core-clj-loadable=false in the default state is #25 held by construction: the fork *.clj.dll are not in the editor domain, so ClojureCLR's namespace resolution can never reach them.

After the states, three more checks:

  • The upgrade path (three launches): import under the package packed without CljPluginConstraints.cs, upgrade to the real package with the consumer metas left in place, and assert Reconcile constrained every one of them (in one log line), and that a fresh launch drops them from the Editor. The upgrade launch must itself log Unloading broken assembly and the fresh launch must not, pinning that the noise converges and that the fixture can still produce it.
  • The toggle (one launch): EditorRuntimeProbe seeds a deliberately unsorted define list, sets and clears the symbol through Magic.Unity.EditorRuntime, and must show append-then-exact-restore with no build-target group's defines changed.
  • The logs: every log the run wrote is scanned for error-shaped lines, catching what no other check predicted.

Why this project and not magic-unity-smoke

Two ingredients smoke lacks:

  1. An immutable (PackageCache) install. bb coexist-noise installs from a repacked tarball; magic-unity-smoke is a mutable file: install, on which this bug class cannot appear.
  2. DLLs a consumer compiled, sitting outside the package, in Assets/Plugins/Consumer/, one per load shape.

The ClojureCLR runtime comes from the package, exactly as a consumer's would, which is why the project runs API Compatibility Level .NET Framework.

The three load shapes

Assets/Plugins/Consumer/ What it holds What it pins
smoke.control_flow.clj.dll fn types implementing Magic.Function, so typed invoke unconstrained in a ClojureCLR Editor it fails type load and Unity unloads it as broken, the loud symptom
smoke.interop.cljr.dll no Magic.Function types it binds cleanly to ClojureCLR's Clojure.dll, the silent shape
smoke_csharp.dll plain C#, the kind a library ships the constrainer matches the three compiled-Clojure extensions only, so it walks past this one and both Editor states load it

The .metas are package output, written by the constrainer on import, so they are gitignored and deleted before each import. Committing them would turn the constraining into setup.

Running it

Close all open instances of Unity first, then run one of:

bb coexist-noise              # both states, then the upgrade path and the toggle
bb coexist-noise clojure-clr  # just the default state, plus those
bb coexist-noise magic        # just the opted-in state, plus those

A full run is eight Unity launches (two per state, three for the upgrade path, one for the toggle) on Unity 2022.3.62f3.

The tarball, Packages/packages-lock.json, Logs/ and the consumer .metas are build artifacts and are gitignored.

The [CoexistenceProbe] marker line in the editor log carries the per-run state:

[CoexistenceProbe] symbol=unset preloaded-clj=0 core-clj-loadable=false core-clj-load=FileNotFoundException clojure-versions=[1.11.0.0] editor-clj-refs=0 player-clj-refs=39 csharp-in-domain=true csharp-editor-refs=1

Player builds are unaffected by the selection; the end-to-end confirmation is an IL2CPP Build & Run in magic-unity-smoke in both symbol states.