You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a developer using TresJS, I need a way to gracefully handle and display runtime errors that occur within the TresCanvas component and its children. This would improve the development experience and make it easier to debug issues in production.
Motivation
Currently, when an error occurs within TresCanvas or any of its child components (lights, meshes, materials, etc.) or threejs, the error can cause the entire application to crash or render a blank canvas without any meaningful feedback. This makes it difficult to:
Identify the source of the error
Debug issues in development
Provide a fallback UI in production
Handle errors gracefully without affecting the rest of the application
Proposal
Add an Error Boundary feature to TresCanvas that would:
Catch runtime errors in:
Scene initialization
Component mounting/unmounting
Animation frame updates
Resource loading (textures, models, etc.)
Child component errors
Provide a customizable error display that shows:
Error message and stack trace (in development)
Component tree path to the error
Simplified error message (in production)
Include built-in error handling for common ThreeJS-specific errors:
WebGL context loss
Texture loading failures
Geometry errors
Material compilation errors
Suggested solution
Implementation Details
<template>
<TresCanvas:error-boundary="true":error-fallback="customErrorComponent"@error="handleError"
>
<!-- Scene content -->
</TresCanvas>
</template>
The error boundary would inject necessary CSS styles automatically for the error display, eliminating the need for external CSS files. The styles would be scoped to the error boundary container to avoid conflicts.
Default Error Display
The default error display would be a styled overlay with:
Error message
Stack trace (in development)
Retry button
Option to copy error details
Responsive design that maintains the canvas aspect ratio
Description
As a developer using TresJS, I need a way to gracefully handle and display runtime errors that occur within the TresCanvas component and its children. This would improve the development experience and make it easier to debug issues in production.
Motivation
Currently, when an error occurs within TresCanvas or any of its child components (lights, meshes, materials, etc.) or threejs, the error can cause the entire application to crash or render a blank canvas without any meaningful feedback. This makes it difficult to:
Proposal
Add an Error Boundary feature to TresCanvas that would:
Catch runtime errors in:
Provide a customizable error display that shows:
Include built-in error handling for common ThreeJS-specific errors:
Suggested solution
Implementation Details
The error boundary would inject necessary CSS styles automatically for the error display, eliminating the need for external CSS files. The styles would be scoped to the error boundary container to avoid conflicts.
Default Error Display
The default error display would be a styled overlay with:
Opt-in vs Opt-out Discussion
Opt-in Approach
<!-- Explicit opt-in --> <TresCanvas :error-boundary="true"> <!-- Scene content --> </TresCanvas>
Pros:
Cons:
Opt-out Approach
<!-- Error boundaries enabled by default --> <TresCanvas> <!-- Scene content --> </TresCanvas> <!-- Explicit opt-out --> <TresCanvas :error-boundary="false"> <!-- Scene content --> </TresCanvas>
Pros:
Cons:
Alternative
No response
Additional context
Questions for Discussion
Feel free to share your thoughts and suggestions on this proposal!
Validations
The text was updated successfully, but these errors were encountered: