Skip to content

Commit

Permalink
refactor(react-core): silence gpu log and add GPUInfo to window
Browse files Browse the repository at this point in the history
  • Loading branch information
telestrial committed Feb 21, 2025
1 parent b7ecfb2 commit e215d4e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion libs/react-core/src/appSettings/useGpuFeatures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import { usePrefersReducedMotion } from '../userPrefersReducedMotion'
// esm compat
const { getGPUTier } = detectGpu

// Extend window to support GPU info.
declare global {
interface Window {
GPUInfo: detectGpu.TierResult
}
}

export function useGpuFeatures() {
const reduceMotion = usePrefersReducedMotion()
const [hasCheckedGpu, setHasCheckedGpu] = useState<boolean>(false)
Expand Down Expand Up @@ -36,7 +43,8 @@ export function useGpuFeatures() {
// skip check during tests
if (process.env['NODE_ENV'] !== 'test') {
const gpu = await getGPUTier()
console.log('GPU', gpu)
// Attach the GPU information to window for easy debugging with users.
window.GPUInfo = gpu
// canRender = gpu.gpu?.startsWith('apple') || (gpu.fps || 0) >= 15
canRender = gpu.tier > 0
// if user has not made a selection yet, and gpu is not powerful, disable gpu
Expand Down

0 comments on commit e215d4e

Please sign in to comment.