Skip to main content

Runtime and ownership contract

Discovery and the Provider calls getModVersion and isReady run on any thread. Every other call is game-thread-only. Calls that return Status report WrongThread; the bool/count getters fail closed. Do not call the provider from workers, render/physics callbacks, arbitrary destructors or static teardown.

Callback lifetime​

PAPER event callbacks run on its owner thread. The event record is borrowed only during that call; the consumer retains ownership of its callback code and userdata. Copy values, not event pointers. FrameComplete is the control and lease boundary. Final native-pose observation uses PresentationComplete, dispatched after ROCK's Presented phase publishes the final pose. It requires both FrameCallbacks and NativePosePipeline capabilities. This additional observation does not advance leases.

Owner lifetime​

Consumer registration creates an owner token tied to a provider generation. The same token is valid for every PAPER interface. Unregistration removes callbacks, leases and authority owned by that token, the physical-reload lease included. A normal RuntimeReset clears authority and cached state but preserves consumer registrations and event callbacks. Discard stale generation-dependent data and deliberately rearm activity. Full provider shutdown/reinitialization clears registrations; reconnect when that registration is actually gone rather than registering duplicate owners on every runtime reset.

Leases​

Animation authority accepts zero for persistent-until-clear ownership, or a bounded frame lease up to kMaxAuthorityLeaseFrames (1200). Prefer renewable short leases for temporary coordination.

A physical-reload lease lasts 1 to kMaxLeaseFrames (120) frames after the ROCK frame it names, and ends early when the equipped item is replaced, on a world reset or when the owner is revoked. Renew it every frame while physical control lasts. A physical-reload lease and animation authority exclude each other: the lease is refused while any consumer holds authority.

Cleanup​

On the game thread: clear the physical-reload lease and authority, unregister event callbacks, unregister the owner (Client::close), then discard every retained sequence and provider-derived cache.