Skip to content

Commit

Permalink
fix: Check for NaN in FPS Graph
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Apr 22, 2024
1 parent f571a05 commit 629e23e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions package/src/FpsGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ export function FpsGraph({ averageFpsSamples, targetMaxFps, style, ...props }: P

return (
<View {...props} style={[styles.container, style]}>
{averageFpsSamples.map((fps, index) => (
<View key={index} style={[styles.bar, { height: (fps / maxFps) * HEIGHT }]} />
))}
{latestFps != null && (
{averageFpsSamples.map((fps, index) => {
let height = (fps / maxFps) * HEIGHT
if (Number.isNaN(height) || height < 0) {
// clamp to 0 if needed
height = 0
}
return <View key={index} style={[styles.bar, { height: height }]} />
})}
{latestFps != null && !Number.isNaN(latestFps) && (
<View style={styles.centerContainer}>
<Text style={styles.text}>{Math.round(latestFps)} FPS</Text>
</View>
Expand Down

0 comments on commit 629e23e

Please sign in to comment.