Skip to content
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

fix(VtkThreeView): try to minimize crashes #526

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions src/components/VtkThreeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import vtkVolumeMapper from '@kitware/vtk.js/Rendering/Core/VolumeMapper';
import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
import { getDiagonalLength } from '@kitware/vtk.js/Common/DataModel/BoundingBox';
import type { Vector3 } from '@kitware/vtk.js/types';
import * as Features from '@/src/utils/features';

import { useProxyManager } from '@/src/composables/proxyManager';
import ViewOverlayGrid from '@/src/components/ViewOverlayGrid.vue';
Expand Down Expand Up @@ -210,6 +211,11 @@ function useCvrEffect(
let sampleDistance = spacing.reduce((a, b) => a + b) / 3.0;
// Adjust the volume sampling by the quality slider value
sampleDistance /= volumeQuality_ > 1 ? 0.5 * volumeQuality_ ** 2 : 1.0;
if (Features.IS_WEBGL_USING_ANGLE) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either: detect angle, or detect angle + intel

// prevent setting too low of a sample distance
sampleDistance = Math.max(0.5, sampleDistance);
}

const samplesPerRay = spatialDiagonal / sampleDistance + 1;
mapper.setMaximumSamplesPerRay(samplesPerRay);
mapper.setSampleDistance(sampleDistance);
Expand Down
12 changes: 12 additions & 0 deletions src/utils/features.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { getGPUInfo } from '@/src/utils/gpuInfo';

function isWebGlUsingAngle() {
try {
const info = getGPUInfo();
return info.renderer.startsWith('ANGLE');
} catch (_) {
return false;
}
}

export const IS_WEBGL_USING_ANGLE = isWebGlUsingAngle();
Loading