Enhance error handling for graphics rendering and update external image loader registration
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"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",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
|
||||
@@ -442,8 +442,18 @@ function App({ container_id, imageStacks, autoCacheStack, annotationJson, viewer
|
||||
const onError = (ev: ErrorEvent) => {
|
||||
try {
|
||||
const msg = ev && ev.message ? String(ev.message) : '';
|
||||
if (msg.includes('releaseGraphicsResources') || msg.includes('openGLTexture')) {
|
||||
console.error('Detected graphics resource error:', ev);
|
||||
// Detect known rendering/WebGL-related errors and actor/colormap issues
|
||||
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);
|
||||
setGraphicsErrorVisible(true);
|
||||
}
|
||||
@@ -456,8 +466,16 @@ function App({ container_id, imageStacks, autoCacheStack, annotationJson, viewer
|
||||
try {
|
||||
const reason = (ev && (ev as any).reason) || '';
|
||||
const text = typeof reason === 'string' ? reason : (reason && reason.message) ? reason.message : String(reason);
|
||||
if (text.includes('releaseGraphicsResources') || text.includes('openGLTexture')) {
|
||||
console.error('Detected graphics resource rejection:', ev);
|
||||
if (
|
||||
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);
|
||||
setGraphicsErrorVisible(true);
|
||||
}
|
||||
@@ -1402,7 +1420,8 @@ function App({ container_id, imageStacks, autoCacheStack, annotationJson, viewer
|
||||
dicomImageLoaderInit();
|
||||
// Register client-side image loader for external images (JPEG/PNG/blob/data)
|
||||
try {
|
||||
imageLoader.registerImageLoader('external', async (imageId: string) => {
|
||||
imageLoader.registerImageLoader('external', (imageId: string) => {
|
||||
const promise = (async () => {
|
||||
// imageId expected as 'external:<url>'
|
||||
const url = imageId.replace(/^external:/, '');
|
||||
const img = new Image();
|
||||
@@ -1443,6 +1462,9 @@ function App({ container_id, imageStacks, autoCacheStack, annotationJson, viewer
|
||||
} as any;
|
||||
|
||||
return image;
|
||||
})();
|
||||
|
||||
return { promise };
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn('Failed to register external image loader', e);
|
||||
|
||||
Reference in New Issue
Block a user