Skip to content

Refactor volume undo/redo mechanism and fix subtle bugs #7506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 46 commits into from
Apr 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
7516f32
create BucketSnapshot class to extract complexity from undo saga
philippotto Dec 19, 2023
561ecf7
inline some stuff to remove types and trivial function
philippotto Dec 19, 2023
19bc4e2
fix tests
philippotto Dec 19, 2023
9caec7d
rename VolumeUndoBuckets to BucketSnapshot[]
philippotto Dec 20, 2023
19c2dd9
extract BucketSnapshot into own module
philippotto Dec 20, 2023
2763d00
mark some properties as readonly
philippotto Dec 20, 2023
120407c
store the versionAtRequestTime in buckets and add version field to Bu…
philippotto Dec 21, 2023
2ccdb71
fix segment tree color in dark mode
philippotto Dec 21, 2023
c728c6d
refactor a bit in pullqueue
philippotto Dec 21, 2023
3b86a38
make use of unused throttledTriggerLabeled in bucket to trigger bucke…
philippotto Dec 21, 2023
8fc3e01
don't do anything in volumetracing_saga when the voxel position did n…
philippotto Dec 21, 2023
5a3ba3b
fix vertical align of undo/redo buttons when in loading state
philippotto Dec 21, 2023
88813ab
prepare new constraint that buckets must not be GCed if snapshots of …
philippotto Dec 21, 2023
64fa426
Merge branch 'master' of github.com:scalableminds/webknossos into ref…
philippotto Dec 23, 2024
370684b
fix cyclic dependencies
philippotto Dec 23, 2024
993d9da
fix pullqueue spec
philippotto Dec 23, 2024
28cfdcf
clean up & rename markAsPulled to markAsRequested
philippotto Dec 23, 2024
4b195e1
remove versionAtRequestTime again; instead, we should always aim to f…
philippotto Dec 23, 2024
e5e08b0
resolve more todos
philippotto Dec 23, 2024
3f39444
ensure loaded bucket before creating snapshot for undo/redo (fixes ra…
philippotto Jan 3, 2025
0bb94c3
parallelize awaiting of bucket snapshots
philippotto Jan 3, 2025
5b5b28d
Merge branch 'master' of github.com:scalableminds/webknossos into ref…
philippotto Jan 7, 2025
b19194c
refactor addToPullQueueWithHighestPriority and css class for undo red…
philippotto Jan 8, 2025
eb011f0
more todo comments in collectBucketsIf
philippotto Jan 8, 2025
04aab8a
Merge branch 'master' of github.com:scalableminds/webknossos into ref…
philippotto Mar 20, 2025
3e37819
write unit tests for new BucketSnapshot class
philippotto Mar 24, 2025
db5953e
update comments
philippotto Mar 24, 2025
6801cf8
iterate on tests
philippotto Mar 24, 2025
f23248f
more comments
philippotto Mar 24, 2025
da1bbaf
tackle last todo in collectBucketsIf
philippotto Mar 25, 2025
5e52602
improve comments
philippotto Mar 25, 2025
716dbc5
wording
philippotto Mar 25, 2025
7afac37
fix tests
philippotto Mar 25, 2025
2f36db1
clean up
philippotto Apr 1, 2025
4700bb8
Merge branch 'master' of github.com:scalableminds/webknossos into ref…
philippotto Apr 1, 2025
e6d4006
Apply suggestions from code review
philippotto Apr 2, 2025
033828e
delete debugging related code
philippotto Apr 2, 2025
4671058
Update frontend/javascripts/oxalis/model/bucket_data_handling/bucket.ts
philippotto Apr 2, 2025
e97ceb8
Update frontend/javascripts/oxalis/model/bucket_data_handling/bucket_…
philippotto Apr 2, 2025
0e638f5
Merge branch 'refactor-volume-undo' of github.com:scalableminds/webkn…
philippotto Apr 2, 2025
7aa1c7e
add missing await
philippotto Apr 2, 2025
9bc6463
update changelog
philippotto Apr 2, 2025
059f178
fix tests by changing needsBackendData back to this.data == null; add…
philippotto Apr 2, 2025
f841e5b
Merge branch 'master' of github.com:scalableminds/webknossos into ref…
philippotto Apr 2, 2025
c029b03
remove accidentally added conflict marker
philippotto Apr 3, 2025
50cbfff
Merge branch 'master' into refactor-volume-undo
philippotto Apr 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Re-enabled jobs planned to be paid with credits for organizations without a paid plan. [#8478](https://github.com/scalableminds/webknossos/pull/8478)
- Fixed that the dataset extent tooltip in the right details bar in the dashboard did not properly update when switching datasets. [#8477](https://github.com/scalableminds/webknossos/pull/8477)
- Fixed a bug where task creation with volume zip as input would fail. [#8468](https://github.com/scalableminds/webknossos/pull/8468)
- Fixed a rare and subtle bug related to volume annotation and undo/redo. [#7506](https://github.com/scalableminds/webknossos/pull/7506)
- Fixed that a warning message about a newer version of an annotation was shown multiple times. [#8486](https://github.com/scalableminds/webknossos/pull/8486)
- Fixed a bug where segment statistics would sometimes be wrong in case of an on-disk segmentation fallback layer with segment index file. [#8460](https://github.com/scalableminds/webknossos/pull/8460)
- Fixed a bug where sometimes outdated segment statistics would be displayed. [#8460](https://github.com/scalableminds/webknossos/pull/8460)

Expand Down
4 changes: 2 additions & 2 deletions frontend/javascripts/admin/api/mesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ type MeshLodInfo = {
};

type MeshSegmentInfo = {
chunkShape: Vector3;
gridOrigin: Vector3;
chunkShape: Vector3; // unused
gridOrigin: Vector3; // unused
lods: Array<MeshLodInfo>;
};

Expand Down
6 changes: 2 additions & 4 deletions frontend/javascripts/libs/async/deferred.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
class Deferred<T, U> {
// @ts-expect-error ts-migrate(2564) FIXME: Property '_internalResolve' has no initializer and... Remove this comment to see the full error message
_internalResolve: (arg0: T) => void;
// @ts-expect-error ts-migrate(2564) FIXME: Property '_internalReject' has no initializer and ... Remove this comment to see the full error message
_internalReject: (arg0: U) => void;
_internalResolve!: (arg0: T) => void;
_internalReject!: (arg0: U) => void;
_internalPromise: Promise<T>;

// Wrapper around `Promise` that keeps a reference to `resolve` and `reject`
Expand Down
5 changes: 3 additions & 2 deletions frontend/javascripts/oxalis/api/api_latest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ import {
} from "oxalis/model/actions/volumetracing_actions";
import BoundingBox from "oxalis/model/bucket_data_handling/bounding_box";
import type { Bucket, DataBucket } from "oxalis/model/bucket_data_handling/bucket";
import { getConstructorForElementClass } from "oxalis/model/bucket_data_handling/bucket";
import type DataLayer from "oxalis/model/data_layer";
import dimensions from "oxalis/model/dimensions";
import { MagInfo } from "oxalis/model/helpers/mag_info";
Expand All @@ -151,6 +150,7 @@ import {
scaleGlobalPositionWithMagnification,
zoomedAddressToZoomedPosition,
} from "oxalis/model/helpers/position_converter";
import { getConstructorForElementClass } from "oxalis/model/helpers/typed_buffer";
import { getMaximumGroupId } from "oxalis/model/reducers/skeletontracing_reducer_helpers";
import { getHalfViewportExtentsInUnitFromState } from "oxalis/model/sagas/saga_selectors";
import { Model, api } from "oxalis/singletons";
Expand Down Expand Up @@ -1617,14 +1617,15 @@ class DataApi {
layerName: string,
predicateFn?: (bucket: DataBucket) => boolean,
): Promise<void> {
const truePredicate = () => true;
await Promise.all(
Utils.values(this.model.dataLayers).map(async (dataLayer: DataLayer) => {
if (dataLayer.name === layerName) {
if (dataLayer.cube.isSegmentation) {
await Model.ensureSavedState();
}

dataLayer.cube.collectBucketsIf(predicateFn || (() => true));
dataLayer.cube.collectBucketsIf(predicateFn || truePredicate);
dataLayer.layerRenderingManager.refresh();
}
}),
Expand Down
26 changes: 10 additions & 16 deletions frontend/javascripts/oxalis/model/actions/volumetracing_actions.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import Deferred from "libs/async/deferred";
import type { BucketAddress, ContourMode, OrthoView, Vector2, Vector3 } from "oxalis/constants";
import type { ContourMode, OrthoView, Vector2, Vector3 } from "oxalis/constants";
import type { QuickSelectGeometry } from "oxalis/geometries/helper_geometries";
import { AllUserBoundingBoxActions } from "oxalis/model/actions/annotation_actions";
import type { BucketDataArray } from "oxalis/model/bucket_data_handling/bucket";
import type { NumberLike, Segment, SegmentGroup, SegmentMap } from "oxalis/store";
import type { Dispatch } from "redux";
import { batchActions } from "redux-batched-actions";
import type { ServerEditableMapping, ServerVolumeTracing } from "types/api_flow_types";
import type {
BucketDataArray,
ServerEditableMapping,
ServerVolumeTracing,
} from "types/api_flow_types";
import type { AdditionalCoordinate } from "types/api_flow_types";
import type BucketSnapshot from "../bucket_data_handling/bucket_snapshot";

export type InitializeVolumeTracingAction = ReturnType<typeof initializeVolumeTracingAction>;
export type InitializeEditableMappingAction = ReturnType<typeof initializeEditableMappingAction>;
Expand All @@ -26,7 +30,7 @@ export type ClickSegmentAction = ReturnType<typeof clickSegmentAction>;
export type InterpolateSegmentationLayerAction = ReturnType<
typeof interpolateSegmentationLayerAction
>;
export type MaybeUnmergedBucketLoadedPromise = null | Promise<BucketDataArray>;
export type MaybeUnmergedBucketLoadedPromise = Promise<BucketDataArray> | null;
export type AddBucketToUndoAction = ReturnType<typeof addBucketToUndoAction>;
type RegisterLabelPointAction = ReturnType<typeof registerLabelPointAction>;
type ResetContourAction = ReturnType<typeof resetContourAction>;
Expand Down Expand Up @@ -343,20 +347,10 @@ export const setContourTracingModeAction = (mode: ContourMode) =>
mode,
}) as const;

export const addBucketToUndoAction = (
zoomedBucketAddress: BucketAddress,
bucketData: BucketDataArray,
maybeUnmergedBucketLoadedPromise: MaybeUnmergedBucketLoadedPromise,
pendingOperations: Array<(arg0: BucketDataArray) => void>,
tracingId: string,
) =>
export const addBucketToUndoAction = (bucketSnapshot: BucketSnapshot) =>
({
type: "ADD_BUCKET_TO_UNDO",
zoomedBucketAddress,
bucketData,
maybeUnmergedBucketLoadedPromise,
pendingOperations: pendingOperations.slice(),
tracingId,
bucketSnapshot,
}) as const;

export const importVolumeTracingAction = () =>
Expand Down
Loading