Skip to content

Commit

Permalink
Fix bugs related to mesh loading and short links (#7507)
Browse files Browse the repository at this point in the history
* Fix mesh serialization for sharing links

* Fix that meshes (or chunks) that were loaded while the segmentation layer was not visible were always white

* Fix race condition when opening short link

* update changelog
  • Loading branch information
daniel-wer committed Dec 20, 2023
1 parent 5a6f12d commit 8d64194
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- The settings page for non-wkw datasets no longer shows a wall of non-applying errors. [#7475](https://github.com/scalableminds/webknossos/pull/7475)
- Fixed a bug where dataset deletion for ND datasets and datasets with coordinate transforms would not free the name even if no referencing annotations exist. [#7495](https://github.com/scalableminds/webknossos/pull/7495)
- Fixed a bug where the URL in the sharing link was wrongly decoded before encoding into a URI. [#7502](https://github.com/scalableminds/webknossos/pull/7502)
- Fixed a bug where loaded meshes were not encoded in the sharing link. [#7507](https://github.com/scalableminds/webknossos/pull/7507)
- Fixed a bug where meshes (or chunks of them) were always colored white, if they were loaded while the corresponding segmentation layer was disabled. [#7507](https://github.com/scalableminds/webknossos/pull/7507)
- Fixed a race condition when opening a short link, that would sometimes lead to an error toast. [#7507](https://github.com/scalableminds/webknossos/pull/7507)

### Removed

Expand Down
7 changes: 6 additions & 1 deletion frontend/javascripts/components/redirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ class AsyncRedirect extends React.PureComponent<Props> {
if (newPath.startsWith(location.origin)) {
// The link is absolute which react-router does not support
// apparently. See https://stackoverflow.com/questions/42914666/react-router-external-link
location.replace(newPath);
if (this.props.pushToHistory) {
location.assign(newPath);
} else {
location.replace(newPath);
}
return;
}

if (this.props.pushToHistory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export default class SegmentMeshController {
);
}

constructMesh(segmentId: number, geometry: THREE.BufferGeometry) {
const color = this.getColorObjectForSegment(segmentId);
constructMesh(segmentId: number, layerName: string, geometry: THREE.BufferGeometry) {
const color = this.getColorObjectForSegment(segmentId, layerName);
const meshMaterial = new THREE.MeshLambertMaterial({
color,
});
Expand Down Expand Up @@ -127,7 +127,7 @@ export default class SegmentMeshController {
targetGroup.scale.copy(new THREE.Vector3(...scale));
}
}
const mesh = this.constructMesh(segmentationId, geometry);
const mesh = this.constructMesh(segmentationId, layerName, geometry);
if (offset) {
mesh.translateX(offset[0]);
mesh.translateY(offset[1]);
Expand Down Expand Up @@ -179,7 +179,7 @@ export default class SegmentMeshController {
}

setMeshColor(id: number, layerName: string): void {
const color = this.getColorObjectForSegment(id);
const color = this.getColorObjectForSegment(id, layerName);
// if in nd-dataset, set the color for all additional coordinates
for (const recordsOfLayers of Object.values(this.meshesGroupsPerSegmentationId)) {
const meshDataForOneSegment = recordsOfLayers[layerName][id];
Expand All @@ -192,8 +192,8 @@ export default class SegmentMeshController {
}
}

getColorObjectForSegment(segmentId: number) {
const [hue, saturation, light] = getSegmentColorAsHSLA(Store.getState(), segmentId);
getColorObjectForSegment(segmentId: number, layerName: string) {
const [hue, saturation, light] = getSegmentColorAsHSLA(Store.getState(), segmentId, layerName);
const color = new THREE.Color().setHSL(hue, 0.75 * saturation, light / 10);
return color;
}
Expand Down
6 changes: 4 additions & 2 deletions frontend/javascripts/oxalis/controller/url_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
additionalCoordinateToKeyValue,
parseAdditionalCoordinateKey,
} from "oxalis/model/helpers/nml_helpers";
import { getMeshesForCurrentAdditionalCoordinates } from "oxalis/model/accessors/volumetracing_accessor";

const MAX_UPDATE_INTERVAL = 1000;
const MINIMUM_VALID_CSV_LENGTH = 5;
Expand Down Expand Up @@ -272,11 +273,12 @@ class UrlManager {
}

for (const layerName of Object.keys(state.localSegmentationData)) {
const { meshes: localMeshes, currentMeshFile } = state.localSegmentationData[layerName];
const { currentMeshFile } = state.localSegmentationData[layerName];
const currentMeshFileName = currentMeshFile?.meshFileName;
const localMeshes = getMeshesForCurrentAdditionalCoordinates(state, layerName);
const meshes =
localMeshes != null
? Utils.values(localMeshes as Record<number, MeshInformation>)
? Utils.values(localMeshes)
.filter(({ isVisible }) => isVisible)
.map(mapMeshInfoToUrlMeshDescriptor)
: [];
Expand Down
2 changes: 1 addition & 1 deletion frontend/javascripts/oxalis/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ export type OxalisState = {
readonly localSegmentationData: Record<
string, //layerName
{
//for meshes, the string represents additional coordinates, number is the segment ID.
// For meshes, the string represents additional coordinates, number is the segment ID.
// The undefined types were added to enforce null checks when using this structure.
readonly meshes: Record<string, Record<number, MeshInformation> | undefined> | undefined;
readonly availableMeshFiles: Array<APIMeshFile> | null | undefined;
Expand Down

0 comments on commit 8d64194

Please sign in to comment.