Enhance error handling for graphics rendering and update external image loader registration
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc && vite build && cp dist/index.js /home/ross/rad/rad/rad/static/dv3d/index.js",
|
"build": "tsc && vite build && cp dist/index.js /home/ross/penracourses/rad/rad/static/dv3d/index.js",
|
||||||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -442,8 +442,18 @@ function App({ container_id, imageStacks, autoCacheStack, annotationJson, viewer
|
|||||||
const onError = (ev: ErrorEvent) => {
|
const onError = (ev: ErrorEvent) => {
|
||||||
try {
|
try {
|
||||||
const msg = ev && ev.message ? String(ev.message) : '';
|
const msg = ev && ev.message ? String(ev.message) : '';
|
||||||
if (msg.includes('releaseGraphicsResources') || msg.includes('openGLTexture')) {
|
// Detect known rendering/WebGL-related errors and actor/colormap issues
|
||||||
console.error('Detected graphics resource error:', ev);
|
if (
|
||||||
|
msg.includes('releaseGraphicsResources') ||
|
||||||
|
msg.includes('openGLTexture') ||
|
||||||
|
msg.includes('getDefaultActor') ||
|
||||||
|
msg.includes('setColormapGPU') ||
|
||||||
|
msg.includes("can't access property \"actor\"") ||
|
||||||
|
// generic rendering failure
|
||||||
|
msg.toLowerCase().includes('webgl') ||
|
||||||
|
msg.toLowerCase().includes('colormap')
|
||||||
|
) {
|
||||||
|
console.error('Detected graphics/rendering error:', ev);
|
||||||
setGraphicsErrorMessage(msg || null);
|
setGraphicsErrorMessage(msg || null);
|
||||||
setGraphicsErrorVisible(true);
|
setGraphicsErrorVisible(true);
|
||||||
}
|
}
|
||||||
@@ -456,8 +466,16 @@ function App({ container_id, imageStacks, autoCacheStack, annotationJson, viewer
|
|||||||
try {
|
try {
|
||||||
const reason = (ev && (ev as any).reason) || '';
|
const reason = (ev && (ev as any).reason) || '';
|
||||||
const text = typeof reason === 'string' ? reason : (reason && reason.message) ? reason.message : String(reason);
|
const text = typeof reason === 'string' ? reason : (reason && reason.message) ? reason.message : String(reason);
|
||||||
if (text.includes('releaseGraphicsResources') || text.includes('openGLTexture')) {
|
if (
|
||||||
console.error('Detected graphics resource rejection:', ev);
|
text.includes('releaseGraphicsResources') ||
|
||||||
|
text.includes('openGLTexture') ||
|
||||||
|
text.includes('getDefaultActor') ||
|
||||||
|
text.includes('setColormapGPU') ||
|
||||||
|
text.includes("can't access property \"actor\"") ||
|
||||||
|
text.toLowerCase().includes('webgl') ||
|
||||||
|
text.toLowerCase().includes('colormap')
|
||||||
|
) {
|
||||||
|
console.error('Detected graphics/rendering rejection:', ev);
|
||||||
setGraphicsErrorMessage(text || null);
|
setGraphicsErrorMessage(text || null);
|
||||||
setGraphicsErrorVisible(true);
|
setGraphicsErrorVisible(true);
|
||||||
}
|
}
|
||||||
@@ -1402,7 +1420,8 @@ function App({ container_id, imageStacks, autoCacheStack, annotationJson, viewer
|
|||||||
dicomImageLoaderInit();
|
dicomImageLoaderInit();
|
||||||
// Register client-side image loader for external images (JPEG/PNG/blob/data)
|
// Register client-side image loader for external images (JPEG/PNG/blob/data)
|
||||||
try {
|
try {
|
||||||
imageLoader.registerImageLoader('external', async (imageId: string) => {
|
imageLoader.registerImageLoader('external', (imageId: string) => {
|
||||||
|
const promise = (async () => {
|
||||||
// imageId expected as 'external:<url>'
|
// imageId expected as 'external:<url>'
|
||||||
const url = imageId.replace(/^external:/, '');
|
const url = imageId.replace(/^external:/, '');
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
@@ -1443,6 +1462,9 @@ function App({ container_id, imageStacks, autoCacheStack, annotationJson, viewer
|
|||||||
} as any;
|
} as any;
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
|
})();
|
||||||
|
|
||||||
|
return { promise };
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('Failed to register external image loader', e);
|
console.warn('Failed to register external image loader', e);
|
||||||
|
|||||||
Reference in New Issue
Block a user