Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit61a33237e0

README.md

scene_observe

The record of what a scene load did, and what each loaded scene costs. Backs layers.observe, layers.lastLoad, layers.lastUnload, layers.loadHistory, layers.problems, layers.whyPartial, layers.inventory, layers.cost and layers.resetCostWindow, and the scene toolbox's observe, whyPartial and cost above them. layers and scene_loader are its writers.

One record per load

A load opens a record; the loader, the lifecycle dispatchers and the scene's own build write their failures and phase timings into it; the load's own completion point closes it with the duration the engine already measured for its DONE line. Reading is lazy — nothing here walks the world, and the only writer that runs every frame is noteUpdate, which the entrypoint tick calls once per scene that declares one.

local r = layers.lastLoad()
print(r.name, r.outcome, r.durationMs)
print(r.entities.added, "arrived,", r.entities.removed, "left")
print(r.phases.teardown, r.phases.instantiate, r.phases.settle)

outcome is "ok" when everything the scene declared was produced, "partial" when the load finished with failures in it, "failed" when the load raised and left no layer, and "unchanged" when the scene asked for was already the active root — that load rebuilt nothing, so the layer keeps the record of the load that built it and still answers why it is not whole.

reason names the nearest cause from the closed set — loaderRaised, entrypointCompileFailed, entrypointBodyRaised, entrypointRaised, buildRaised, entityFailed, parentMissing, parentRefused, parentAbandoned, componentUnresolved, componentRefused, subscriberRaised, updateRaised — ranked so it names the thing to fix rather than the last thing to break.

Failures reach the layer they belong to

Every write of a failure calls the subscriber layers registers through M.onFailure, which republishes the record onto that layer's proxy: ok false, failures the records, and "partial" in place of "ready" once the layer has settled. A tick that starts raising on frame 400 moves the layer the same way one raised during the load does.

A failure identical to one already held raises that one's count, so a tick raising every frame keeps one record. FAILURE_LIMIT bounds the distinct records a report holds, and failuresOmitted states how many arrived past it.

Cost

noteUpdate accumulates each layer's entrypoint tick into a per-guid entry — calls, total, last, max, average and how many raised — summed across the window M.window() reports. M.resetWindow() opens a new one, leaving the load history alone. An unload drops the layer's entry.