Skip to content

Changelog ​

All notable changes to this package are documented here. The format follows Keep a Changelog, versions follow Semantic Versioning.

[2.5.1] - 2026-12-03 ​

Fixed ​

  • World listeners and the entities still being created. A NextTick outside a runner, or a SystemsRunner.Run, called by a listener in the middle of a CreateEntity or CopyEntity (one begun without world listeners) made the world forget every entity still being created, not only the ones an exception had left: a world listener subscribed since was told the destroy of such an entity, though it never got its OnEntityCreated. Followed by a rollback (Clear, then WorldSerializer.Load), a creation nested in another then put back the record of the outer one after the load, and an entity the snapshot gave that handle, announced like any other, got no OnEntityDestroyed. A creation now keeps its record while it runs and removes it when it ends, also when an exception leaves it; NextTick and the end of the outermost Run forget only the entities of creations an exception cut.
  • An entity whose CreateEntity threw before it was announced (a listener of its component threw) while world listeners were subscribed was not recorded: its destroy was told to them, although it never had an OnEntityCreated. It now gets neither until the next NextTick outside a runner or the end of the outermost SystemsRunner.Run, as without world listeners.
  • A rollback (Clear, then WorldSerializer.Load) made by a listener no longer lets the operations still running go on with the restored entity that the snapshot gave the same handle. A creation or copy in progress sent that entity a second OnEntityCreated (or one to a world listener that already counted it as restored); the world listeners not told yet of a change in progress were told of it for the restored entity (a component it was given without an event, a removal it never had); a CopyEntity went on copying the source's components into the restored copy; a copy that failed afterwards destroyed the restored entity that had its handle. The same held for an AutoCopy, which runs between reading the source's value and storing it: one that destroyed the copy, cleared the world or rolled it back still had its value stored, on the freed slot (in release the next entity created there found the component without an Add, and an Add of it threw "already has component"; under KENSEI_DEBUG CopyEntity threw) or on the restored entity that had the copy's handle. Clear and Load now end every notification, creation and copy in progress for the entities they remove: nothing more is told, announced, copied or destroyed for them. A world listener that throws in OnEntityCreated leaves the entity announced, as before: its destroy is told to every listener.

Documentation ​

  • World events: the entities a snapshot restores and the ones a listener creates during Warmup count as existing for world listeners, like entities that existed before a listener subscribed: they get no OnEntityCreated, and their destroy is told. An entity a listener destroys during Warmup gets no OnEntityDestroyed, as Warmup suppresses every world event of the call (unchanged; now written in world-events.md).

[2.5.0] - 2026-12-02 ​

Behaviour changes ​

What code written for 2.4.0 can notice; the entries below have the details.

  • Listeners: a world, filter or typed listener hears the changes that happen after it subscribed. One subscribed during a notification is not told of the change in progress; an IComponentListener<T> subscribed during an Add of its pool gets no OnAdded for that Add. A change nested in the notification of another change of the same entity goes only to the listeners that heard of that change, and a notification ends once its change is undone: the listeners after the one that undid it hear of neither.
  • Snapshots: WorldSerializer.Save writes format version 2. Version 1 snapshots still load; 2.4.0 and earlier do not load a snapshot written by this version (InvalidDataException, "Unsupported snapshot version 2").
  • KENSEI_DEBUG throws in two more cases: a command recorded on a PendingEntity of another buffer, of a recording the buffer has played back or cleared since (also right after Playback), or on a default one; and a Filter.Enumerator driven by hand and never disposed, reported by World.NextTick outside a Run and at the end of the outermost SystemsRunner.Run. Release checks neither.
  • SystemsRunner.Destroy destroys every system, also after the Destroy of one of them threw, and then rethrows: one exception as is, several as one flat AggregateException.
  • Generator: code that compiled on 2.4.0 and was silently wrong there is now an error, and the warnings KECS013 to KECS016 fail a TreatWarningsAsErrors build (see Generator, Breaking).
  • Editor: the Profiler window takes its entity names from the world being recorded, not from the World Inspector's world, and a world left by a previous play session is never bound automatically.

Fixed ​

  • Snapshots: WorldSerializer.Save now writes the generations of the slots that hold no entity (the free slots below the highest slot in use, and the slots above it whose generation a Clear had raised), and Load restores them. Before, a slot that was free at Save started again from the generation of a new world, so in the restored world a handle that was dead when the world was saved named the next entity created in its slot (IsAlive true for an entity that was destroyed before the save). The snapshot format version is 2; snapshots written by 2.4.0 and earlier (version 1) still load, without those generations, as before. Free slots are saved in the order the saved world would reuse them, so the entities created after Load get the same slots and handles as in the saved world. Loaded into a world with a past of its own (a rollback: Clear, then Load), a free slot keeps the later of the two generations, so a handle of an entity that lived and died there after the snapshot was taken stays dead.
  • WorldSerializer.Load and listeners. Pool and filter listeners run during Load, as documented. A listener that destroyed an entity being restored (a rule that destroys entities without health) let the components of that entity that were restored later land on the freed slot, where the next entity inherited them, or on an entity the listener had created in the slot; under KENSEI_DEBUG Load threw. Those components are now skipped. A listener that adds a component which the snapshot also holds (one component derived from another, in a world wired like the saved one) made Load throw "already has component"; the stored value now overwrites the listener's, without a second OnAdded. Load now refuses a world whose pools still hold components that an interrupted DestroyEntity left without an entity; call world.Clear() first. Up to 2.4.0 it did not check, and a stored component that met such an orphan in its pool threw "already has component" in the middle of the restore.
  • WorldSerializer.Save writes only the live entities with components and only their components. Called by a listener of DestroyEntity, it wrote the entity being destroyed and its components not removed yet, a stream that Load rejected; it now saves the world without that entity. It also wrote the components an interrupted DestroyEntity had left orphaned in their pools, which Load then put on a free slot; they are left out now, and so is an entity inside the removal of its last component (Save called by a listener of that removal), which the auto-destroy that follows takes.
  • A listener that throws in the middle of a structural change no longer leaves the world inconsistent. When an IFilterListener threw in OnEntityAdded or OnEntityRemoved, the filters of that component type that the update had not reached kept their old membership: an entity without the component stayed in an Inc filter (reading it through that filter failed), an entity with it stayed in an Exc filter. When a filter or world listener threw during the removal of an entity's last component, the entity stayed alive without components. Now the remaining filters are updated (without notifying their listeners) and the entity is destroyed before the exception leaves Add, Remove or DestroyEntity; the listeners not called yet are not called for that change. The first exception is the one reported: a world listener that throws again in the OnEntityDestroyed of that destroy does not replace it. A throw inside DestroyEntity (a listener or AutoReset) still leaves the components not removed yet orphaned in their pools, but the released slot now leaves every filter and owning group (an owning group kept counting the dead entity as a member) and is not reused until Clear, so a new entity never meets those components; a snapshot keeps it so (format version 2 stores those slots).
  • An AutoReset that throws during Remove on a pool that belongs to an owning group or tracks changes left the component in place but took the entity out of its group (the group no longer listed an entity that had every owned component) and gave the component the change version of the pool's last component. AutoReset now runs before the group swap and the version move, as it already ran before the swap-remove: when it throws, nothing has been changed for the removal. An AutoReset only resets the value, so the order makes no other difference.
  • Listeners that change what they are being told about now hear every entity's changes in pairs and in order. When the first IFilterListener of a filter removed the component in OnEntityAdded, the second got OnEntityRemoved and then OnEntityAdded for an entity that was no longer in the filter; the same for world listeners, for a listener that adds the component back, and for one that destroys the entity in OnEntityCreated. Now a change nested in the notification of another change of the same entity (made directly or from a callback further in) goes only to the listeners that heard of that change, and the notification ends once its change is undone: the listeners after the one that undid it hear of neither, and the last call every listener gets matches the world. For world listeners an Add, a Remove, CreateEntity and CopyEntity count from the start: a filter listener that removes the component again while it is being added (or adds it back while it is removed) tells world listeners nothing (up to 2.4.0 they heard of the removal alone, or of a removal and two additions), and an entity a listener destroys while it is being created gets no OnEntityDestroyed either (it had no OnEntityCreated). A world listener subscribed while an entity is created (by a listener of its components) and destroyed before its OnEntityCreated is sent gets no OnEntityDestroyed for it either, also when the entity being destroyed is not the one being created but one whose own CreateEntity is still running further out (a listener of a component of an entity being made creates another, whose listener destroys the first). An entity whose CreateEntity or CopyEntity throws before it is announced gets neither OnEntityCreated nor OnEntityDestroyed (until the next NextTick); a snapshot loaded before then (a rollback: Clear, then WorldSerializer.Load) drops that record, so an entity to which the restored generations give the same handle again is announced like any other. Listeners never change which slot or handle an entity gets. When a listener destroys an entity whose component's removal is still being told and creates another that takes its slot (destroy and spawn a replacement), the listeners not told yet hear that removal before the new entity's events; up to 2.4.0 they never heard it, and then heard the new entity's component come.
  • CopyEntity checks its source after telling the world listeners still to hear of a removal in the slot the copy takes: one of them may destroy the source, and CopyEntity then behaves as for any dead source (Entity.Null, under KENSEI_DEBUG an exception) instead of leaving an entity without components.
  • A listener hears the changes that happen after it subscribed: one subscribed during a notification (also a world listener that a filter listener subscribes while the filters are updated) is not told of that change, but of the changes after it, nested ones included; OnEntityCreated goes to the listeners subscribed when it is sent. Up to 2.4.0 a world listener subscribed by a filter listener got the change in progress, and could hear it twice. Behaviour change: the rule now holds for typed listeners as well. An IComponentListener<T> that a filter or world listener subscribes during an Add of its pool gets no OnAdded for that Add (the component was stored before it subscribed); its first OnAdded is for the next Add. Up to 2.4.0 that depended on the pool: the new listener got the OnAdded when the pool already had a typed listener when the Add started, and did not when it had none. A typed listener unsubscribed during the Add still gets no OnAdded, and a dispatch that has started still goes over the listeners it started with.
  • Change tracking no longer breaks when the world's change counter passes int.MaxValue (two billion Add, Modify and MarkChanged calls on tracking pools: hours of play for a game that marks a few thousand components per frame). The counter went negative, so ChangedSince reported nothing as changed against a bookmark taken before the wrap and old components as changed against one taken after it. The counter now starts again at 1 and ChangedSince compares across that. Nothing changes before the first wrap. After it a bookmark is exact for the next 2^30 writes (see World.ChangeVersion); compare versions with ChangedSince, a plain > on ChangedVersion values does not survive the wrap.
  • Change tracking past the first wrap of the counter lost changes made by Modify/MarkChanged in ParallelRunner jobs: the counter is incremented without synchronization, so a worker can leave it below versions other workers handed out, and those versions looked a whole turn old to ChangedSince and to the aging. Such versions now count as the newest, the aging replaces only versions that are still old, and the first wrap is aged by one worker before any version of the new turn is stored; the worker that ages at the first wrap lets the others go on also if it fails. A job's writes may still share a version or show as changed against a bookmark taken after the job; no write is lost.
  • CommandBuffer.Playback: commands that a listener records into the buffer while it is played back are applied by the same Playback, but when they created entities past the buffer's capacity for pending entities (16 at first) Playback threw IndexOutOfRangeException and dropped the rest.
  • SystemsRunner.Run: when a system threw and the OneFrame cleanup threw as well (a listener of a OneFrame component, AutoReset), Run reported the cleanup's exception, the system's was lost, and the OneFrame types after the failing one were not cleaned, so their events were processed again in the next frame. Every OneFrame type is now cleaned, and the first exception is the one Run reports: the system's when a system threw, otherwise the one of the first cleanup that failed.
  • SystemsRunner.Destroy stopped at the first system whose Destroy threw: the systems after it (in reverse order) were never destroyed, and a nested runner among them stayed initialized, so the next Init skipped it. Every system is now destroyed, those of nested runners included; then the exception is rethrown as is, or, when more than one Destroy threw, one flat AggregateException holds them all in the order they were thrown, as for the rollback of Init. A nested runner of a class derived from SystemsRunner that implements IDestroySystem.Destroy again is destroyed through that method, called once, as before; its systems are now destroyed also when that method throws before it calls the base one, or never calls it. EcsBootstrap.OnDestroy destroys the world also when the Destroy of a system throws.
  • The OneFrame cleanup of one type stopped at the first component whose OnRemoved listener or AutoReset threw, so the other components of that type stayed for the next frame. That component stays, as after any Remove, the others are removed, and the first exception is the one reported. The cleanup of a disabled runner or group (cleanWhenDisabled types) now cleans every type when one of them throws, as Run already did.
  • World.Clear with an AutoReset that throws left the world half cleared: the pools after the failing one, the filters and the groups kept their contents while every entity was gone. Clear now finishes, then rethrows the first exception. World.Destroy, which clears first, stopped there as well: the world stayed not destroyed (IsDestroyed false, still listed by the editor windows) until a second Destroy. It now finishes too (the world is destroyed and drops out of the lists), then rethrows.
  • CopyEntity whose AutoCopy (or a listener of a copied component) threw left the copy alive, with the components copied before the failure or with none when the first one failed: an entity the caller never got the handle of, which no filter saw when it had no component. The copy is now destroyed before the exception leaves; world listeners hear nothing of it.
  • KENSEI_DEBUG: a PendingEntity of another CommandBuffer, of a recording the buffer has played back or cleared since, or a default one, was accepted and silently named another entity of the buffer. Recording a command on it now throws InvalidOperationException; release does not check it, as for other handles. Behaviour change under KENSEI_DEBUG: this includes a command recorded on a pending entity after its Playback, before the buffer records another CreateEntity. Up to 2.4.0 that reached the entity the Playback had created (its id was still resolved), in every build; it throws now under KENSEI_DEBUG and still lands there in release, until the new recording creates an entity first. Keep the Entity to address it after Playback. PendingEntity remains an unmanaged struct in both builds (it holds numbers, no reference to its buffer; 4 bytes in release, 12 under KENSEI_DEBUG), so stackalloc PendingEntity[n] and where T : unmanaged compile in both.
  • KENSEI_DEBUG: a Filter.Enumerator driven by hand (GetEnumerator, MoveNext) and never disposed kept the filter's removal-during-iteration guard held for good, and later removals from the filter threw the double-visit error at random. World.NextTick outside a Run and the end of the outermost SystemsRunner.Run now release such a guard and throw, naming the filter.
  • KENSEI_DEBUG: a second Dispose of a Filter.Enumerator ended one more iteration than there was: it released the removal-during-iteration guard of another loop running over the filter, or left the filter's count of running loops below zero: the next foreach over that filter then threw IndexOutOfRangeException, or World.NextTick (the end of the outermost SystemsRunner.Run) reported an iteration "never ended" with "(-1 enumerators)". A repeated Dispose now does nothing, and the count never goes below zero.
  • KENSEI_DEBUG: the removal-during-iteration check (an entity a running foreach has not reached leaves the iterated filter, so an entity already visited would be visited twice) threw in the middle of the removal: the component was gone from its pool, but its entity stayed in the iterated filter, where reading the component failed, and the filters after that one were not updated. The exception is now thrown once the removal is complete, as release completes it: the entity has left the filter, every other filter is updated and an entity left without components is destroyed. A DestroyEntity it interrupts ends like after any exception inside it (the slot is released and leaves every filter, the components not removed yet stay orphaned until Clear). The OneFrame cleanup that meets the check (a loop over a filter of the type left open by a system) removes every component and reports once; it stopped at the first one.
  • Unity, .NET trimming and NativeAOT: managed code stripping at Medium or High removed IAutoReset<T>.AutoReset and IAutoCopy<T>.AutoCopy (the pool reached them only through reflection: GetInterfaceMap and Delegate.CreateDelegate), and creating the pool of any component that implements them threw in the player (ArgumentNullException on IL2CPP, IndexOutOfRangeException on Mono and NativeAOT). That included EventBuffer<T> and Listeners<T>, so the first world.AddEvent or world.Subscribe failed. The pool now calls them through the interface on one boxed default(T), with no reflection and no [Preserve] needed (checked in release IL2CPP and Mono players at Managed Stripping Level High, implicit and explicit implementations, and in a NativeAOT build); no allocation per call.
  • Unity: EcsBootstrap lifecycle methods (Awake, Start, Update, FixedUpdate, LateUpdate, OnDestroy) are protected virtual. A subclass method with one of these names used to replace the bootstrap's one silently (no world, no initialization, no update or no cleanup); it now gets compiler warning CS0114, an error in the Console in the editor and under KENSEI_DEBUG, and, for a replaced Awake, one clear error in every build instead of a NullReferenceException per frame. Override the method and call the base one. A replacing method that calls the one it hides (protected new virtual void Update() { base.Update(); }) is not reported, also from an iterator or async Start, a lambda or a local function, also in a generic base class.
  • Unity: an EcsBootstrap subclass method with the name of a Unity message and with parameters (Update(float dt)) is reported with an error in the editor and under KENSEI_DEBUG: Unity calls nothing for that message, so the bootstrap's own method never ran, with no message from the package.
  • Unity: EcsBootstrap.OnDestroy: when the Destroy of a system throws, that first exception is the one that leaves; a later one from World.Destroy is logged as an error instead of replacing it.

Performance ​

Against 2.4.0, measured on .NET 8 (Arm64 RyuJIT).

  • Listener dispatch. A notification now keeps which listeners have heard of it (see Fixed), so that a change nested in it reaches only those. It is kept out of the world's and the filter's bookkeeping until a listener makes something look for it (it changes the entity it is told about, subscribes or unsubscribes, or another change is told from inside it), so listeners that only read cost little more than before. A change told to no listener, to one listener of a kind or to typed listeners (IComponentListener<T>) costs what it did in 2.4.0; told to two to four listeners of a filter, 2 to 8% more; told to two to four world listeners, 9 to 20% more (about 1 ns). CreateEntity followed by DestroyEntity takes about 5% longer with one world listener and 12 to 24% longer with two to four; CopyEntity 29 to 36% longer with world listeners.
  • CreateEntity is 4 to 13% faster (5.1 to 4.5 ns with one component) and DestroyEntity 4 to 13% faster (7.8 to 6.8 ns): the slot allocation is inlined into CreateEntity, and what DestroyEntity does when a listener throws is written as handlers instead of finally blocks, which the JIT called as functions on every destroy. CopyEntity without listeners takes 4 to 8% longer than in 2.4.0 (it destroys the copy when a component cannot be copied).
  • WorldSerializer.Save is four times faster (20 to 4.5 ns per entity with two or three components) and Load a third faster (20 to 13 ns): the entity table, the free-slot list and the components without a formatter go to and from the stream through a buffer, many at a time, instead of one call per number. The stream is the same, byte for byte.
  • SystemsRunner.Run costs 5 to 9% less per system, and the OneFrame cleanup 6% less (13% for OneFrame<EventBuffer<T>>).

Generator ​

Breaking ​

Code that compiled on 2.4.0 and was silently wrong there:

  • 2.1 layout: a base.Init(world, shared) that C# binds to another Init overload is KECS006: an overload of a class in between, or one next to a base Init that is a hand-written override of a generated Init (C# looks that override up at the generated base, above the overload). The base Init was skipped before; rename the overload.
  • A class that lists IInitSystem over a hand-written override of an Init hiding a generated base's Init is the 2.1 layout: KECS006 without the base.Init call. It was chained silently before; a base.Init there was KECS012 and is now required.
  • An injection attribute written through a using alias is recognised (see Fixed), so such a class with a hand-written Init gets KECS002 and with a member named Init gets KECS018.
  • KECS019 is an error also for a system no runner initialises.
  • TreatWarningsAsErrors projects fail on KECS013 to KECS016 (KECS014 to KECS016 are new, KECS015 also on events, KECS013 also for a base.Init call that an overload takes, see Fixed); list them in WarningsNotAsErrors.

Added ​

  • New warnings KECS014 (static field with an injection attribute), KECS015 ([field: ...] on an auto-property or a field-like event) and KECS016 (two kinds of injection attribute on one field): the cases where a marked field was left out with no diagnostic.
  • KECS020 (error): a failure of the generator on one class is reported on that class; the others still get their Init.
  • KECS018 for a type parameter named Init; a class with a type parameter named OnInit gets its Init without the hook.

Fixed ​

  • Injection attributes written through a using alias (using Inject = KenseiECS.PoolAttribute;, also a global using, and [K::Pool]) were not noticed and the field stayed null; they are injected now.
  • An Init overload with two parameters other than (World, SharedData) was reported as KECS002 and the class got no generated Init.
  • [field: Pool] on an auto-property next to an injected field produced generated code that did not compile.
  • A file-local system class (file partial class, C# 11), a class nested in a file-local type, and a file-local component type in [Inc], [Exc] or [Any] produced generated code that did not compile; they are now the error KECS017 and the class gets no generated code.
  • A field, property, event or nested type named Init in a system class, and a system class named Init, produced generated code that did not compile (CS0102, CS0542); they are now the error KECS018 and the class gets no generated Init.
  • A component type listed in [Exc] and also in [Inc] or [Any] passed the generator, and the generated Init threw InvalidOperationException when it built the filter; it is now the error KECS019.
  • KECS019 is also reported for types that differ only in tuple element names.
  • [field: Pool] (or another injection attribute) on a field-like event was ignored with no diagnostic; it is now the warning KECS015, as on an auto-property.
  • A system class named OnInit got a generated partial void OnInit that did not compile (CS0542); it now gets its Init without the hook.
  • An override of a base OnInit hook in a system derived from a generated base whose own Init calls no base (its base is not a system, or has an abstract Init) never ran. The derived class's generated Init now calls it; a generated base in another assembly is judged the same way when its injected fields are protected or public.
  • A hand-written override Init of a generated Init whose base.Init(world, shared) C# binds to another Init overload compiled without a diagnostic, the generated Init never ran and the base fields stayed null (since 2.2.0). An overload such as Init(World, SharedData, int x = 0), Init(World, object) or Init(World, params SharedData[]) takes the call when it is declared in a class between, or in the generated base itself when its generated Init is an override. It is now the warning KECS013, reported on the call; an override whose only base.Init calls are written for another overload gets it too. The calls are judged as the compiler binds them once the generated code exists, so an overload next to a generated Init that is the first declaration, which loses to it, is not reported.
  • Hand-written override Init classes between two generated systems: a second override in a row, or one over a generated base in the 2.1 layout, was a false KECS006 on the derived system (KECS006 instead of KECS012 when its OnInit called base.Init). Below a generated base with its own error the derived system got a second KECS006.
  • [Inc(typeof(X))], [Exc] or [Any] with a type the compiler cannot resolve (a typo, or a type another generator adds) made the generator throw (CS8785), and no system of the assembly got its Init. The filter is now written with the name as given and the type is left to the compiler. An attribute with broken arguments no longer gets a misleading KECS007.
  • The packaged DLL carries the package version (it reported 1.0.0+<commit>); dotnet build KenseiECS.Generators -c Release -p:UpdatePackage=true rebuilds it into KenseiECS/Plugins.

Editor ​

  • The World Inspector, Systems and Profiler windows list every live world, not only the one a MonoBehaviour provider exposes, and switch between them with a dropdown in the toolbar. Worlds of IEcsWorldProvider/IEcsSystemsProvider behaviours (such as EcsBootstrap) come first, labelled with their GameObject; worlds created in code follow as World <id>, and root SystemsRunners after their Init. With several providers the windows bound whichever Unity returned first; now, when none is picked, the provider world with the lowest id. Worlds and root runners register in an internal, weakly referenced registry compiled only in the editor and under KENSEI_DEBUG: a world nobody references is still collected, a destroyed one drops out, and a release player has none of it.
  • With Debug Mode on, the EcsEntityView inspector hid the view's serialized fields (Destroy Entity With Game Object, Entity Name). It now draws them above the entity, supports multi-selection, and applies to subclasses of EcsEntityView too.
  • Editor windows held strong references to every world and runner they listed; they now hold them weakly.
  • Enter Play Mode without domain reload: a world left by the previous session is listed last as World <id> (previous session) and is never bound automatically. With only previous-session worlds alive, the windows bind nothing until one is picked.
  • Profiler window: entity names come from the world passed to EcsProfiler.Enable; the toolbar wraps and is fully reachable at 430 pt. Behaviour change: the Profiler no longer shares its names world with the World Inspector.
  • World Inspector and Systems windows: dropdowns are sized by their longest label with a tooltip; "Reset peaks" and "Clear" stay in view.

Documentation ​

  • IRangeJob, ParallelRunner: the XML docs said the runner copies the job struct to each worker. It keeps one copy that every worker and the calling thread execute, so a field the job writes is shared between threads and never reaches the struct passed to Run.
  • IFilterListener, IWorldEventListener: what a listener that undoes the change, or throws, means for the listeners after it.
  • The CommandBuffer, FAQ and migration examples recorded a hit with CommandBuffer.Set, which keeps only the last of two hits on one target in a frame; they use world.AddEvent now.
  • Warnings for Subscribe without the listener interface and for AddEvent without OneFrame<EventBuffer<T>>(); the world dropdown of the editor windows; managed stripping levels.
  • Debug mode, world lifecycle and FAQ: CreateEntity and Pool<T> on a destroyed world in a release IL2CPP player crash the process (World is compiled without null checks there); the pages promised NullReferenceException, which is what Mono and .NET throw. Debug mode: the report of an iteration that was never ended also comes for a foreach over a filter wrapped around a root Run() or World.NextTick() outside any Run, and that Run() then skips its systems for the frame. World events and entities: a world listener that throws in OnEntityCreated leaves the entity alive and complete, for CopyEntity as for CreateEntity.
  • AGENTS.md: rule 1 says that pausing a whole phase is the runner's job (SetActive on its SystemsRunner), not an if in each system.
  • Snapshots, architecture, threading, change tracking, listeners, runner and CommandBuffer pages describe the fixes above: snapshot format version 2 and the restore steps (free-slot order, rollback, the refusal of orphaned components), Load with listeners, the order in which listeners hear a change that one of them undoes, the state of the world after a throwing listener, the counter wrap and Modify/MarkChanged in jobs, and the single job copy of ParallelRunner.
  • Example: Chasing stores an Entity handle and checks IsAlive instead of keeping a filter index across frames. The headless run uses a fixed seed, so its output is the same on every run.
  • Demo: the game pauses on the level-up screen and at game over by switching its gameplay group off with SystemsRunner.SetActive, instead of the host checking the game status before running the sim phase; the level-up offer and the swarm loop are switched by a tag and a filter ([Exc(typeof(Dead))], [Inc(typeof(Swarm))]) instead of an if on the game state. The simulation output is unchanged, for a level-up screen held open for any number of frames: a paused frame advances neither the world's tick nor the spatial grid, and Demo/Headless ends every run by comparing a run that holds its level-up screens open with one that does not.
  • CI runs the tests also with ENABLE_IL2CPP defined (-p:KenseiIl2Cpp=true), so the IL2CPP code paths are compiled and tested on .NET.

[2.4.0] - 2026-10-27 ​

Changed ​

  • A world that uses a component type with an index of 64 or above (more than one mask word) keeps 8 more bytes per entity slot: the summary of the mask words each entity uses (see Performance). world.ReserveEntities reserves it with the other per-entity arrays. Type indices are process-wide, so this depends on the types registered in the process, not only on the world's own.

Performance ​

No change in behaviour, also after an exception in a listener or an out-of-memory error while the mask grows.

  • Add and Remove: the world's per-change bookkeeping for a type no filter mentions is inlined into the pool, Remove decides the auto-destroy from the count it has just decremented while no filter or world listener can run, the filter updates read the mask arrays once per change instead of once per filter when no listener can run, Add and Remove read each pool array once, and Filter reads its count and dense array once on entry and exit.
  • The OneFrame cleanup (OneFrame<T>, DelHere<T>) removes each component in place while no callback can run (no listeners on the pool, its filters or the world). An AutoReset that changes the world anyway (it should only reset the value) makes the rest of the cleanup go through Remove, as before. CommandBuffer.Clear (also at the end of Playback) walks only the payload stores it created.
  • DestroyEntity stops reading mask words after the last one that holds a component of the entity (its component count says when every bit is met), and an auto-destroy (last component removed) reads none. After a destroy interrupted by a throwing listener, whose leftover components stay orphaned in their pools and can lower the count of the next entity in the slot, the world reads every word again until Clear.
  • A world with more than one mask word keeps per entity slot which words may hold a component of the entity (set by an Add into an empty word, reset when the slot is released): DestroyEntity and CopyEntity read word 0 and those words only, instead of every word. The words they read are scanned without re-reading the world's fields.
  • The world listener dispatch of CreateEntity, CopyEntity and DestroyEntity is a test of one flag before the call, and CreateEntity no longer writes the new slot's count (a released slot's is zero already); growing the free-slot list is out of line.
  • IL2CPP: TrailingZeroCount in the Unity build (netstandard2.1) is a shift-and-mask count instead of a De Bruijn table, so World has no static constructor and each set bit of DestroyEntity, CopyEntity and GetComponentTypes costs no class-initialization check or static load (clang compiles it to rbit + clz on ARM64). Filter.Enumerator walks an int[] instead of a Span<int> (whose indexer IL2CPP always bounds-checks); a default(Filter.Enumerator) still throws IndexOutOfRangeException from MoveNext. IsAlive, GetEntity, Filter.GetEnumerator and the Entity constructor are marked for inlining, so game code calls their inlined copies instead of a cross-module call.

Documentation ​

  • IAutoReset<T>.AutoReset: reset the value only; changing the world from it (adding or removing components, creating or destroying entities, subscribing listeners) is not supported.
  • AGENTS.md in the package, and the page Rules for AI Agents on the site: how to write game code on KenseiECS for an AI agent (a marker component instead of an if in Run, components as data, events as components, views called directly by a system, Entity handles, changes inside a filter loop, ref lifetime, allocation-free hot paths, KENSEI_DEBUG, the generator).

[2.3.1] - 2026-10-26 ​

Fixed ​

  • Under KENSEI_DEBUG the first CreateEntity of a process allocated about 400 KB, also with the profiler off: the static constructor of EcsProfiler created its ring buffer of MaxEvents (10,000) events. The buffer is now created by EcsProfiler.Enable; MaxEvents set before it applies as before.
  • When a system threw during SystemsRunner.Run and applying the listener removals queued by UnsubscribeLater threw as well (a listener whose Equals throws), Run reported the second exception and the system's was lost. The system's exception now propagates; the other one is dropped.

[2.3.0] - 2026-10-26 ​

Added ​

  • World.ReserveEntities(n) and World.ReservedEntities: reserve the world's own per-entity storage (generations, alive flags, component counts, every mask word and the free-slot list) for n entity slots, sized exactly. Pools and filters are not touched, except the reserved ones, whose sparse side covers the reserved slots, also after a later ReserveEntities.
  • ComponentPoolBase.Reserve(count) and ReservedComponents. Reserve moved from ComponentPool<T> to the non-generic base, so GetPool(i).Reserve(n) and a loop over ActivePools work without a type argument; code built against 2.2 keeps working.
  • Filters take their reserve from their component types: a filter whose Inc types are all reserved holds the smallest of their reserves (at most the sum of its Any types' reserves when those are all reserved; a filter without Inc types takes that sum), and at most ReservedEntities once the world reserved entity slots. This holds for a filter created after the reserve too, so the filters systems create in Init need nothing. The reserve follows the reserves of the types as they are now, whatever the order of the calls (a later ReserveEntities can lower it; arrays never shrink), and the obsolete World.Reserve moves its cap too. Filter.ReservedCount reports it.
  • World.UnsubscribeLater<T>(entity, listener): queues the removal of a listener and applies it when the outermost SystemsRunner.Run of the world returns, after the OneFrame cleanup, also when a system threw; called outside a Run, at the next World.NextTick (the root runner calls it before its systems; a world driven without a runner calls it itself). A listener leaves this way from inside its own callback while a system iterates the list it is in, also while its entity is being destroyed. A removal whose entity was destroyed by then is skipped (also when a new entity took the slot), World.Clear drops the queue, and on a destroyed world the call does nothing; the queue is kept per listener type and allocates nothing once it reached its peak.
  • Under KENSEI_DEBUG, while EcsProfiler records, the growth of a pool or filter that nothing reserved is logged as StorageGrown marked (not reserved): that is how a forgotten hot type shows. It is not counted in GrowthsAfterReserve.

Changed ​

  • Behaviour change: pool.Reserve also extends the pool's sparse array to ReservedEntities and reserves the filters whose Inc types it completes; filter.Reserve also allocates the sparse pages of the reserved slots. A filter's dense array can therefore move in a pool.Reserve: an Entities span taken before it is invalid afterwards (a running foreach is not affected).
  • Behaviour change: GrowthsAfterReserve counts each reserved array that grows past its reserve: the world's slots and free-slot list past ReservedEntities, a reserved pool's or filter's dense side past its own reserve and its sparse side past ReservedEntities. Growth of a pool or filter that nothing reserved is no longer counted; the obsolete World.Reserve still makes every pool and filter count in the dimensions it was given.
  • Reserve of a pool or a filter of a destroyed world throws ObjectDisposedException, like World.Reserve.
  • Under KENSEI_DEBUG, World.Unsubscribe accepts an entity whose own DestroyEntity is running, as component access does; it threw "not alive" for a listener that unsubscribed while its entity was destroyed.
  • SystemsRunner.Add with a null system throws ArgumentNullException in every build, like AddGroup and AddPhase; it was a NullReferenceException under KENSEI_DEBUG and a runner that failed later otherwise.
  • SystemsRunner.Run(World) counts its nesting on the world, so that the outermost Run applies the queued listener removals. A phase driven on its own (the fixed and late runners of EcsBootstrap) is the outermost Run of its frame step and applies the removals queued during it.

Deprecated ​

  • World.Reserve(entities, components) sizes every pool and filter, singletons and those created later included: about 4 bytes × entities per pool, some 200 MB of sparse arrays at 1000 types and 50,000 entities. Use ReserveEntities(entities), and Pool<T>().Reserve(count) for the types whose count changes during play; the filters over reserved types follow. Its behaviour is unchanged; removed in 3.0.
  • Listeners<T>.Invoke (both overloads), Add and Remove. A system iterates Values and calls the listeners itself (var values = listeners.Values; for (int i = 0; values != null && i < values.Count; i++) values[i].OnDamage(damage);; Values is null on a component added without a list): no delegate, no snapshot, nothing allocated. A callback must not change the list it is called from, and World.UnsubscribeLater is how a listener leaves from inside one. Instead of Add and Remove, use World.Subscribe and World.Unsubscribe. Their behaviour is unchanged; removed in 3.0.
  • Both produce warning CS0618, an error in projects that treat warnings as errors.

Performance ​

  • Reserve footprint, measured on the prototype (.NET; the IL2CPP byte counts are the same), the obsolete Reserve(n, n) / Reserve(n) with the hot pools and filters / ReserveEntities with the hot pools: 1000 types × 50,000 entities × 150 filters 916 / 256 / 44 MB; 60 types × 528 entities × 40 filters 0.76 / 0.42 / 0.37 MB. Peak resident memory of an IL2CPP process with 300 types × 50,000 entities: 395 / 197 / 108 MB. A frame of play allocates nothing with any of them.
  • Listener dispatch under IL2CPP (64 entities, Apple M5, the il2cpp CLI of Unity 6000.3.13f1 with the player's checks), nanoseconds per dispatch for 1 / 8 / 32 listeners: a for loop over Values 2.0–2.2 / 14.4–14.5 / 56.5, foreach 5.7–6.0 / 22.4–24.4 / 76.0, the 2.2 Invoke with a static lambda 32–33 / 53–54 / 121–125.
  • Reserve has no generic body per component type any more (302 fewer in the benchmark's IL2CPP build, 162 KB smaller binary). The hot path compiles to the same IL and C++ as in 2.2.2.

Documentation ​

  • Listener bridge rewritten: a view reference in a component found through a filter, Listeners<T> iterated by the system, the rule for callbacks, UnsubscribeLater and the migration from Invoke. World config: reserving for the peak (ReserveEntities and the hot pools, filters following their types, what to reserve, small worlds, migrating from World.Reserve, measurements); the anchor #reserving-capacity-later is now #reserving-for-the-peak. Bootstrap: reserve in Configure. Command buffer: an EventBuffer<T> written over one with a list returns that list to the pool, also when the new buffer has none. Architecture, components, one-frame, world lifecycle, debug mode, debug tools, the migration guide and the package README follow.

[2.2.2] - 2026-10-26 ​

Fixed ​

  • World.Warmup with a listener that destroys its temporary entity (a "Health ≤ 0 destroys the entity" rule subscribed in Init fires on the default Health; any IComponentListener<T> or IFilterListener that destroys the entity it is handed) kept adding the remaining types to the freed slot. In release the next entity created there inherited those components, their mask bits and filter memberships (a singleton created in Init got a twin and GetSingleton threw); under KENSEI_DEBUG Warmup threw from EcsBootstrap.Start. If the listener also created an entity, which took the freed slot, every remaining type was added to it in both builds. Warmup now checks the temporary entity's handle before each type and continues on a new temporary entity when it is gone, and skips a type a listener already added to it (that threw "already has component"). Since 2.0.0.
  • Typed listeners that remove components of their own pool re-entrantly. 2.1.1 kept one continuation slot per pool, so two linked entities whose OnRemoved removes the partner (if (pool.Has(other)) pool.Remove(other)) recursed until the stack overflowed (a native crash on IL2CPP), longer cycles did too (also across two pools), and with DestroyEntity instead of the Has guard the first listener got a second OnRemoved. Removals in progress are now a stack of frames: a nested Remove of a component whose removal is running continues that notification, every listener gets one OnRemoved per component, and a cycle ends. Since 2.0.0; 2.1.1 fixed only an entity removing itself.
  • A component re-created in the slot it is being removed from is no longer taken for the old one. When an OnRemoved listener removes the component and adds it again (to the same entity, or by destroying the entity and creating one that reuses the slot), the outer Remove no longer removes the new component or destroys the new entity, and the new component's own removal notifies every listener (the first one was skipped). The same in Add: when a listener removes and re-adds the component, or destroys the entity and a new one takes the slot, the remaining typed listeners no longer get a second OnAdded for the new component. A removal also keeps the listener array it started with, so a listener that unsubscribes during it no longer makes the next one miss its OnRemoved. Since 2.0.0.
  • Adding T while a filter listener takes T away again left the entity out of Exc<T> filters it matches: an Inc<T> listener that removes T in OnEntityAdded, an Exc<T> listener that removes T in OnEntityRemoved (the later Exc<T> filters lost it), a listener that destroys the entity and creates a new one in its slot, and a nested Add<U> that an Inc<U> listener rolled back (Exc<U>). The mirror of the 2.1.1 fix for Remove: after a filter whose listeners ran, the update stops when the entity no longer has T or its slot holds another entity. Since 2.0.0.
  • CopyEntity with a listener that destroys the copy (an IComponentListener<T>.OnAdded or IFilterListener of a copied component: a spawn limit, a "Health ≤ 0 destroys the entity" rule) kept copying the remaining components into the freed slot. In release the next entity created there inherited them, with their mask bits and filter memberships (its component count said 1 with three components in the pools), and OnEntityCreated went out for the dead copy; under KENSEI_DEBUG CopyEntity threw with a message about int indices from a filter. When the listener created an entity, which took the slot, the remaining components and a second OnEntityCreated went to that entity in both builds. CopyEntity now stops when the copy is destroyed (it returns the dead handle and sends no OnEntityCreated) and when the source is destroyed (the copy keeps what it got and is created; an entity in the source's slot is not copied). CreateEntity<T> no longer sends OnEntityCreated for an entity that a listener of its component destroyed. EcsEntityView.Spawn skips the remaining providers when a listener destroyed the entity (it applied them to the freed slot, under KENSEI_DEBUG the next one threw) and binds the view to the dead handle. Since 2.0.0.
  • CopyEntity of an entity inside the removal of its last component (from an IWorldEventListener.OnComponentRemoved or an IFilterListener.OnEntityRemoved of that removal, which run before the auto-destroy) created an alive entity without components: no filter saw it, nothing destroyed it, and world listeners got OnEntityCreated for it. Such a source has nothing to copy: CopyEntity now returns Entity.Null and creates nothing, in both builds. Since 2.0.0.
  • World.Clear from a listener inside DestroyEntity (an OnEntityDestroyed or OnRemoved that restarts the level when the player dies) left the world broken: the destroy went on after Clear and released the slot again, so EntityCount was -1, the free list held a slot past the end, and the next entity created there was not alive (IsAlive false, its component on a dead slot, inherited by the entity after it); under KENSEI_DEBUG the next Add threw. An entity that the listener created after Clear, in the slot being destroyed, lost its components to the destroy. DestroyEntity now stops at a Clear, as Remove already did. Since 2.0.0.
  • During DestroyEntity, world.Has<T> returned false for the components the destroy had not removed yet, although they were still in their pools, readable with Get, and got their own OnRemoved later: if (world.Has<Position>(e)) in an OnRemoved of Health skipped silently, and if (!world.Has<B>(e)) world.Add(e, …) threw "already has component". A plain Remove did not do that. With component types in more than one mask word (over 64 types), removing a component of the dying entity could also put it into an Exc filter of that component, whose listeners saw it enter, until the components that made it match were removed. DestroyEntity now clears each component's mask bit as it removes it, and removing a component of a dying entity no longer lets it into a filter. A component that a listener adds to the dying entity still lets it enter the filters it then matches, now with the components not removed yet (OnEntityAdded sees it dead), until the destroy removes that component too; see IFilterListener. Since 2.0.0.
  • A pooled EventBuffer<T> list could end up on two entities. A struct copy of the buffer stored again after its component was removed — through Add, CommandBuffer.Add/Set/CreateEntity, or the pattern 2.1.1 documented, var b = world.Get<EventBuffer<Hit>>(e); b.Add(h); cb.Set(e, b);, with a OneFrame cleanup (also of a nested runner) or a recorded Remove before Playback — put a list that was back in the static pool on the entity; the next buffer, in any world, got the same list, and the pool handed it out twice from then on (in a measured loop of the documented pattern after 2,000 frames: 15,964 duplicate pool entries, 28 entity pairs sharing a list, 132,800 B allocated over frames 1,001–2,000 instead of 1,704 B). The same happened, in any world, to a copy of another entity's buffer, also one whose list world.AddEvent had rented for a buffer the entity already had without a list (added as new EventBuffer<T>(), or set to default), and to a buffer forwarded from OnRemoved to another entity. Pooled lists now record whether they are free and which entity holds them (a pool id and an entity index): a value whose list is free or held by another entity is stored with an empty list of its own (Count 0, and Values is not null, so a reader that loops over Values.Count keeps working), an overwrite with such a value keeps the entity's buffer, a list returned twice is pooled once, and a list a stale copy appended to is cleared before it is handed out again. world.AddEvent records the entity as the holder of every list it rents. Every rent of a pooled list is numbered and the buffer that rents it keeps the number (in an internal field: EventBuffer<T> is 16 bytes instead of 8 on 64-bit), so a stale copy that holds a list rented again since, for a new buffer that is not stored yet (var b = new EventBuffer<T>(); b.Add(x); cb.Add(e, b);), is stored with the empty list and the new buffer keeps its events (in 2.2.1 both entities ended up with the list). Writes straight into the pool's storage (Get(e) = copy, RawData) and pool.Get(e).Add(v) on a buffer without a list (which rents a list without a holder) are not checked. Since 2.0.0.
  • CommandBuffer.Set overwriting an EventBuffer<T> with a buffer that brings its own list returns the replaced list to the pool; it used to be dropped.
  • World.Destroy kept the owning groups, and through them every owned pool's arrays, reachable from the destroyed World object.
  • A World.Reserve that ran out of memory left the world unusable: it recorded the reserved sizes first, so every pool and filter created afterwards tried the same allocation and threw, and an interrupted growth could leave parallel arrays (slot arrays, a pool's dense arrays and change versions) with different lengths. Every array is now allocated before it replaces the old one, and the reserved sizes are recorded only after everything succeeded.
  • Filter.Reserve(n) and the filter side of World.Reserve(entities, n) allocated up to twice n; they now size the dense array exactly, like pools. For int.MaxValue, which needs one slot more than an array can have, both throw OutOfMemoryException and change nothing; 2.2.1 did nothing for the filter, and in a world with filters but no pool World.Reserve(…, int.MaxValue) recorded the size anyway, so every pool created afterwards threw.
  • When the rollback of a failed SystemsRunner.Init threw both inside a nested runner (a group or a phase, such as the fixed and late phases of EcsBootstrap) and in a runner above it, Init threw an AggregateException nested in another: InnerExceptions[0] was the inner AggregateException, not the original exception, and Flatten() listed the outer rollback errors first. It now throws one flat AggregateException at any depth: the original exception, then every rollback exception in the order they were thrown. Without rollback errors the original exception is still rethrown unwrapped; an AggregateException thrown by a system itself is kept whole as the original one.
  • Under KENSEI_DEBUG a nested runner with a different World or SharedData was rejected only after its entry had been added to the parent; both checks now run before anything is registered. Registration errors name the method that was called (SystemsRunner.AddPhase("fixed", SystemsRunner): ...) instead of always Add.
  • SystemsRunner.Shared of a runner added to a group or phase before that group was added to its own parent (a tree built from the bottom up, such as the groups EcsBootstrap.Configure adds to fixedUpdate or lateUpdate) returned the group's own empty SharedData from then on, while the runner's systems got the root's in Init. A runner without SharedData of its own now reads its parent's at every call. Under KENSEI_DEBUG a runner constructed with the root's SharedData and added to such a group before the group joined the root was rejected ("different SharedData than its parent"); the check now runs once the SharedData is known: when the runner, or a group holding it, is added under a runner constructed with SharedData, otherwise in Init. Since 2.0.0.
  • EcsBootstrap: under KENSEI_DEBUG a system, group or phase that Configure registers in the update runner under "fixed" or "late" made Awake fail inside AddPhase with a message that did not mention EcsBootstrap. Awake now throws right after Configure, naming the system and saying that EcsBootstrap reserves these names for its phases. The phase names are unchanged, and the phases are still registered after Configure (initialized after the update systems, destroyed before them); release builds still check nothing.
  • EcsBootstrap: FixedUpdate and LateUpdate run their runner only while that runner is initialized (they checked Systems.IsInitialized). When Awake failed before the phases were registered (an exception in Configure, or the reserved name above), every FixedUpdate and LateUpdate ran a runner that Init never reached: under KENSEI_DEBUG it threw each time, in release it ran systems that were never initialized, and in both it advanced the world tick on every call, like a root runner. Such phases now stay idle.
  • EcsEntityView.Spawn called again before it returns — from a listener that the new entity's components trigger, such as an IComponentListener<T>.OnAdded or an IWorldEventListener.OnEntityCreated that spawns another view — no longer breaks the outer entity. Since 2.0.0 every call shared one static provider list, so the nested Spawn overwrote and cleared it: the outer entity lost the components of its remaining providers, and when the nested Spawn threw and the listener caught it, the outer entity got the child's providers instead. Each nesting depth now has its own list, reused by later calls, so Spawn still allocates nothing once warm; the list is also cleared when a listener throws.

Changed ​

  • Behaviour change: the rollback of a failed SystemsRunner.Init destroys only the systems whose Init completed and that implement IDestroySystem, at every nesting level. In 2.2.0 and 2.2.1 it destroyed every IDestroySystem registered before the failed system, so a system without IInitSystem (also one inside a nested runner that had completed its Init) was destroyed by the rollback: the retried Init and the frames after it ran with whatever its Destroy had released, and it was destroyed again at shutdown. Such a system now gets its Destroy only from Destroy() after a completed Init; a runner whose Init never succeeds does not destroy it, as in 2.1. Nested runners that completed Init are still rolled back system by system, the failing one still rolls itself back first, and the next Init still starts from the first system. The XML docs of IInitSystem, IDestroySystem and SystemsRunner.Init/Destroy describe the contract.
  • Behaviour change: a SystemsRunner can be registered only once, in one slot of one parent, in every build. Add, AddGroup, AddPhase and the obsolete Add(runner, name) throw InvalidOperationException for a runner that is already registered — in the same runner (two groups, two unnamed slots, a phase and a group) or in another one — naming its slot (the group "sim" (index 1) of this runner), and for a runner added to itself or to a runner nested in it. A rejected call registers nothing. Up to 2.2.1 a second registration was accepted, and its slots shared the runner's IsEnabled: after SetActive on one slot the other slots, IsActive and GetSystemInfo(i).IsEnabled disagreed with what actually ran, so the Systems window showed wrong checkboxes; a runner added to itself recursed without end in Init. To run the same systems at two points of a frame, use two runners.
  • Behaviour change: when a filter listener removes a component again while it is being added (or destroys the entity), world listeners get the OnComponentRemoved of that removal and no OnComponentAdded after it; up to 2.2.1 the OnComponentAdded followed and left them believing the entity had the component. The same for a removal: when a filter listener adds the component back while it is being removed (an Inc<T> listener in OnEntityRemoved, an Exc<T> listener in OnEntityAdded), world listeners get the OnComponentAdded of that addition and no OnComponentRemoved after it, and when it destroys the entity and creates one that takes the slot, they get the new entity's events and no OnComponentRemoved for the slot after them; up to 2.2.1 the OnComponentRemoved came last and told them the entity had lost the component, or that the new entity had. A world without filter listeners on the type pays nothing for it. Unchanged: a filter listener that removes the component and adds it back at once makes world listeners get the removal and then two OnComponentAdded, the re-added component's and the original Add's, and a world listener that a filter listener subscribes during an Add or Remove gets that change's event.
  • Behaviour change: a typed listener (IComponentListener<T>) that a filter or world listener subscribes during an Add of its pool gets the OnAdded of that Add only when the pool already had typed listeners when the Add started; otherwise its first OnAdded is for the next Add. Up to 2.2.1 it also got that OnAdded when the pool tracked changes, belonged to an owning group or held EventBuffer<T> (on a pool with none of these it did not either). With typed listeners present the OnAdded dispatch still starts after the filter and world listeners, over the listeners subscribed by then: one they unsubscribe gets no OnAdded, as up to 2.2.1.
  • Behaviour change: the ref returned by Add points at the scratch value also when a listener destroyed the entity and a new entity took its slot; it used to point at the new entity's component. When a listener removed the component and added it to the same entity again, it points at the new component, as before.
  • Behaviour change: a list assigned to EventBuffer<T>.Values by hand is still cleared when the component is removed, but no longer goes into the list pool.
  • Behaviour change: under KENSEI_DEBUG a dead handle is accepted only for the entity whose DestroyEntity is running. It used to pass validation (Add/Get/Has/Remove, AddEvent, pool.Add by index) whenever any entity was being destroyed, so a listener inside some DestroyEntity could add a component or an event to another, dead slot, which the next entity there inherited.

Performance ​

  • Add no longer re-reads the dense index when no filter or world listener ran; World.OnComponentAdded takes a lean path while no filter of the component's type has listeners and nothing is dispatched (each type counts its listened filters, so a filter listener elsewhere in the world does not slow this type down); World.OnComponentRemoved handles world listeners out of line; EventBuffer<T> pools check list ownership on Add only, record the holder as a pool id and an entity index and call the check through a class instead of an interface; the re-entrancy frames store their listener arrays only when there is one to store (on IL2CPP every store into a reference field, null included, calls the GC write barrier). In-process A/B against 2.2.1 on an Apple M5, interleaved runs, medians: IL2CPP (Unity 6000.3.13f1, macOS arm64, Release, incremental GC with its write barriers; no device measured) / .NET 8 / .NET 10; runs of the same code differed by up to 2%, and by up to 4% for creating and destroying entities on .NET. Faster: Add+Remove without hooks −17% / −10% / −6%, with four Inc filters −4% / −5% / −6%, with four Exc filters −6% / −3% / −1%, the same four Inc filters next to a listened filter of another type −5% / −7% / −6%, with change tracking −13% / −4% / +3%; DestroyEntity of five components in filters −7% / −1% / −1%; CreateEntity+DestroyEntity and CopyEntity+DestroyEntity within ±3%. Slower, all with listeners or EventBuffer<T>: with a typed listener +26% / +20% / +24% (the re-entrancy frames, about 3 ns per Add+Remove on IL2CPP); through a filter that has a listener +19% / +17% / +17% (the re-check of the entity after each filter whose listener ran, about 2.5 ns); with a world listener +13% / −1% / −4% for Add+Remove (after the world listeners Add checks that the entity still has the component, and Remove reports through a separate method) and +10% / +12% / +4% for DestroyEntity; an EventBuffer<T>'s first event in a frame plus its cleanup +16% / +6% / +11%, three events +8% / +4% / +6% (the ownership check).
  • SystemsRunner.SetActive(bool) on an inline group sets its slot directly instead of scanning the parent's run slots.
  • What the last fixes of this release cost (the OnAdded dispatch taking the typed listeners after the world update, a removal reaching world listeners its filter listeners subscribed, numbered list rents), measured in-process A/B against the state before them on an Apple M5 Pro, .NET 8 / .NET 10, interleaved runs, medians; IL2CPP not measured, so the IL2CPP figures above predate them: Add+Remove with a typed listener +1% / +1%, with Inc, Exc or Any filters −1 to +2% / +1 to +3%, through a filter that has a listener and no world listener +3 to +6% / +2 to +3%; an EventBuffer<T>'s first event in a frame plus its cleanup +3% / +5%, a frame of OneFrame events +5% / +4%, the read-modify-write through CommandBuffer.Set +5% / +5%; the other paths measured (no hooks, change tracking, groups, world listeners, CreateEntity/CopyEntity/DestroyEntity) within ±2%.

Generator ​

  • Behaviour change: the generated Init is public virtual in every class that is not sealed, whether or not the compilation contains subclasses of it; a sealed class keeps the plain public void Init. In 2.2.0 and 2.2.1 it was virtual only when a subclass in the same compilation overrode it, so the Init a subclass in another assembly saw depended on the subclasses (and defines) of the base's assembly: with a subclass under UNITY_EDITOR, DEVELOPMENT_BUILD or KENSEI_DEBUG, the Editor chained a derived system and reported (KECS012) the base.Init that the player build needed, while the player silently kept the 2.1 layout with the base fields null, or failed with KECS006. A derived system in another assembly is now chained in every build, so a base.Init it still calls from OnInit for the 2.1 layout is KECS012: delete it. A hand-written subclass that declares public void Init(World, SharedData) without override or new gets CS0114 instead of CS0108 (both warnings; it still hides the base Init).
  • Behaviour change: a derived generated Init fills the derived fields first, then calls base.Init(world, shared), then the derived OnInit. 2.2.0 called base.Init before filling the derived fields, so the base OnInit, a hand-written base Init and the virtual methods they call saw the derived fields null; on 2.1, where the derived OnInit called base.Init, they were already filled. This corrects the 2.2.0 entries "base fields, base OnInit, then derived fields and OnInit" and "the base still runs first": the base Init still runs before the derived OnInit, but after the derived fields, as on 2.1. A [Shared] field of the derived class is now read before the base Init runs, so an object the base OnInit adds to SharedData is not there yet. Code that stood in OnInit before the deleted base.Init line runs after the base Init.
  • Behaviour change: KECS006 again reports a class that keeps the 2.1 layout (lists IInitSystem over a base Init that cannot be overridden: not virtual, sealed, not public, hidden by a new Init in between, or from an assembly built by 2.2.1 or older) without a base.Init call, as 2.1.1 did, when the base Init would never run: it is the Init the runner reaches through IInitSystem.Init, or a base has injected fields (a new Init in between that does not implement IInitSystem.Init, with no injected fields above it, is taken for an unrelated method and not reported, as in 2.1.1); 2.2.0 dropped the check and the base Init with its injected fields was silently skipped. The check now also covers a hand-written non-virtual base Init that implements IInitSystem without injected fields, which 2.1.1 did not report, and a sealed or protected override of the base Init in a class between (Mid : Root { public sealed override void Init(...) }), which neither 2.1.1 nor 2.2.1 reported: the interface maps to the first declaration of the method, so the override was taken for an unrelated Init and both were skipped without a word. An explicit base IInitSystem.Init, which base.Init cannot reach, stays accepted without the call. Of a base in another assembly only the protected and public injected fields are seen, as for KECS013: over a base there with only private ones a missing base.Init is not reported.
  • New warning KECS013: a hand-written override of a generated Init (directly or through hand-written overriding classes) that has no base.Init in its own declarations. On 2.1 such an override did not compile (CS0506); since 2.2.0 it compiled and left the base fields null. The check is syntactic like KECS012; a generated base in another assembly is recognised only by its protected or public injected fields.
  • A hand-written base that implements IInitSystem through another interface (GameSystem : IGameSystem with IGameSystem : IInitSystem) and has a public virtual Init is chained; 2.2.0 reported KECS006 ("does not implement IInitSystem.Init") or, when the derived class listed IInitSystem, kept the 2.1 layout and skipped that Init without a warning. A derived class that lists such an interface itself keeps the 2.1 layout like one that lists IInitSystem. Whether a base Init is the one IInitSystem.Init maps to is decided by the compiler's interface mapping, now also for bases in other assemblies.
  • The base Init is no longer picked by name and member order. An explicit IInitSystem.Init that does part of the base's setup and then calls the public virtual void Init next to it (Init(world, shared) or this.Init(world, shared)) is chained in either member order: the runner calls the explicit one, which reaches the generated override; 2.2.0 and 2.2.1 chained it only when the public Init came first. An explicit implementation that does not call the public Init is KECS006, since an override of the public one would never run (when the public one came first, 2.2.0 overrode it anyway and the generated Init never ran). The call is read from source, so a base from another assembly with both is KECS006. A generic Init<T>(World, SharedData) whose T the call cannot infer no longer gives a false KECS006 and does not take the generated base.Init call; a non-void Init(World, SharedData) between two chained classes is reported as an overload that takes the call instead of a misleading "is not virtual"; a private Init of a base is ignored.
  • Behaviour change: such an explicit base IInitSystem.Init that does not call the public Init is KECS006 also when hand-written overrides of the public Init sit between the base and the derived class: the runner calls the explicit Init, so neither the overrides nor the generated Init run. 2.2.1 took an override for chainable, and the derived fields stayed null without a diagnostic. A base from another assembly is not read, so with an override in between it is KECS006 as well, also when its explicit Init calls the public one (2.2.1 compiled that, and it worked). A derived class that lists IInitSystem itself is chained over such overrides, as before (the interface then maps to the generated Init).
  • Behaviour change: KECS006 also reports an Init overload on the chained base itself and on the classes above it, up to the class that first declares the overridden Init. C# looks an override up at that class, so an overload such as Init(World, params SharedData[]), Init(World, object) or Init(World, SharedData, int x = 0) above a hand-written override or next to it (or above a generated override of an abstract Init) took the generated base.Init(world, shared), and the chained Inits never ran, without a word; 2.2.1 checked only the classes between. An overload in the class with the first declaration loses to it and stays allowed.
  • A hand-written base with an OnInit(World, SharedData) of its own (for example a virtual hook its Init calls) no longer breaks the derived generated class: 2.2.0 declared the generated partial void OnInit over it (CS0114 or CS0108 in the generated file) and failed with CS0111 when the derived class overrode the hook. The generated part now declares no partial OnInit over such a member, and an override of the hook runs once, after the derived fields are filled: from the base Init when the generated Init calls a base Init that can call the hook (the hook is declared in that base or in one of its bases), and from the generated Init otherwise (a base that is not a system, an abstract base Init, a hook declared in a hand-written class between a generated base and the derived class). In the 2.1 layout an override of a hook that the replaced base Init can call is KECS006: the generated Init would call it, and the base.Init that OnInit must call would run it again (without end, unless guarded). A partial void OnInit that the derived class implements anyway is still declared and called, with the hiding warning silenced in the generated file. The same removes CS0108 for a system nested in its generated base. An OnInit(World, SharedData) written without partial (CS0111 before) is called by the generated Init, unless it overrides a hook that the chained base Init calls.
  • Systems whose full names differ only in case (Game.AI.MoveSystem and Game.Ai.MoveSystem), or a generic system next to a class named like its hint (Gen<T> and Gen_T_), no longer make the generator fail. Roslyn compares hint names without case; the generator threw, the compilation got only the warning CS8785, and no system of the assembly had a generated Init, so all their injected fields stayed null. Such names now get a numeric segment (Game.Ai.MoveSystem.2.Injection.g.cs), chosen by the names, not by file order.
  • Keywords used as identifiers (namespace Game.@event, class @class, a field @event, a type parameter @in) are escaped in the generated file; a keyword in a namespace or type name put @ into the hint name and made the generator fail the same way (CS8785). A [Shared] key is written as an escaped string literal, so one with a line break or another control character compiles.
  • No more CS0108, CS0109 or CS0505 in generated code over unrelated base members: a generated Init is declared new exactly when it hides an accessible inherited member (also a static Init(World, SharedData) or a non-method member named Init, which got no new before; not an Init with in parameters or an inaccessible one such as private protected in another assembly, which got a needless new), and a member named Init that is not a method on a class between two chained systems is KECS006 instead of CS0505 in the generated file.
  • KECS012 says that the generated Init calls base.Init before OnInit (it said "first").
  • Plugins/KenseiECS.Generators.dll is rebuilt; the packaged-DLL test covers the virtual Init, the new field order, KECS006 for the 2.1 layout without base.Init (also over a sealed override in between), for an override in between over an explicit base Init and for an overload above the chained override, KECS013, a base OnInit hook (also one that no base Init calls), an explicit IInitSystem.Init that calls the public Init, and hint names that differ only in case.

Editor ​

  • Profiler window: the selected event stays selected while recording goes on. Once the ring buffer was full, every new event moved the others down and the selection (a position in the list) slid to other events, so the call-stack panel changed with every snapshot. An event that leaves the buffer is now deselected.
  • Profiler window: the Entity column no longer shows v0 for component events, which record no generation; it is taken from the slot's Created or Destroyed events in the buffer, and without one the cell shows the index alone (E(5)). The debug name is shown only for the event's own entity: once a slot was reused, older events of that index showed the name of the entity living there now.
  • Profiler window: Next > is disabled on the last page, a new search starts at the first page, and the page is pulled back when the events are cleared from code or MaxEvents shrinks; the list could be paged past its end and stay empty.
  • World Inspector and Systems windows skip a provider that still returns a destroyed world (or a runner of one). The window dropped it on the next update and could find it first again on every later bind, so the live world or runner of a second provider was never shown.
  • World Inspector (Entities, Filters and Pools tabs) and the EcsEntityView inspector name generic component types with their arguments (EventBuffer<Hit>, Listeners<IHealthView>) instead of Type.Name (EventBuffer`1 for every buffer), and the entity search matches the arguments. Profiler events keep Type.Name in ComponentType.

Documentation ​

  • README, site home page and introduction: what a throwing listener or system restores (entity slots, runner and buffer state) and that only a throw inside DestroyEntity or a snapshot Load can leave components behind, which Clear() recovers; they said the world is never left inconsistent.
  • CommandBuffer page and CommandBuffer.Set: the read-modify-write of an EventBuffer<T> is not a way to defer events; use world.AddEvent, or keep the values and add them after Playback.
  • One-frame guide and EventBuffer<T>: copies share the entity's list and are stale once the component is removed; what storing a stale copy does now; Values is null in a buffer added without events; pool.Get(e).Add(v) on such a buffer is not checked, use world.AddEvent; Prewarm takes up to O(lists × free lists).
  • World config and World.Reserve: what Reserve(entities) costs (about 4 bytes × entities per pool and 4 KB per 1024 entities per filter, also for pools and filters created later; about 200 MB for 1000 types at 50,000 entities, 236 MB with 150 filters) and what to do for such worlds until there is an API for it; exact sizes; a failed Reserve; a Reserve that grows a pool or filter invalidates refs, RawData/RawEntities and Filter.Entities spans like any growth. The InitialEntityCapacity row no longer claims to size filter sparse arrays.
  • Migration guide and components page: everything that invalidates a ref (a Reserve that grows the pool included), and why a ref that survives another entity's Del in Lite does not here.
  • Component listeners: a listener may remove components of its own pool from OnRemoved (its own entity's or a linked one's), every listener gets one OnRemoved per component and cycles end; a component removed and added again is a new one; Warmup continues on a new temporary entity when a listener destroys it; what OnRemoved sees during DestroyEntity, a Clear there, and an OnAdded that destroys an entity CreateEntity, CopyEntity or Spawn is still building.
  • World lifecycle, world events and architecture: Warmup when a listener destroys its entity, the world event order when a filter listener takes a component away or adds it back, OnEntityCreated for an entity destroyed while it was made, Has during DestroyEntity, Clear from a listener, hook frames, the add/remove hook flags, the per-type count of listened filters, list ownership, debug handle validation, Destroy releasing groups.
  • Runner page: what the rollback of a failed Init destroys (completed Inits only; systems without IInitSystem are left for Destroy()), the flat AggregateException, a runner registered only once, the names EcsBootstrap reserves, and which registration a name reaches in release when two share it: the page said the second always replaced the first, but a system or group and a phase split the name (SetActive, IsActive and IndexOf reach the system or group in either order, GetRunner the phase), which is what happens with "fixed" and "late" in EcsBootstrap's update runner; the bootstrap page says so too. Bootstrap page: the reserved names "fixed" and "late" in debug and release, the per-runner guards of Update/FixedUpdate/LateUpdate, and not registering fixedUpdate/lateUpdate in another runner. Systems page, migration guide, architecture and package README updated to match (when Init and Destroy are called, the rollback, one parent per runner, the bootstrap guards).
  • Source generator guide: the order (derived fields, base Init, derived OnInit), Init virtual unless sealed, a base with its own OnInit (who calls an override of the hook), an explicit IInitSystem.Init that calls the public Init, KECS006 for the 2.1 layout without base.Init, the warning KECS013 and upgrading from 2.2.0 and 2.2.1; FAQ, migration guide and architecture (generator section) updated to match.
  • Release vs. KENSEI_DEBUG checked against the code: Get of a missing component throws IndexOutOfRangeException on Mono and .NET and reads (or through the ref writes) outside the pool's arrays on IL2CPP; new rows for AddEvent/Subscribe/Unsubscribe with a stale handle, GetComponentTypes/GetComponentCount of a dead entity, a listener that keeps re-adding components to a dying entity (in release DestroyEntity never returns), a name registered twice in one runner, a runner registered twice, the names EcsBootstrap reserves, IsActive on a system without Run and World.Clear after Destroy; the runner rows say what release does, and the handle rows that debug validation accepts only the entity being destroyed. Which debug APIs exist in release builds and which need #if KENSEI_DEBUG, the sources the release check names, and that -p:KenseiDebug=true reaches a referenced KenseiECS.NET project.
  • Debug tools: the Systems window tags only phases as phase; the Pools tab's Size is Marshal.SizeOf (a bool field counts 4 bytes); the Profiler's Entity column, history per entity index, kept selection and paging; ProfileEvent.Generation is set for Created and Destroyed only; providers of a destroyed world are skipped.
  • Entity view: Spawn can be called again from a listener of the components it adds, and stops when such a listener destroys the entity. Entities page and FAQ: CopyEntity and CreateEntity return a dead handle, and send no OnEntityCreated, when a listener destroys the new entity.
  • Filters page and IFilterListener: a component that a listener adds to an entity being destroyed lets the dying entity (IsAlive false) enter filters until the destroy removes it; they said the entity is always alive on enter. World events and architecture: a world listener that a filter listener subscribes during a change gets its event, and a filter listener that removes the component and adds it back makes world listeners hear of two additions. Component listeners and architecture: which typed listeners the OnAdded dispatch takes. Entities page and FAQ: CopyEntity of a source without components left. One-frame guide and EventBuffer<T>: numbered rents. Runner page: Shared of nested runners, and when the debug SharedData check runs. World config, Filter.Reserve and World.Reserve: int.MaxValue. Source generator guide: KECS006 over overrides in between (and the chaining of a derived class that lists IInitSystem over them) and for overloads up to the first declaration, the 2.1 layout over a new Init that is not reported, and which injected fields of a base in another assembly KECS006 sees.
  • Benchmarks: one game-loop time for 2.0. The game-loop table, the performance tables of the README and the introduction and the comparison page showed 34 us from the first benchmark session, taken before the last filter change of 2.0 (479b6f0), while the 2.0-versus-1.0 table had 33 us measured after it; all say 33 us now, the benchmarks page says which numbers come from which session (the README and the introduction no longer say one session), and the game loop is 2.4x faster than Arch (was 2.3x, also on the home page).

[2.2.1] - 2026-10-23 ​

Added ​

  • World.FirstGrowthAfterReserve (a StorageGrowth): under KENSEI_DEBUG the first growth counted by GrowthsAfterReserve — owner (component type, filter description or World), array, old, new and reserved sizes and the tick — so the storage that outgrew the reserve can be found without recording the world in EcsProfiler. Later growths do not replace it; Clear resets neither it nor the count. Empty (IsEmpty) without the define.

Fixed ​

  • Content builds with Debug Mode on work again. In 2.2.0 the release check was a #error in the runtime assembly, and Addressables, the Scriptable Build Pipeline and legacy AssetBundles compile the player scripts without DEVELOPMENT_BUILD, so every content build failed while KENSEI_DEBUG was set — with Addressables' default settings even a Development player build (its content step). The runtime assembly now compiles a marker type instead, and a new editor check after the player scripts compile (IPostBuildPlayerScriptDLLs, which Unity calls for player builds only) fails a non-development player whose KenseiECS.dll has it, naming where the define came from: BuildPlayerOptions.extraScriptingDefines, Player Settings -> Additional Compiler Arguments (-define:, which 2.2.0 did not mention) or Assets/csc.rsp. A development build is recognised by the build options, as in the preprocess guard, rather than by the DEVELOPMENT_BUILD define, which Unity 6.6 deprecates (its UAC0009 warning from this file is gone, and a release build with a hand-written DEVELOPMENT_BUILD no longer slips through). The check adds a short step to every player build. The preprocess guard for the Scripting Define Symbols of the Build Profile and Player Settings is unchanged.
  • In release, a CreateEntity on a destroyed world claimed an entity slot before failing with NullReferenceException, after which IsAlive and DestroyEntity threw too instead of returning false and doing nothing. The slot is now claimed only once it exists.
  • World.Clear after World.Destroy throws ObjectDisposedException in every build, like Reserve and filter creation; it failed with ArgumentNullException.
  • Under KENSEI_DEBUG a pool built its type name on its first growth even when nothing was reserved (one string per pool, about 30 extra allocations in a measured game battle, absent in 2.1.1). The name is now built only for a growth that Reserve watches.
  • StorageGrown profiler events for filters name the filter (Filter Inc<Position, Velocity> filter dense 128 -> 256 (reserved 128)) instead of the bare word Filter.
  • The [Obsolete] message of SystemsRunner.Add(SystemsRunner, string) now says that only a named call creates a phase; with null it adds an unnamed inline group, as documented.

Documentation ​

  • AddGroup (and an unnamed Add(runner)) starts the group's slot as the group is: a group switched off with SetActive(false) before registration starts disabled.
  • World config: a filter does not create its pools, so a pool first used during play allocates there even after Reserve(n, n); the cost of components for every pool, with a measured example, next to reserving only the hot pools.
  • Debug tools: the sources of KENSEI_DEBUG each check reads; the CI check before BuildPlayer does not read Additional Compiler Arguments or Assets/csc.rsp, and the check after the player scripts compile catches those. Content builds are not checked.

[2.2.0] - 2026-10-22 ​

Added ​

  • EventBuffer<T>.Prewarm(lists, capacity) fills the static list pool up front: the next lists lists the pool hands out get Capacity of at least capacity. Free lists already that large are used first, then the largest remaining ones are grown (at most lists of them, so a pool left large by an earlier peak is not inflated), and new lists are created only when fewer than lists are free; the prepared lists are moved to the top of the pool. A repeated call with the same arguments does nothing. The pool is static per T and shared by every world in the process; World.Warmup still does not fill it, and neither does Prewarm size the world (use World.Reserve).
  • World.Reserve(entities, components = 0) grows storage ahead of time in one call: entity storage (generations, masks, free-slot list) and the sparse side of every pool and filter for entities, and the dense arrays of every pool (entities, data, change versions) and filter for components. Both apply to existing pools and filters and to those created later in the world. After Reserve(n, n), creating and destroying n entities with components that enter filters allocates nothing; creating a pool or filter still allocates the object (and, in a new 64-type block, a mask word). components costs that many slots of every component type, singletons included; ComponentPool<T>.Reserve(count) (dense, data, change-version and sparse arrays) and Filter.Reserve(count) (dense array, safe during iteration) size one pool or filter. Nothing shrinks. On a destroyed world Reserve throws ObjectDisposedException.
  • World.GrowthsAfterReserve: under KENSEI_DEBUG it counts every growth past what Reserve reserved (entity slots, free-slot list, pool sparse arrays and filter pages past entities; pool and filter dense arrays past components; a dimension left at 0 is not watched), and while EcsProfiler records the world each such growth is a ProfileEventType.StorageGrown event naming the array and its sizes (Profiler window: Grow filter). Its EntityIndex is -1. The window's search (ProfileEvent.MatchesSearch) treats a query of digits as an entity index and matches it only against events that have an entity, so typing 1 no longer lists every growth ("-1", "64 -> 128"); growth events are found by text (dense, a type name) or the Grow filter. Always 0 without the define; release builds check nothing.
  • Listeners<T>.Invoke(call, onError) and Invoke<TArg>(arg, call, onError) call the listeners from a snapshot of the list in subscription order (first subscribed, first called; hand-written loops over Values usually went from the end). A listener removed from the list during the dispatch before its turn is skipped (a view destroyed with Object.Destroy stays subscribed until its OnDestroy at the end of the frame, so it is still called); listeners added during the dispatch are not called; each snapshot entry is called at most once. "Still subscribed" uses Equals like Remove, so a struct listener removed and added again counts as subscribed; a listener added several times is matched by value, not per copy. On an unchanged list the check is one reference comparison per listener; after a change the search widens from the previous listener's position in both directions, so a listener unsubscribing itself or a callback inserting listeners before the current one does not make the rest of the dispatch quadratic. If onError itself throws, the dispatch stops and that exception propagates. The snapshot is rented from ArrayPool<T>.Shared and cleared and returned in finally; nested calls work. Without onError an exception propagates; with it the error is reported per listener and the call continues. In the TArg overload onError is Action<T, TArg, Exception> and receives the argument too, so static lambdas for both call and onError allocate nothing.
  • SystemsRunner.AddPhase(name, runner) registers a separate phase (same as the now obsolete Add(runner, name)); AddGroup(name, runner) registers a named inline group that runs inside the parent's Run, is reachable through SetActive(name), IsActive(name), IndexOf(name) and GetRunner(name), and gives its name to its ProfilerMarker and SystemInfo.Name.
  • SystemsRunner.IndexOf(ISystem) (by reference) and IndexOf(string) return the registration position used by GetSystemInfo/SetActive(int), or -1. They find any registered system, Init/Destroy-only ones included, which SetActive cannot toggle (GetSystemInfo(i).IsRunnable is false). For a run system, group or phase IndexOf(string) resolves an explicit registration name exactly like SetActive(string)/IsActive(string) and falls back to the first unnamed system with that type name only when no system was registered under the name. Nested runners are not searched.
  • SystemsRunner.SetActive(bool) toggles a runner through a reference to it: on an inline group (named or not) it switches the group's slot in the parent together with its IsEnabled, like the parent's SetActive(name); on a phase or a root runner it sets the runner's own IsEnabled (a disabled root's Run still advances the tick but runs no systems).
  • SystemsRunner.OneFrame<T>(cleanWhenDisabled): with true the type is also removed in frames where the runner is skipped, at the slot of a disabled inline group (recursively into its inline groups) or in Run() of a disabled phase. Systems and DelHere of the skipped runner still do not run. OneFrame<T>() keeps the old behaviour. A runner tree without cleanWhenDisabled types passes disabled slots at the 2.1 cost.

Changed ​

  • Behaviour change: a SystemsRunner.Init that throws now rolls back. Destroy is called on every IDestroySystem registered before the failing system, in reverse order (a nested runner that fails rolls itself back first), the progress is reset and the original exception is rethrown; if rollback Destroy calls throw too, the rollback still completes (also inside nested runners registered before the failing system: each of their systems is destroyed even when another one throws) and an AggregateException holds the original exception followed by the rollback errors. The next Init starts from the first system. Up to 2.1.x the systems before the failing one were left initialized and the next Init resumed with the failing system. Destroy() after a failed Init does nothing.
  • Behaviour change: SetActive(index|name) on an inline group (named or unnamed) switches both the parent's slot and the group's own IsEnabled; up to 2.1.x the unnamed child's IsEnabled stayed true. GetSystemInfo and IsActive agree with it. A direct Run() of such a group while its slot is off now runs nothing (it only removes OneFrame types registered with cleanWhenDisabled); in 2.1.x it ran the group's systems.
  • Under KENSEI_DEBUG SetActive(int), SetActive(string) and IsActive(string) on a system without Run (Init/Destroy only) throw InvalidOperationException saying so; SetActive(int) used to do nothing, and by name the error claimed that nothing was registered under the name. Release builds still ignore it. Names stay case-sensitive and an unknown name stays silent in release; both are now spelled out in the XML docs and on the runner page.
  • World.Filter after World.Destroy throws ObjectDisposedException, and under KENSEI_DEBUG so do CreateEntity and Pool<T>, instead of a NullReferenceException.
  • Under KENSEI_DEBUG registering a name that is already used in the same runner (system, group or phase) throws InvalidOperationException; before, the later registration silently replaced the earlier one in the name lookup. AddPhase/AddGroup throw for a null runner or an empty name in every build.
  • EcsBootstrap registers its fixed and late phases with AddPhase instead of the now obsolete Add(runner, name); the phases and their names are unchanged.

Deprecated ​

  • SystemsRunner.Add(SystemsRunner runner, string name) is a new overload marked [Obsolete] (a warning) with the 2.1 behaviour: a named runner passed to Add is a separate phase, which next to AddGroup(name, runner) reads like a group whose systems then never run. Use AddPhase(name, runner) for a phase or AddGroup(name, runner) for an inline group. Add(runner) without a name, Add(system, name) for other systems and a runner passed as an ISystem do not warn.

Generator ​

  • Behaviour change: a derived system with injected fields whose base can be chained (a generated base in the same compilation, or a hand-written base with a public virtual or abstract Init) always gets a generated Init that overrides the base one and calls base.Init(world, shared) first (none for an abstract base Init). A base.Init written in the class itself is now the new error KECS012 ("generated Init already calls base.Init first; remove the call from OnInit"): the 2.1 layout, where the derived class re-implements IInitSystem and calls base.Init from OnInit, is no longer kept for such classes. To upgrade, delete the base.Init(...) line; the base still runs first. The check is syntactic: any base.Init member access in the class's own parts counts, whatever overload it binds to (rename a hand-written base helper named Init); one inside a nested type does not. A class that lists IInitSystem itself over such a base without calling base.Init is chained too, so that base Init now runs (on 2.1 it was skipped). Over a base Init that cannot be overridden (not virtual, sealed, not public, explicit), a class that lists IInitSystem itself keeps the 2.1 layout as before.
  • Systems with injected fields can derive from a partial system with injected fields in the same compilation, or from a base with a public virtual Init. The base's generated Init becomes public virtual, the derived one a public override that calls base.Init: base fields, base OnInit, then derived fields and OnInit. Works over several levels, through intermediate classes without fields and with generic bases. A hand-written subclass that overrides Init (directly or through hand-written intermediate classes that override it and call base.Init) also makes the generated base Init virtual, so such a chain compiles instead of failing with CS0506. Systems without inheritance get the same .g.cs as before. Where the generated Init hides an inherited one, it is declared new (no more CS0108/CS0114 in generated code).
  • KECS006 is now reported only where inheritance cannot work: a base Init that is not virtual, sealed, not public or explicit (unless the class lists IInitSystem itself, see above), an intermediate class that hides Init, an intermediate hand-written class with another Init overload that the generated base.Init(world, shared) would bind to instead of the chained base Init (for example Init(World, object), Init(World, SharedData, int x = 0), a generic or params overload; rename it), or a base from another assembly whose Init is not virtual. The message names the reason. A derived class of a base that failed with its own error (for example KECS001) gets no second error.
  • Plugins/KenseiECS.Generators.dll is rebuilt; the packaged-DLL test covers the inheritance case and KECS012.

Editor ​

  • Behaviour change: the Debug Mode toggle writes KENSEI_DEBUG to the active Build Profile's scripting defines on Unity 6 when a profile is active, otherwise to the Player Settings of the current build target only (2.1.x wrote every target). The checkbox shows whether the define is in effect for the active profile or target; turning it off removes it from both the profile and the current target's Player Settings, so a define written to all targets by 2.1.x does not keep the mode on. Other targets are not changed; if their Player Settings still have the define, a warning lists them. Each write to a Build Profile asset (shared, usually under version control) is logged with its name and path.
  • Behaviour change: a new build guard (IPreprocessBuildWithReport) fails a non-development player build whose defines (active profile plus Player Settings of the built target) contain KENSEI_DEBUG. The error names where the define comes from (the profile's name and asset path and/or the Player Settings target). Define KENSEI_ALLOW_DEBUG_RELEASE to allow it. Defines the guard cannot see (BuildPlayerOptions.extraScriptingDefines, csc.rsp) are caught by a #error in the runtime assembly when a release player is compiled with KENSEI_DEBUG; an allow define passed only that way satisfies the #error but not the guard. The guard runs early (callbackOrder -1000) but does not stop other preprocessors: Unity still calls those ordered after it, so their asset changes can remain after the failed build; build scripts should check the defines before BuildPlayer. BuildPlayer(BuildPlayerWithProfileOptions) makes the profile active before the build, so its defines are checked (and it stays active afterwards). A profile with its own Player Settings ("Customize player settings") makes Unity read and write that copy while it is active: turning Debug Mode off then edits the profile asset and logs it, and the guard error and the other-targets warning say that the Player Settings are the copy in the profile (the warning also notes that the project's ProjectSettings.asset was not checked). With the Dedicated Server subtarget active, the toggle and the guard use the Server define slot on every supported Unity version (2021.3+).

Documentation ​

  • One-frame guide: prewarming the list pool, the static shared pool, cleanWhenDisabled for paused runners.
  • Runner page: phase / named group / unnamed group, AddPhase/AddGroup, IndexOf, IsEnabled of inline groups, the Init rollback contract; architecture, migration guide and bootstrap page updated to match.
  • World config and lifecycle pages: Reserve with components, GrowthsAfterReserve, use after Destroy. Listener bridge: Invoke order, skipping of unsubscribed listeners (and why a view destroyed with Object.Destroy is still called in the same dispatch), matching by Equals, duplicates and a throwing onError. One-frame guide and migration guide: Prewarm does not size the world; a warmup that created entities needs World.Reserve as well. Runner page: case-sensitive names, silent unknown names in release, SetActive(bool), the obsolete Add(runner, name). Architecture: why Listeners<T> lists are not pooled (a copy written back after a remove would share a pooled list between entities).
  • Source generator guide: inheritance, the new KECS006 cases, KECS012 and upgrading from 2.1; FAQ, architecture and migration guide updated.
  • Debug tools, debug mode, installation and FAQ: where the toggle writes the define and the release build guard; the profile is a shared asset (Unity may leave m_HasScriptingDefines changed after off/on), the warning about other targets, profiles with their own Player Settings, and a pre-BuildPlayer check for CI (it activates the profile before reading PlayerSettings).
  • World.Warmup/SystemsRunner.Warmup XML docs and the package README: typed and filter listeners see Warmup's temporary entity.

[2.1.1] - 2026-10-22 ​

Fixed ​

  • A typed listener that removes the same component again from OnRemoved (for example by destroying its own entity) corrupted the pool: the outer Remove swap-removed a slot that was already gone. The nested Remove now continues the notification from the next listener and does the removal, the outer one sees the component gone and stops; every listener gets one OnRemoved. Works with change tracking and owning groups.
  • World.Add and pool.Add returned a ref to a stale slot when a filter, world or typed listener added or removed the same type elsewhere, or removed the just-added component: writes through it landed on another entity. The dense index is re-read before each typed OnAdded and before returning; a component removed before Add returns gets no further OnAdded, and the ref points at a scratch value whose writes are discarded.
  • CopyEntity shared one List between the source and the copy for EventBuffer<T> and Listeners<T>; after the next OneFrame cleanup the pool could hand that list to two entities. Both now implement IAutoCopy<T> and give the copy its own list.
  • ParallelRunner: after a job threw, the chunk counter jump made chunk * chunkSize overflow, so chunks ran again or with a negative start (Execute(-1024, 0)). The start index is computed in long.
  • world.AddEvent on a stale handle appended to the new occupant's buffer under KENSEI_DEBUG; it now throws like the other entity operations.
  • An IFilterListener.OnEntityRemoved that added the removed component back left the entity out of the remaining Inc filters of that type.
  • World.Warmup left its temporary entity alive, and world events suppressed, when a listener threw; both are now restored in finally.
  • World.Destroy called twice threw; the second call is a no-op.
  • CommandBuffer.Set on an existing component and a CopyEntity that overwrites a component (one a listener added during the copy) were invisible to change tracking; both now write through Modify. Set still does not run AutoReset on the old value, so writing back a modified copy (var b = world.Get<EventBuffer<Hit>>(e); b.Add(h); cb.Set(e, b);) keeps its list. CopyEntity runs AutoReset on the overwritten value for types with IAutoCopy, whose copied value owns its references.

Performance ​

  • Under KENSEI_DEBUG, pool Add/Remove call EcsProfiler only while it is enabled, and the component type name is cached per pool; before, every structural change evaluated typeof(T).Name, which allocates on Mono and IL2CPP.
  • Remove tests the pool's _autoReset delegate instead of a static readonly bool, which IL2CPP does not fold and checks through class initialization on every call.

Generator ​

  • New errors for injection that compiled but left fields null at runtime or failed inside the generated file: KECS006 (a derived system where its own or the base Init would never run; deriving still works when the class lists IInitSystem among its bases if the base implements it, and calls base.Init from OnInit if the base has injected fields), KECS007 (no types in [Inc] and [Any]), KECS008 (a non-component type in a filter attribute), KECS009 (readonly injected field), KECS010 (record or struct system), KECS011 (system nested in a record or interface).
  • KECS002 also covers an explicit void IInitSystem.Init(...); KECS003 also covers [Shared] on a value type, which failed with CS0452 in the generated file.
  • No false KECS003 on nullable-annotated fields (Filter?, ComponentPool<T>?) in a #nullable enable context.
  • Plugins/KenseiECS.Generators.dll is rebuilt from these sources. The test that loads it now uses a separate load context (it used to get the generator project's own assembly) and checks a 2.1.1 diagnostic, so a stale DLL fails the tests.

Editor ​

  • Systems window repaints at most about 10 times per second instead of on every editor update.
  • Profiler window caches the event snapshot (refreshed at most twice a second while recording, on enable/disable, after Clear and on entering Play Mode) instead of copying the buffer on every OnGUI, and keeps showing recorded events after the world is destroyed or recording stops.
  • World Inspector counts components only for entities on the shown page (or for search matching), disables Next when no further match exists, and clamps the page when entities die.

Documentation ​

  • Generator diagnostics table, FAQ and migration guide list KECS006-KECS011 and the new KECS002/KECS003 cases.
  • ref lifetime from Get/Add: any Add or Remove of the type on any entity invalidates it, and in an owning group any of the group's types does (components, groups, FAQ, architecture, XML docs).
  • EventBuffer<T> allocates nothing only once its static, process-wide list pool has reached the peak; World.Warmup does not fill it.
  • A disabled runner (or an unnamed child disabled through the parent's SetActive(int, bool)) does not clean its OneFrame/DelHere types; the unnamed child's own IsEnabled stays true.
  • World.Warmup is visible to pool and filter listeners subscribed in Init.
  • EcsEntityView/SetName without KENSEI_DEBUG: the call is an empty method, not compiled out.
  • Benchmarks: measured on .NET 8 x64 only (no Mono, IL2CPP or ARM), the .NET build uses BitOperations while Unity uses the De Bruijn fallback, no EventBuffer/OneFrame scenarios, and "0 B" holds after capacities reach their peak.
  • CommandBuffer.Set and change tracking pages describe the overwrite; CopyEntity overwrite and AutoReset are described under IAutoCopy.

[2.1.0] - 2026-10-08 ​

Added ​

  • Documentation site at https://kenseitheone.github.io/KenseiECS/: getting started, core concepts, feature guides, Unity integration, architecture, FAQ, migration from LeoEcsLite, benchmarks and changelog. package.json documentationUrl points to it.
  • API reference on the site, generated from the XML doc comments of the public .NET API.
  • Comparison page: KenseiECS against Arch, Friflo.Engine.ECS, Unity Entities, LeoEcsLite and DefaultEcs, including where the others are the better choice.
  • XML doc comments for every public type and member of the .NET API (117 had none: the Inc/Exc/Any filter specs, Group<T1..T4> data arrays, enumerators, constructors, system and listener interfaces, attribute properties). A public member without one (CS1591) now fails the build.
  • Live demo "Horde": a survivors-like game on KenseiECS running in the browser on .NET WebAssembly, with an ECS inspector (per-system timings, system toggles, filter and pool sizes, stress mode) and touch controls; "Inside the Demo" walks through its systems.

Changed ​

  • Every C# sample in the documentation that does not need UnityEngine (plus the FAQ and migration samples, Unity-related ones against stubs) and the C# blocks of both READMEs is compiled from projects in docs/snippets/ (the LeoEcsLite side of the migration guide against the Leopotam.EcsLite 1.0.1 NuGet repack, which is unofficial but has the same API as the official repository) and checked in CI in release and KENSEI_DEBUG.
  • The root README is now a short landing page that links to the site; the installation guide covers building from source for .NET.
  • World.SetName is no longer [Conditional("KENSEI_DEBUG")]. Without the define it is an empty method and its arguments are evaluated; before, the compiler dropped the call together with its arguments, so world.SetName(world.CreateEntity(...), "Player") created no entity when the define was off - in practice, in release builds and in any test run without it. On .NET the name now depends on how KenseiECS itself is built rather than on the calling assembly, so assemblies compiled against 2.0.x need a rebuild to see names. A name built at the call site ($"Enemy {i}") is now built in release too; wrap such a call in #if KENSEI_DEBUG if that allocation matters.

Fixed ​

  • README Quick Start: wrong call order and a missing using; other README samples had duplicate locals, an EcsProfiler call not guarded by #if KENSEI_DEBUG and a double CommandBuffer.Add.
  • Migration guide and FAQ samples that did not compile or threw at runtime: a duplicate Add in the deferred-changes loop (now Set on the KenseiECS side and a Has-guarded Add on the LeoEcsLite side, each followed by break), a doubly declared variable, out-of-scope variables, statements mixed with declarations.
  • XML documentation of 21 public types and members (among them SystemsRunner, SharedData, CommandBuffer, Group, EventBuffer<T>, WorldSerializer and the [Inc]/[Pool]/[Group]/[Shared] attributes) was dropped from KenseiECS.xml as badly formed XML, so IDEs showed no summaries for them. The comments are escaped now, and a badly formed doc comment (CS1570) fails the build.
  • Performance tables in the README, introduction and BENCHMARKS.md bolded KenseiECS's owning group (5.5 us) as the fastest two-component iteration; Arch (5.4 us) is.

[2.0.0] - 2026-09-02 ​

Breaking ​

  • IComponentPool replaced by the abstract class ComponentPoolBase. Clear, AddDefault and CopyTo are now internal; user code can no longer desynchronize masks and filters by calling them.
  • World.GetEntity(int) on a dead slot returns the dead entity's own handle (IsAlive is false) instead of throwing under KENSEI_DEBUG. A slot's generation now changes when the slot is reused, not when it is freed.
  • IWorldEventListener.OnEntityCreated fires after the first component is added (CreateEntity) or after all components are copied (CopyEntity). Listeners never observe an entity without components.
  • World.Unsubscribe<T> keeps the empty Listeners<T> component; unsubscribing the last listener no longer auto-destroys the entity. HasListeners<T> is false for an empty list.
  • World.Remove<T> no longer creates the pool for a type that was never added.
  • SystemsRunner.Destroy runs IDestroySystem.Destroy in reverse registration order, is a no-op before Init, and resets the runner so Init can run again.
  • Listeners<T> and WorldListenerExtensions moved from Unity/ to Core/ and no longer depend on Unity.
  • The .NET project file moved from KenseiECS/KenseiECS.csproj to KenseiECS.NET/KenseiECS.csproj; the KenseiECS/ folder is now a UPM package.

Added ​

  • FilterBuilder.Any<T>(): match entities with at least one of the listed types. Any and Exc of the same type is rejected; Any of an Inc type is dropped as redundant.
  • world.Filter<Inc<A, B>, Exc<C>, Any<D, E>>() static filter specs (Inc 1-6 types, Exc 1-4, Any 2-4, None).
  • Filter.IsEmpty, First(), TryGetFirst, Single(), Entities span, AddListener(IFilterListener) for enter/leave notifications.
  • ComponentPool<T>.AddListener(IComponentListener<T>): OnAdded after filters update, OnRemoved before AutoReset.
  • CommandBuffer: deferred CreateEntity/Add/Set/Remove/DestroyEntity with PendingEntity handles, typed payload storage, zero allocations after warmup; commands on dead entities are skipped.
  • World.GetSingleton<T>(), GetSingletonEntity<T>(), HasSingleton<T>().
  • EventBuffer<T> component and world.AddEvent(entity, value) for several events per entity per frame; lists are pooled.
  • KENSEI_DEBUG: removing an entity from a filter that is being iterated throws when the swap-remove would make the loop visit an entity twice (nested loops tracked per enumerator).
  • KenseiECS.NET multi-targets netstandard2.1 and net8.0; the .NET build uses BitOperations.
  • SystemsRunner.GetSystemInfo(int), SystemCount, SetActive(int, bool), IsEnabled, World: introspection for tooling. Every run system gets a ProfilerMarker on Unity; LastRunMs/PeakRunMs and ResetTimings() under KENSEI_DEBUG.
  • World.FilterCount/GetFilter(int); Filter.IncludedTypes/ExcludedTypes/AnyTypes, ToString(), DenseCapacity, AllocatedBytes; ComponentPoolBase.SparseCapacity, DenseCapacity, ComponentSize, AllocatedBytes.
  • World.SetName(Entity, string) / GetName(Entity) debug entity names (SetName compiles out without KENSEI_DEBUG).
  • Filter sparse arrays are paged (1024 slots per page, allocated on first touch); a filter no longer costs an int per entity slot of the world.
  • Owning groups: world.Group<T1, T2>() (up to four types) keeps the owned pools' dense arrays aligned so members can be iterated through Data1..DataN spans with no sparse lookups. A pool belongs to at most one group. World.GroupCount/GetGroup.
  • Change tracking: pool.TrackChanges(), Modify(e), MarkChanged(e), ChangedVersion(e), ChangedSince(e, version) with World.ChangeVersion as the consumer's bookmark.
  • WorldSerializer: Save(world, stream) / Load(world, stream) snapshots that keep entity indices and generations (so Entity fields inside components stay valid), identify types by name, write unmanaged components bit-for-bit and use IComponentFormatter<T> for components with references.
  • Source generator (KenseiECS.Generators, shipped as Plugins/KenseiECS.Generators.dll): [Inc], [Exc], [Any], [Pool], [Group], [Shared] on fields of a partial system class generate Init and call partial void OnInit(World, SharedData). Diagnostics KECS001-KECS005 for misuse.
  • World.TryGetEntity(int, out Entity).
  • ParallelRunner and IRangeJob: struct jobs over an index range (filter Entities or group Data spans) on fixed worker threads plus the caller, dynamic chunking, no allocations per Run, worker exceptions rethrown on the caller.
  • Unity: EcsBootstrap base MonoBehaviour (World, SharedData, update/fixed/late runners, warmup), IEcsSystemsProvider, EcsComponentProvider<T> inspector-authored components, EcsEntityView.Spawn(world) and EntityName, KenseiECS -> Systems window with enable toggles and timings, Filters and Pools tabs in the World Inspector, debug names in inspector and profiler, Samples~/BasicGame.
  • UPM package: package.json, KenseiECS and KenseiECS.Editor assembly definitions, committed .meta files. Install via git URL with ?path=/KenseiECS.
  • ComponentType.TypeOf(int) and ComponentType.NameOf(int) resolve the typeIndex passed to world event listeners.
  • World.GetComponentTypes(Entity, List<int>), World.GetComponentCount(Entity), World.GetPool(int).
  • ComponentPoolBase.ComponentType.
  • SystemsRunner.DelHere<T>() removes all T at that point of the pipeline; SystemsRunner.IsInitialized, SystemsRunner.Shared.
  • SystemsRunner.SetActive/IsActive work on named child runners.
  • Listeners<T>.Count.
  • IAutoReset<T> and IAutoCopy<T> may be implemented explicitly.
  • KENSEI_DEBUG validation: pool Add on a dead or never-allocated slot, Run before Init, Add after Init, unknown names in SetActive/IsActive/GetRunner, GetComponentTypes on a dead entity.
  • GitHub Actions workflow running the test suite in both configurations.

Fixed ​

  • An exception thrown by a world event listener or AutoReset during DestroyEntity left a permanent zombie (dead flag set, components and filter membership intact, slot never freed). The slot is now always released and components are drained in finally.
  • An exception in SystemsRunner.Init marked the runner initialized and skipped the remaining systems forever; Init now resumes at the failed system.
  • An exception in a system skipped OneFrame cleanup, so events were processed twice; cleanup now runs in finally.
  • Warmup fired world events and profiler records for its temporary entity.
  • Removing a world event listener with a lower index from inside a dispatch invoked the current listener twice; the listener list is now copy-on-write.
  • A child SystemsRunner constructed without SharedData got an empty container instead of the parent's.
  • The World Inspector and EcsEntityView inspector lost edits made to nested structs and array elements.
  • KenseiECS -> Debug Mode applied KENSEI_DEBUG only to the current build target group.
  • EcsProfiler kept a static reference to a destroyed world and survived Enter Play Mode without domain reload.
  • Il2CppSetOption did not apply to Filter.Enumerator (nested types do not inherit it), so the hottest loop kept bounds checks under IL2CPP.
  • ComponentPool.Clear and World.Clear were O(entity capacity) per pool; sparse entries are now reset through the dense list.

Changed ​

  • Per-type filter lists are split into include/exclude/any, so adding or removing a component tests the mask only for filters it can move the entity into.

[1.0.0] - 2026-03-28 ​

Initial release.