Skip to content

Commit 4e27240

Browse files
authored
Merge pull request #517 from Kitware/report-generic-contextlost-error
fix(useWebGLWatchdog): just report message
2 parents d7d9775 + 426b69f commit 4e27240

1 file changed

Lines changed: 40 additions & 8 deletions

File tree

src/composables/useWebGLWatchdog.ts

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,54 @@
1-
import { captureException, captureMessage } from '@sentry/vue';
1+
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

11-
const reportError = useThrottleFn((event) => {
41+
const reportError = useThrottleFn(() => {
1242
const messageStore = useMessageStore();
1343
messageStore.addError(Messages.WebGLLost.title, Messages.WebGLLost.details);
14-
if (event) {
15-
captureException(event);
16-
} else {
17-
captureMessage('WebGL2 context was lost');
18-
}
19-
}, 100);
44+
captureMessage('WebGL2 context was lost', {
45+
contexts: {
46+
vtk: {
47+
volumeMapper: getVolumeMapperContext(pxm),
48+
},
49+
},
50+
});
51+
}, 150);
2052

2153
onProxyManagerEvent(ProxyManagerEvent.ProxyCreated, (id, obj) => {
2254
if (!obj || !obj.isA('vtkViewProxy')) return;

0 commit comments

Comments
 (0)