|
1 | 1 | import { captureMessage } from '@sentry/vue'; |
2 | 2 | import vtkViewProxy from '@kitware/vtk.js/Proxy/Core/ViewProxy'; |
| 3 | +import vtkProxyManager from '@kitware/vtk.js/Proxy/Core/ProxyManager'; |
3 | 4 | import { useEventListener, useThrottleFn } from '@vueuse/core'; |
| 5 | +import { Maybe } from '@/src/types'; |
| 6 | +import { useProxyManager } from '@/src/composables/proxyManager'; |
4 | 7 | import { Messages } from '../constants'; |
5 | 8 | import { useMessageStore } from '../store/messages'; |
6 | 9 | import { onProxyManagerEvent, ProxyManagerEvent } from './onProxyManagerEvent'; |
7 | 10 |
|
| 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 | + |
8 | 37 | export function useWebGLWatchdog() { |
9 | 38 | const watchdogs = new Map<string, () => void>(); |
| 39 | + const pxm = useProxyManager(); |
10 | 40 |
|
11 | 41 | const reportError = useThrottleFn(() => { |
12 | 42 | const messageStore = useMessageStore(); |
13 | 43 | 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 | + }); |
15 | 51 | }, 150); |
16 | 52 |
|
17 | 53 | onProxyManagerEvent(ProxyManagerEvent.ProxyCreated, (id, obj) => { |
|
0 commit comments