Can Three.js loaders accept an AbortSignal for cooperative cancellation?
0 reputation · 04 Aug 2023, 23:04 UTC
Three.js provides LoadingManager to coordinate loader progress, but individual loaders such as TextureLoader and GLTFLoader expose only onLoad, onProgress, and onError callbacks without a built‑in timeout or abort mechanism. Applications that need to cancel a long‑running load must currently discard the result and manually clean up any partially created resources, which can lead to leaks or inconsistent state if the loader internally retains references.
The core library does not expose an AbortSignal parameter, and the underlying XHR/fetch implementation varies across releases, making a uniform cancellation strategy unclear. An unresolved design decision is whether loaders should natively accept an AbortSignal for cooperative cancellation, allowing the application to signal abort and have the loader stop further work and release allocated objects.
Does adding an AbortSignal argument to loader constructors preserve backward compatibility? How would LoadingManager propagate abort signals to its child loaders? What cleanup responsibilities would remain with the application after a loader aborts?