Skip to content

Commit 426b69f

Browse files
committed
feat(useWebGLWatchdog): attach volume mapper stats
1 parent 69e9369 commit 426b69f

1 file changed

Lines changed: 37 additions & 1 deletion

File tree

src/composables/useWebGLWatchdog.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,53 @@
11
import { captureMessage } from '@sentry/vue';
22
import vtkViewProxy from '@kitware/vtk.js/Proxy/Core/ViewProxy';
3+
import vtkProxyManager from '@kitware/vtk.js/Proxy/Core/ProxyManager';
34
import { useEventListener, useThrottleFn } from '@vueuse/core';
5+
import { Maybe } from '@/src/types';
6+
import { useProxyManager } from '@/src/composables/proxyManager';
47
import { Messages } from '../constants';
58
import { useMessageStore } from '../store/messages';
69
import { onProxyManagerEvent, ProxyManagerEvent } from './onProxyManagerEvent';
710

11+
/**
12+
* Collects relevant context for debugging 3D crashes.
13+
* @returns
14+
*/
15+
function getVolumeMapperContext(pxm: Maybe<vtkProxyManager>) {
16+
if (!pxm) return null;
17+
18+
const view3d = pxm.getViews().find((view) => view.isA('vtkLPSView3DProxy'));
19+
if (!view3d) return null;
20+
21+
const ren = view3d.getRenderer();
22+
const vol = ren.getVolumes()[0];
23+
if (!vol) return null;
24+
25+
const mapper = vol.getMapper();
26+
if (!mapper) return null;
27+
28+
return mapper.get(
29+
'computeNormalFromOpacity',
30+
'autoAdjustSampleDistances',
31+
'maximumSamplesPerRay',
32+
'sampleDistance',
33+
'volumetricScatteringBlending'
34+
);
35+
}
36+
837
export function useWebGLWatchdog() {
938
const watchdogs = new Map<string, () => void>();
39+
const pxm = useProxyManager();
1040

1141
const reportError = useThrottleFn(() => {
1242
const messageStore = useMessageStore();
1343
messageStore.addError(Messages.WebGLLost.title, Messages.WebGLLost.details);
14-
captureMessage('WebGL2 context was lost');
44+
captureMessage('WebGL2 context was lost', {
45+
contexts: {
46+
vtk: {
47+
volumeMapper: getVolumeMapperContext(pxm),
48+
},
49+
},
50+
});
1551
}, 150);
1652

1753
onProxyManagerEvent(ProxyManagerEvent.ProxyCreated, (id, obj) => {

0 commit comments

Comments
 (0)