File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change 11import { h } from 'preact'
22import { getCanvasContext } from '../app-state/getters'
3- import { memo , useMemo } from 'preact/compat'
3+ import { memo , useEffect , useMemo } from 'preact/compat'
44import { useActiveProfileState } from '../app-state/active-profile-state'
55import { useTheme } from './themes/theme'
66import {
@@ -20,10 +20,21 @@ import {Application} from './application'
2020export const ApplicationContainer = memo ( ( ) => {
2121 const canvas = useAtom ( glCanvasAtom )
2222 const theme = useTheme ( )
23- const canvasContext = useMemo (
24- ( ) => ( canvas ? getCanvasContext ( { theme, canvas} ) : null ) ,
25- [ theme , canvas ] ,
26- )
23+ const { canvasContext, error : canvasError } = useMemo ( ( ) => {
24+ if ( ! canvas ) return { canvasContext : null , error : null }
25+ try {
26+ return { canvasContext : getCanvasContext ( { theme, canvas} ) , error : null }
27+ } catch ( e ) {
28+ console . error ( 'Failed to create WebGL context:' , e )
29+ return { canvasContext : null , error : e }
30+ }
31+ } , [ theme , canvas ] )
32+
33+ useEffect ( ( ) => {
34+ if ( canvasError ) {
35+ errorAtom . set ( true )
36+ }
37+ } , [ canvasError ] )
2738
2839 return (
2940 < ProfileSearchContextProvider >
You can’t perform that action at this time.
0 commit comments