A polygon layer can be finalized while its earcut task is still waiting in a shared worker pool—for example, when a viewport changes or a progressive Arrow response is replaced before every record-batch layer finishes triangulating.
finalizeState() correctly avoids terminating an externally owned pool, but the obsolete layer’s queued task remains. It can later consume worker time and allocate or transfer geometry even though its result can no longer be displayed.
Would it be possible for the layer to retain ownership of its queued task and discard it during finalization if it has not started yet, without terminating the shared pool?
This could use the pool’s task handle, an abort signal, or another internal mechanism. The important semantics would be:
- Finalizing one layer must not terminate or disrupt a shared pool.
- Work that has not started should be removed from the queue.
- Any promise awaited by the layer must settle cleanly rather than being left pending.
- Already-running worker jobs do not necessarily need to be interrupted; cancelling those safely is a separate and harder problem.
This would complement #225: moving payload preparation inside the worker task prevents a cancelled queued job from cloning its geometry before it starts.
A possible regression test would use a one-worker pool, hold its first task open, queue triangulation for a second layer, finalize that second layer, and verify that its worker callback never runs while the first task and the shared pool continue normally.
A polygon layer can be finalized while its earcut task is still waiting in a shared worker pool—for example, when a viewport changes or a progressive Arrow response is replaced before every record-batch layer finishes triangulating.
finalizeState()correctly avoids terminating an externally owned pool, but the obsolete layer’s queued task remains. It can later consume worker time and allocate or transfer geometry even though its result can no longer be displayed.Would it be possible for the layer to retain ownership of its queued task and discard it during finalization if it has not started yet, without terminating the shared pool?
This could use the pool’s task handle, an abort signal, or another internal mechanism. The important semantics would be:
This would complement #225: moving payload preparation inside the worker task prevents a cancelled queued job from cloning its geometry before it starts.
A possible regression test would use a one-worker pool, hold its first task open, queue triangulation for a second layer, finalize that second layer, and verify that its worker callback never runs while the first task and the shared pool continue normally.