The best way to control Claude Code, Codex and more from any computer or phone
fix(mobile): Android no longer freezes when you go back from a running thread (#19292)
Co-authored-by: PR Batch Tester <agent@local.test> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
shivam committed
Oct 20, 2026 at 13:01 UTC
5a86fe433f895149f7330f3daea63afec3a5e93c
2 files changed
+57
-37
apps/mobile/src/features/threads/thread-work-log.tsx
+44
-37
@@ -33,11 +33,14 @@ import {
33
} from "react";
34
import {
35
AccessibilityInfo,
36
+ Animated as NativeAnimated,
37
AppState,
38
type ColorValue,
39
+ Easing,
40
Pressable,
41
ScrollView,
42
StyleSheet,
43
+ useAnimatedValue,
44
View,
45
} from "react-native";
46
import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
@@ -91,17 +94,12 @@ import type { FilePreviewSource } from "../../components/FilePreviewModal";
94
import { FilePreviewGallery } from "../../components/FilePreviewGallery";
95
import { ThreadMarkdownImage } from "./ThreadMarkdownImage";
96
import Animated, {
94
- cancelAnimation,
95
- Easing,
97
FadeIn,
98
FadeOut,
99
LinearTransition,
100
ReduceMotion,
101
useAnimatedStyle,
102
useSharedValue,
102
- withDelay,
103
- withRepeat,
104
- withSequence,
103
withTiming,
104
} from "react-native-reanimated";
105
import { useAssetUrl } from "../../state/assets";
@@ -267,7 +265,7 @@ export function ShimmeringWorkContent(props: {
265
const [appIsActive, setAppIsActive] = useState(AppState.currentState === "active");
266
const [reducedMotion, setReducedMotion] = useState(true);
267
const screenIsFocused = useIsFocused();
270
- const progress = useSharedValue(0);
268
+ const progress = useAnimatedValue(0);
269
const gradientId = `work-shimmer-${useId().replaceAll(":", "")}`;
270
const contentWidth = Math.min(
271
availableWidth,
@@ -290,37 +288,37 @@ export function ShimmeringWorkContent(props: {
288
return () => subscription.remove();
289
}, []);
290
291
+ // Runs on React Native's native driver instead of Reanimated, whose
292
+ // per-frame commits starve React's while commit pausing is disabled
293
+ // (package.json). See docs/internals/performance-regressions.md.
294
useEffect(() => {
294
- cancelAnimation(progress);
295
- progress.value = 0;
295
+ progress.setValue(0);
296
if (contentWidth <= 0 || reducedMotion || !appIsActive || !screenIsFocused) return;
297
298
- progress.value = withRepeat(
299
- withSequence(
300
- withTiming(1, {
301
- duration: SHIMMER_SWEEP_MS,
302
- easing: Easing.linear,
303
- reduceMotion: ReduceMotion.Never,
304
- }),
305
- withDelay(
306
- SHIMMER_PAUSE_MS,
307
- withTiming(0, { duration: 0, reduceMotion: ReduceMotion.Never }),
308
- ),
309
- ),
310
- -1,
311
- false,
312
- undefined,
313
- ReduceMotion.Never,
298
+ const loop = NativeAnimated.loop(
299
+ NativeAnimated.timing(progress, {
300
+ toValue: 1,
301
+ duration: SHIMMER_SWEEP_MS + SHIMMER_PAUSE_MS,
302
+ easing: Easing.linear,
303
+ useNativeDriver: true,
304
+ }),
305
);
315
- return () => cancelAnimation(progress);
306
+ loop.start();
307
+ return () => loop.stop();
308
}, [appIsActive, contentWidth, progress, reducedMotion, screenIsFocused]);
309
318
- const sweepStyle = useAnimatedStyle(() => ({
319
- transform: [{ translateX: -SHIMMER_WIDTH + progress.value * (contentWidth + SHIMMER_WIDTH) }],
320
- }));
321
- const counterSweepStyle = useAnimatedStyle(() => ({
322
- transform: [{ translateX: SHIMMER_WIDTH - progress.value * (contentWidth + SHIMMER_WIDTH) }],
323
- }));
310
+ // One timing covers the sweep and the pause, so the native driver can loop it.
311
+ // The React Compiler memoizes these, so re-renders don't rebuild the native
312
+ // animation nodes.
313
+ const inputRange = [0, SHIMMER_SWEEP_MS / (SHIMMER_SWEEP_MS + SHIMMER_PAUSE_MS), 1];
314
+ const sweepTranslateX = progress.interpolate({
315
+ inputRange,
316
+ outputRange: [-SHIMMER_WIDTH, contentWidth, contentWidth],
317
+ });
318
+ const counterSweepTranslateX = progress.interpolate({
319
+ inputRange,
320
+ outputRange: [SHIMMER_WIDTH, -contentWidth, -contentWidth],
321
+ });
322
323
return (
324
<View
@@ -341,13 +339,20 @@ export function ShimmeringWorkContent(props: {
339
onTextLayout={(event) => setTextWidth(event.nativeEvent.lines[0]?.width ?? 0)}
340
/>
341
{!reducedMotion && appIsActive && screenIsFocused && contentWidth > 0 ? (
344
- <Animated.View
345
- className="absolute inset-y-0 left-0 overflow-hidden"
342
+ <NativeAnimated.View
343
pointerEvents="none"
344
accessible={false}
345
accessibilityElementsHidden
346
importantForAccessibility="no-hide-descendants"
350
- style={[{ width: SHIMMER_WIDTH }, sweepStyle]}
347
+ style={{
348
+ position: "absolute",
349
+ top: 0,
350
+ bottom: 0,
351
+ left: 0,
352
+ overflow: "hidden",
353
+ width: SHIMMER_WIDTH,
354
+ transform: [{ translateX: sweepTranslateX }],
355
+ }}
356
>
357
<MaskedView
358
style={StyleSheet.absoluteFill}
@@ -368,7 +373,9 @@ export function ShimmeringWorkContent(props: {
373
</Svg>
374
}
375
>
371
- <Animated.View style={[{ width: availableWidth }, counterSweepStyle]}>
376
+ <NativeAnimated.View
377
+ style={{ width: availableWidth, transform: [{ translateX: counterSweepTranslateX }] }}
378
+ >
379
<ShimmerWorkContent
380
textClassName={props.textClassName}
381
compact={props.compact}
@@ -381,9 +388,9 @@ export function ShimmeringWorkContent(props: {
388
themeAppearance={props.themeAppearance}
389
toolIcon={props.toolIcon}
390
/>
384
- </Animated.View>
391
+ </NativeAnimated.View>
392
</MaskedView>
386
- </Animated.View>
393
+ </NativeAnimated.View>
394
) : null}
395
</View>
396
);
docs/internals/performance-regressions.md
+13
@@ -121,3 +121,16 @@ continuous traffic during an outage.
121
Focused coverage: `ProjectionSettlement.test.ts`, `ThreadSettlementService.test.ts`,
122
`runtimeLayer.test.ts`, `AgentAwarenessRelay.test.ts`, `GitVcsDriverCore.test.ts`,
123
`ThreadStatusIndicators.subscriptions.browser.test.tsx`, and `desktopLocal.test.ts`.
124
+
125
+## Mobile looping animations
126
+
127
+`apps/mobile/package.json` sets Reanimated's `DISABLE_COMMIT_PAUSING_MECHANISM` so keyboard avoiding
128
+animates on iOS. Reanimated documents that flag as safe only alongside React Native's
129
+`preventShadowTreeCommitExhaustion`, which defaults to off and needs React Native built from source,
130
+so our builds run without it. Reanimated commits each animation frame to the shadow tree, and
131
+without commit pausing those commits can starve React's: the JS thread keeps retrying its commit,
132
+the screen freezes, and back does nothing. Release builds retry forever; dev builds abort with
133
+`ShadowTree.cpp: assertion failed (attempts < 1024)`. Looping animations that stay on screen while
134
+heavy content renders should use React Native's `Animated` with `useNativeDriver: true`, which
135
+updates views without commits, not Reanimated's `withRepeat`. The running-thread shimmer in
136
+`thread-work-log.tsx` is the example.