Skip to content

Commit 310b0c7

Browse files
PR Batch Testerclaude
andcommitted
fix(mobile): let the React Compiler memoize the shimmer interpolations
Main moved thread-work-log.tsx to the React Compiler and dropped useMemo, so the hand-written memo no longer compiled. Also note in the docs that React Native's preventShadowTreeCommitExhaustion is off in our builds. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 61cf9f7 commit 310b0c7

2 files changed

Lines changed: 17 additions & 18 deletions

File tree

‎apps/mobile/src/features/threads/thread-work-log.tsx‎

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -306,20 +306,17 @@ export function ShimmeringWorkContent(props: {
306306
}, [appIsActive, contentWidth, progress, reducedMotion, screenIsFocused]);
307307

308308
// One timing covers the sweep and the pause, so the native driver can loop it.
309-
// Memoized so re-renders don't rebuild the native animation nodes.
310-
const { sweepTranslateX, counterSweepTranslateX } = useMemo(() => {
311-
const inputRange = [0, SHIMMER_SWEEP_MS / (SHIMMER_SWEEP_MS + SHIMMER_PAUSE_MS), 1];
312-
return {
313-
sweepTranslateX: progress.interpolate({
314-
inputRange,
315-
outputRange: [-SHIMMER_WIDTH, contentWidth, contentWidth],
316-
}),
317-
counterSweepTranslateX: progress.interpolate({
318-
inputRange,
319-
outputRange: [SHIMMER_WIDTH, -contentWidth, -contentWidth],
320-
}),
321-
};
322-
}, [contentWidth, progress]);
309+
// The React Compiler memoizes these, so re-renders don't rebuild the native
310+
// animation nodes.
311+
const inputRange = [0, SHIMMER_SWEEP_MS / (SHIMMER_SWEEP_MS + SHIMMER_PAUSE_MS), 1];
312+
const sweepTranslateX = progress.interpolate({
313+
inputRange,
314+
outputRange: [-SHIMMER_WIDTH, contentWidth, contentWidth],
315+
});
316+
const counterSweepTranslateX = progress.interpolate({
317+
inputRange,
318+
outputRange: [SHIMMER_WIDTH, -contentWidth, -contentWidth],
319+
});
323320

324321
return (
325322
<View

‎docs/internals/performance-regressions.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,12 @@ Focused coverage: `ProjectionSettlement.test.ts`, `ThreadSettlementService.test.
121121

122122
## Mobile looping animations
123123

124-
`apps/mobile/package.json` sets Reanimated's `DISABLE_COMMIT_PAUSING_MECHANISM` so keyboard
125-
avoiding animates on iOS. Reanimated commits each animation frame to the shadow tree, and without
126-
commit pausing those commits can starve React's: the JS thread keeps retrying its commit, the
127-
screen freezes, and back does nothing. Release builds retry forever; dev builds abort with
124+
`apps/mobile/package.json` sets Reanimated's `DISABLE_COMMIT_PAUSING_MECHANISM` so keyboard avoiding
125+
animates on iOS. Reanimated documents that flag as safe only alongside React Native's
126+
`preventShadowTreeCommitExhaustion`, which defaults to off and needs React Native built from source,
127+
so our builds run without it. Reanimated commits each animation frame to the shadow tree, and
128+
without commit pausing those commits can starve React's: the JS thread keeps retrying its commit,
129+
the screen freezes, and back does nothing. Release builds retry forever; dev builds abort with
128130
`ShadowTree.cpp: assertion failed (attempts < 1024)`. Looping animations that stay on screen while
129131
heavy content renders should use React Native's `Animated` with `useNativeDriver: true`, which
130132
updates views without commits, not Reanimated's `withRepeat`. The running-thread shimmer in

0 commit comments

Comments
 (0)