Skip to content

UniNet v0.23.0

Choose a tag to compare

@github-actions github-actions released this 29 Oct 08:10
· 3 commits to main since this release

Stabilization release — FR-01..07 plus audit hardening (generator 0.2.19; wire formats unchanged, default handshake version bumps as usual).

Added

  • Game-RPC send gate (FR-01) — broadcast [ClientRpc], the To/ToOwner companions, and [MulticastRpc] network sends now go only to connections that are approved and not scene-held (ServerConnection.CanReceiveGameData: !Disconnected && VersionApproved && !AwaitingSceneReady). Calls before approval or during a scene transition are dropped immediately — no queue, no replay. The system handshake (Welcome etc.), multicast local execution, and approved connections that never changed scenes are unaffected.
  • Periodic in-motion baseline (FR-02) — an Unreliable-delivery sub-object that keeps producing deltas now re-sends its full state on the reliable batch every 1.0 s (UnreliableBaselineIntervalSeconds), so a lost delta converges to the latest authoritative state within one interval even while other fields keep changing (collections re-baseline wholesale — a tag-1 full, never an op replay). Idle subs are still healed once by the existing 0.25 s quiescence resend; batching/budget contracts unchanged.
  • AOI re-entry refresh (FR-04) — re-entering a dynamic object's relevance no longer silently ignores the re-sent spawn baseline when the client still holds the instance: transform + per-slot full state are refreshed in place (no re-instantiation, SubId slots and typeKeys verification kept, RepNotify raised like the first spawn). Host duplicates keep the server originals untouched.
  • State-only ack reconciliation (FR-05) — INetworkMoveSimulation.ReconcileState(…): when an ack's predicted position already matches, the state snapshot recorded for that sequence is byte-compared against the server echo and, on divergence only, restored and re-simulated with Rollback's exact replay semantics. An agreeing ack costs one comparison (no replay). Default interface method — custom INetworkMoveSimulation implementations keep the legacy discard-only behavior. Wire fields, death gate, ownership epoch, teleport re-anchor unchanged. Note: the comparison is exact on WriteState bytes, so a lossy (quantized) state codec can encode distinct states identically — sub-wire-precision divergence is skipped (the same limit the rollback restore has).
  • Finite semantic-preserving backlog + explicit overflow (FR-06) — deferred replication entries coalesce per (NetId, SubId) into the LATEST full state (senders may never interleave a stale-index op delta past a queued full — index continuity for collections is preserved end to end); the deferred queue is capped at MaxDeferredDeltas (1024) with overflow force-sent (DeferredForcedSendCount, counted on actual deliveries). The main-thread queue is capped (UniNetEnvironment.MainQueueCapacity, 65536); overflow drops are explicit (LogFault + DroppedMainActions). Client-side apply drops are observable via UniNetEnvironment.DroppedReplicateEntries. New counters: DeferredCoalescedCount, DeferredForcedSendCount, DroppedMainActions, DroppedReplicateEntries.
  • Headless generator regression host + CI gate (FR-07) — Tests/UniNet.CodeGenerator.Tests runs the real generator (source-built or the packaged analyzer DLL) through RunGeneratorsAndUpdateCompilation and executes the generated send/codec paths on the real Core runtime; wired as a required validate job step in CI alongside the generator build.

Fixed

  • Generator source build restored — a merge remnant in UniNetCodeGenerator.cs (CS1010/CS1002) made the generator source uncompilable; the shipped analyzer DLL was a stale artifact. The source pipeline is whole again and the packaged DLL is rebuilt from it (0.2.18).

  • RPC collection codec (FR-03) — receiving a List<T> RPC argument pre-allocated capacity instead of adding elements (empty list + every following argument corrupted); arrays/collections longer than 65,535 elements now throw ArgumentException before serialization instead of wrapping the UInt16 count; a fully-decoded but misaligned payload (trailing bytes) never reaches the game implementation. Wire format unchanged for existing payloads.

  • Parser crash on unsupported RPC args — an unsupported parameter (e.g. List<List<int>>) reported UNINET002 but kept emitting, crashing the generator (CS8785) and swallowing the diagnostic; it now reports and skips only that RPC (matching the Replicated-field path).

  • Malformed array receive hardening (generator 0.2.19) — the generated array receiver no longer pre-allocates from the wire's UInt16 count alone: a forged 12-byte header with count 65,535 used to allocate ~263 KB before failing. The count is rejected before allocation if it exceeds the remaining payload bytes (every supported element consumes at least one byte). Malformed lengths are never clamped into empty or shorter arrays: terminal-array and truncated-byte-array regressions assert that the implementation is not invoked. Wire format, null/empty/max-size receive unchanged. The headless regression host now dispatches a header-only forged 65,535-count frame (implementation not invoked, no count-sized allocation) plus array/null/empty/65,535 round-trips through the real generated handler.

  • RPC identifier hygiene (F13) — legal payload names such as netId, r, w, server, __n, and __i, plus escaped keywords, no longer collide with generated protocol fields or locals. Private wire helpers use ordinal aliases; public payload names and working named-argument calls are preserved. A To recipient parameter gains __ prefixes only if its usual connId name conflicts with a payload name. Method IDs and wire bytes are unchanged. Real compile, dispatch, targeting, and named-argument regressions cover all three RPC kinds.

  • verify-install.sh exit handling — set -e aborted the script on Unity's non-zero exit before the FAIL summary, the compiler-error scan, and the detailed-log path could run; the capture is now guarded (|| EXIT=$?). A hermetic regression (Tests/PackageTools/run-tests.sh) executes the real script's judgment block against a fake Unity — exit 23 → FAIL + log path + exit 1, exit 0 → PASS, exit 0 + error CS → FAIL, missing package trace → FAIL — and is wired into the CI validate job. No real Unity, clone, or network involved.

  • Arena PlayMode jump wait — the 1000-frame guard fired before the physically accurate 3 s simulation cap under batch-mode headless FPS (a pre-existing harness budget bug); raised to the file-wide 6000 convention.

  • Deferred merge cap bypass + partial-success wipe (F11) — when a deferred-entry merge was impossible (a faulted serializer view or an all-empty full rewrite), the fallback kept BOTH same-key entries, appending one per tick and growing the deferred queue past MaxDeferredDeltas without bound; and a merge whose owner view faulted while the others view succeeded was treated as success, discarding the fresh owner delta and stranding that receive group on a stale payload. Now: a fault on EITHER view voids the merge atomically, and the merge-impossible fallback force-drains the OLDER entry (by Seq) on the reliable batch past the budget (existing force-send precedent) while retaining the newer one on the same reliable lane — the queue holds exactly one entry per key, the per-key wire stream stays seq-monotonic, and every receive group converges after recovery without a new value change.

  • Saturated-main-queue detach cleanup loss (F12) — when the main queue was at capacity, DetachConnection removed the connection but dropped its cleanup lambda, permanently skipping ownership reassignment (dead owners), the player-object mapping, and the ClientDisconnected event. New: UniNetEnvironment.TryQueueOnMain (explicit accept/reject) carries general work; a rejected one-shot detach cleanup falls back to a reserved FIFO retained for PumpMain after normal work (no inline callbacks, no retry loop, no blocking); AttachConnection refuses admission both at normal capacity and while reserved cleanup remains, even if normal work has made room (returns 0, rolls the registration back, disconnects the hub), bounding the reserve by the already-admitted cohort rather than historical connection churn. A throwing action still aborts the current pump call; no throughput/reentrancy contract change is included. Approval-release enqueues rejected by a saturated queue revert to unapproved (the declare-timeout sweep owns them) and approval dispatch/verdict rejections are fault-logged. New observability: ReservedCleanupCount / ReservedCleanupDrainedCount (enqueue/dequeue totals); PendingMainActions includes both queues.

  • Same-key backlog ordering on priority changes (F15) — a runtime priority increase could send a fresh reliable delta before its older queued delta, permanently reverting the receiver. Queued keys now share the group's maximum effective priority and use Seq ordering; the reusable scratch dictionary is limited to queued keys and fresh candidates need no extra pass when the queue is empty. CoreInvariantRegressionTests passed 15/15 in isolated Unity EditMode, including actual generated FastArray replay, >64 recipients, send-fault pool ownership, queue-backpressure churn, and priority increase/decrease controls. This does not promise replay after channel failures.

  • Role-aware client dynamic-mirror lifecycle (F06) — ClientAsync (and ReconnectAsync through it) now purges the previous client generation's dynamic mirrors immediately BEFORE swapping in the new client registry: a leftover mirror kept its cached dynamic netId, was skipped by the fresh generation's scene registration, and a catch-up spawn of a recycled id instantiated a second live instance beside the stale ghost. ClientStop is now client-role-aware too — in host mode the live server's authoritative dynamic originals and their registry entries survive (the still-listening server owns them until ServerStop); previously the indiscriminate sweep destroyed them. Authoritative-original detection compares LIVE SERVER ENTRY component/GameObject identity, never netId alone (a recycled id may name a different component). Multi-component objects are destroyed exactly once, and no destroy callback unregisters by netId, so a play-mode deferred destroy surviving a generation swap cannot wipe the new registry. ServerStop/ServerStopAsync still remove server dynamics.

  • Targeted editor persistence (F07) — the spawnable postprocessor's prefab stamping and table baking no longer call the global AssetDatabase.SaveAssets (which flushed unrelated dirty user assets to disk). Persistence stays deferred off the import callback but now saves ONLY the exact prefab/table assets this operation changed, via Unity 6's targeted AssetDatabase.SaveAssetIfDirty, coalesced into one delay call. The in-memory table remains synchronously usable; destroyed/deleted targets are skipped safely with no global fallback.

  • Driver scene-subscription symmetry (F08) — the hidden UniNetDriver's SceneManager.sceneLoaded subscription is now paired with the driver's actual lifetime (OnDestroy unsubscribes and clears the stale instance reference): every destroy/recreate cycle used to accumulate a duplicate delegate (double registration runs and double scene-ready reports). Ensure stays idempotent.

  • Automatic dynamic ownership admission (F17) — round-robin owner selection now excludes disconnected, unapproved and scene-held connections, using the existing CanReceiveGameData predicate; approved clients with no scene-transition history still qualify. No eligible receiver leaves owner 0 for normal reassignment. Trusted explicit ownerConnId assignments are unchanged.

  • Consumer event example (F16) — the ServerChanged subscription example now accepts its actual NetworkServer argument (runtime => …) instead of failing CS1593. No event API change.