From 69e93699bf7327e7e4a4b17c41282e799af86092 Mon Sep 17 00:00:00 2001 From: Forrest Date: Fri, 24 Nov 2023 12:00:51 -0500 Subject: [PATCH 1/2] fix(useWebGLWatchdog): just report message The WebGL event is not an exception, just an event object. --- src/composables/useWebGLWatchdog.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/composables/useWebGLWatchdog.ts b/src/composables/useWebGLWatchdog.ts index 26016f938..3025ee80b 100644 --- a/src/composables/useWebGLWatchdog.ts +++ b/src/composables/useWebGLWatchdog.ts @@ -1,4 +1,4 @@ -import { captureException, captureMessage } from '@sentry/vue'; +import { captureMessage } from '@sentry/vue'; import vtkViewProxy from '@kitware/vtk.js/Proxy/Core/ViewProxy'; import { useEventListener, useThrottleFn } from '@vueuse/core'; import { Messages } from '../constants'; @@ -8,15 +8,11 @@ import { onProxyManagerEvent, ProxyManagerEvent } from './onProxyManagerEvent'; export function useWebGLWatchdog() { const watchdogs = new Map void>(); - const reportError = useThrottleFn((event) => { + const reportError = useThrottleFn(() => { const messageStore = useMessageStore(); messageStore.addError(Messages.WebGLLost.title, Messages.WebGLLost.details); - if (event) { - captureException(event); - } else { - captureMessage('WebGL2 context was lost'); - } - }, 100); + captureMessage('WebGL2 context was lost'); + }, 150); onProxyManagerEvent(ProxyManagerEvent.ProxyCreated, (id, obj) => { if (!obj || !obj.isA('vtkViewProxy')) return; From 426b69f8c897c6d4d3a243d9455a27224d6a983f Mon Sep 17 00:00:00 2001 From: Forrest Date: Fri, 24 Nov 2023 13:24:26 -0500 Subject: [PATCH 2/2] feat(useWebGLWatchdog): attach volume mapper stats --- src/composables/useWebGLWatchdog.ts | 38 ++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/composables/useWebGLWatchdog.ts b/src/composables/useWebGLWatchdog.ts index 3025ee80b..e7c07eed8 100644 --- a/src/composables/useWebGLWatchdog.ts +++ b/src/composables/useWebGLWatchdog.ts @@ -1,17 +1,53 @@ import { captureMessage } from '@sentry/vue'; import vtkViewProxy from '@kitware/vtk.js/Proxy/Core/ViewProxy'; +import vtkProxyManager from '@kitware/vtk.js/Proxy/Core/ProxyManager'; import { useEventListener, useThrottleFn } from '@vueuse/core'; +import { Maybe } from '@/src/types'; +import { useProxyManager } from '@/src/composables/proxyManager'; import { Messages } from '../constants'; import { useMessageStore } from '../store/messages'; import { onProxyManagerEvent, ProxyManagerEvent } from './onProxyManagerEvent'; +/** + * Collects relevant context for debugging 3D crashes. + * @returns + */ +function getVolumeMapperContext(pxm: Maybe) { + if (!pxm) return null; + + const view3d = pxm.getViews().find((view) => view.isA('vtkLPSView3DProxy')); + if (!view3d) return null; + + const ren = view3d.getRenderer(); + const vol = ren.getVolumes()[0]; + if (!vol) return null; + + const mapper = vol.getMapper(); + if (!mapper) return null; + + return mapper.get( + 'computeNormalFromOpacity', + 'autoAdjustSampleDistances', + 'maximumSamplesPerRay', + 'sampleDistance', + 'volumetricScatteringBlending' + ); +} + export function useWebGLWatchdog() { const watchdogs = new Map void>(); + const pxm = useProxyManager(); const reportError = useThrottleFn(() => { const messageStore = useMessageStore(); messageStore.addError(Messages.WebGLLost.title, Messages.WebGLLost.details); - captureMessage('WebGL2 context was lost'); + captureMessage('WebGL2 context was lost', { + contexts: { + vtk: { + volumeMapper: getVolumeMapperContext(pxm), + }, + }, + }); }, 150); onProxyManagerEvent(ProxyManagerEvent.ProxyCreated, (id, obj) => {