Module progress

Module progress 

Source
Expand description

Cooperative heartbeat from long geometry work to a host that must tell a slow call from a hung one (see the module docs). Cooperative progress heartbeat from inside long geometry work.

A browser geometry worker runs one synchronous WASM call per batch, and the host can only see that the call is still alive through messages the worker posts. Before this hook a single slow element (a wall with hundreds of curved openings: tens of seconds) was indistinguishable from a genuinely wedged call, so the host’s wall-clock recovery replaced the worker after 45 s and skipped the element after another 90 s. Whether an element survived therefore depended on the user’s CPU speed and load, which made the same file produce different geometry on different machines.

[tick] is called at coarse points that every long-running geometry path passes through repeatedly (each boolean, each analytic prism cut, each coplanar consolidation bucket, a strided count of exact-predicate escalations, each element). With no hook installed, the default on every native target, it is a single atomic load. The wasm bindings install a hook that rate-limits by the JS clock and lets the worker post a heartbeat, so a call that is still working is never mistaken for a hung one. The hook has no influence on WHAT is computed: geometry output is identical with or without it.

Functions§

set_hook
Install the process-wide progress hook. First installation wins; a later call is ignored and returns false. The hook must be cheap and must not re-enter geometry code.
tick
Report that geometry work is progressing. A no-op until a hook is installed.
tick_strided
tick on every (stride_mask + 1)-th call, for a hot loop whose single iteration is too cheap to report on its own. stride_mask is a power of two minus one; counter is the loop’s own call count.