Repository navigation
Keep sorting after a sort fails - #511
Open
vanyathecyborg wants to merge 1 commit into
Open
vanyathecyborg wants to merge 1 commit into
vanyathecyborg wants to merge 1 commit into
Conversation
driveSort sets `sorting` before it reads depths back and calls the sort worker, and cleared it only on its last line. If the readback or the worker call rejected, the flag stayed set for the life of the renderer: no sort started again, and an update that changes the splat mapping waits for the running sort. A lost WebGL context is enough: it rejects the readback, and once the context is restored nothing is drawn. The sort body moves into sortCurrent(), and driveSort clears the flag in a finally block. After a failure it marks the sort as still wanted, so the next update starts it again, and rethrows the error as before. A sort worker that trapped is disposed and replaced on that next sort, as the worker pool does for its own workers since sparkjsdev#480: a trap leaves the WebAssembly instance unusable, so the retry would fail the same way. Two unit tests cover a rejected sort that runs again on the next frame and a trapped worker that is not used again. A browser test loses and restores the WebGL context and expects the same image as before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
driveSortsetssortingbefore it reads depths back and calls the sort worker, and cleared it only on its last line. If either rejected, the flag stayed set for the life of the renderer: no sort started again, and an update that changes the splat mapping waits for the running sort. A lost WebGL context is enough to get there: it rejects the readback, and after the context is restored nothing is drawn.The flag is now cleared in a
finallyblock, the failed sort is asked for again on the next update, and the error is rethrown as before. A sort worker that trapped is disposed and replaced on that next sort, as the pool does for its own workers since #480, which leftSparkRenderer's sort worker unchanged.Verification
context-loss.test.ts: it loses the WebGL context, restores it, and expects the same image as before the loss.mainit fails:sortingstaystrue, the renderer never sorts again, and the canvas stays black.mainand pass with this change.Open question
A sort that keeps failing is retried on every update and reported each time. #477 stopped a similar retry for LoD trees. I kept it here because without it a pending mapping change is never shown while the camera stands still. I can add a limit if you prefer.
Related to #480.
🤖 Generated with Claude Code