Skip to content

Commit d907f38

Browse files
Fix ad hoc mesh infinite loading (#8915)
This PR avoids requesting out-of-bounds ad hoc mesh chunks in an infinite loop. ### URL of deployed dev instance (used for testing): - https://fixadhocmeshinfiniteloading.webknossos.xyz ### Steps to test: - Best to test locally with a dataset without segment index - please not, that ad hoc meshing is bug for transformed datasets. See #8913. - checkout 3fc42bd to have a visualization of what happens on the master - View a dataset without a segment index. - Load some segments ad hoc mesh. Watch boxes appear -> infinitely mesh requests e.g. going more and more out of bounds. - Note: The bounds of the boxes are not correct but still helpful to see at what coordinates mesh chunk requests are sent. - check out 67f2060 and do the same again after reload - now no boxes outside of the segmentation layer should be requested and the request should terminate rather quickly ### TODOs: - [x] remove debug bboxes code ### Issues: - fixes reported here: https://scm.slack.com/archives/C02H5T8Q08P/p1757417432537409?thread_ts=1757338710.530969&cid=C02H5T8Q08P ------ (Please delete unneeded items, merge only when none are left open) - [x] Added changelog entry (create a `$PR_NUMBER.md` file in `unreleased_changes` or use `./tools/create-changelog-entry.py`) --------- Co-authored-by: Daniel <[email protected]>
1 parent 1cc8807 commit d907f38

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

frontend/javascripts/test/global_mocks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ vi.mock("libs/toast", () => ({
2222
success: vi.fn(),
2323
info: vi.fn(),
2424
},
25+
showToastOnce: vi.fn(),
2526
}));
2627

2728
vi.mock("libs/user_local_storage", () => ({

frontend/javascripts/viewer/model/sagas/meshes/ad_hoc_mesh_saga.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,12 @@ function* maybeLoadMeshChunk(
429429
): Saga<Vector3[]> {
430430
const additionalCoordinates = yield* select((state) => state.flycam.additionalCoordinates);
431431
const threeDMap = getOrAddMapForSegment(layer.name, segmentId, additionalCoordinates);
432+
const mag = magInfo.getMagByIndexOrThrow(zoomStep);
433+
const paddedPosition = V3.toArray(V3.sub(clippedPosition, mag));
434+
const paddedPositionWithinLayer =
435+
layer.cube.boundingBox.clipPositionIntoBoundingBox(paddedPosition);
432436

433-
if (threeDMap.get(clippedPosition)) {
437+
if (threeDMap.get(paddedPositionWithinLayer)) {
434438
return [];
435439
}
436440

@@ -439,7 +443,7 @@ function* maybeLoadMeshChunk(
439443
}
440444

441445
batchCounterPerSegment[segmentId]++;
442-
threeDMap.set(clippedPosition, true);
446+
threeDMap.set(paddedPositionWithinLayer, true);
443447
const scaleFactor = yield* select((state) => state.dataset.dataSource.scale.factor);
444448
const dataStoreHost = yield* select((state) => state.dataset.dataStore.url);
445449
const datasetId = yield* select((state) => state.dataset.id);
@@ -449,8 +453,6 @@ function* maybeLoadMeshChunk(
449453
}`;
450454
const tracingStoreUrl = `${tracingStoreHost}/tracings/volume/${layer.name}`;
451455

452-
const mag = magInfo.getMagByIndexOrThrow(zoomStep);
453-
454456
if (isInitialRequest) {
455457
sendAnalyticsEvent("request_isosurface", {
456458
mode: useDataStore ? "view" : "annotation",
@@ -462,9 +464,6 @@ function* maybeLoadMeshChunk(
462464
const { segmentMeshController } = getSceneController();
463465

464466
const cubeSize = marchingCubeSizeInTargetMag();
465-
const paddedPosition = V3.toArray(V3.sub(clippedPosition, mag));
466-
const paddedPositionWithinLayer =
467-
layer.cube.boundingBox.clipPositionIntoBoundingBox(paddedPosition);
468467

469468
while (retryCount < MAX_RETRY_COUNT) {
470469
try {

unreleased_changes/8915.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Fixed
2+
- Ad hoc mesh requests loading infinitely.

0 commit comments

Comments
 (0)