Animated.loop instances accumulate under the New Architecture on 0.77.3, degrading performance over a long-running session
Mantenedores costumam responder em até 2 dias
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 40/100
- Tipo de issue
- Bug
- Clareza
- Precisa de esclarecimento
- Status de atividade
- Ativa
- Stack de tecnologia
- android, react-native
- Domínio
- mobile, performance
Direção de pesquisa
Comece pelo ponto de entrada Animated.loop e compare seu comportamento entre React Native 0.75.3 e 0.77.3 com a New Architecture habilitada no Android. Reproduza a montagem e desmontagem repetidas da tela com vários loops infinitos e, em seguida, verifique se os loops interrompidos não continuam se acumulando e se o soak test de longa duração permanece estável.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Description
On RN 0.77.3 with the New Architecture, looping animations appear not to be
released when their component unmounts, even though every call site stops the
loop in its cleanup. The number of live loops grows for the life of the
process, so each frame drives more of them and the app gets progressively
slower.
This is a long-running Android app that stays open for days without the process
restarting. A repeated user flow — mounting a screen, doing some work, then
returning to the previous screen — takes ~16s on a freshly started process and
~28s by the 40th repetition, measured with an automated UI soak. Only a process
restart clears it.
Evidence
Bisected to the 0.75.3 -> 0.77.3 upgrade. Building an older source tree
with only the RN upgrade applied — no other application changes — reproduces
it; the same tree on 0.75.3 is flat.
| build | run 1-10 | run 31-40 | slope |
|---|---|---|---|
| RN 0.75.3 | 18.0s | 17.9s | -0.005 s/iteration |
| RN 0.77.3 (only change) | 20.8s | 26.5s | +0.280 s/iteration |
CPU profiles (Hermes sampling profiler over the inspector, two equal 60s
windows, one early in the session and one after ~30 iterations):
[Host Function] startAnimatingNode 3.3% -> 14.6%
[Host Function] startOperationBatch 1.7% -> 7.6%
getSlope / getTForX / calcBezier 4.7% -> 19.9%
newtonRaphsonIterate 1.1% -> 4.7%
__getNativeAnimationConfig 0.3% -> 1.3%
Roughly a 4x increase in absolute Animated work over equal windows. The hot
frames are the ones that run when an animation starts
(__getNativeAnimationConfig samples the easing curve into a lookup table at
start time), so animations are being started ever more often rather than
running longer.
Isolated to Animated.loop. Neutralising Animated.loop alone — leaving
every timing, spring and sequence untouched — removes the entire
regression:
| build | run 1-10 | run 31-40 | slope |
|---|---|---|---|
| unmodified 0.77.3 | 16.4s | 26.1s | +0.338 s/iteration |
| all animations disabled | 18.0s | 17.9s | +0.003 s/iteration |
only Animated.loop disabled |
17.8s | 18.0s | ~0.000 s/iteration |
What we ruled out by measurement
useNativeDriver— switching every call site tofalsechanged nothing
(+0.335 vs +0.338), so this is not the native animation module specifically.- Component/view retention — live
ViewsandAppContexts(dumpsys meminfo)
are flat across the run; threads and file descriptors fall slightly. - Leaked listeners, unbounded JS containers, navigation stacking (we use
replace/popToTop), our list renderer, NativeWind's babel transform, and
third-party SDK versions. - Hermes heap growth is real (40 -> 80 MB across 40 iterations) but is not
the cause: it still doubles with loops disabled while timings stay flat.
Every loop on the affected path already calls .stop() in its effect cleanup.
Steps to reproduce
We do not yet have a minimal reproduction — the evidence above comes from a
large application. The pattern that triggers it here is a screen that mounts
several components each running an infinite Animated.loop, where that screen
is mounted and unmounted repeatedly, with the New Architecture enabled on
Android.
Happy to build a minimal repro if that would help; filing now in case the
profile signature is already recognisable to someone.
React Native Version
0.77.3
Affected Platforms
Runtime - Android
Areas
Fabric - The New Renderer
Environment
- Android 7.1.2, armeabi-v7a, low-end ARM SoC (2 GB RAM)
- Hermes enabled, New Architecture enabled
- Release build (minified,
--dev=false)
- Linguagem predominante
- C++
- Estrelas
- 127k
- Forks
- 25.3k
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de react/react-native
-
Needs: Author Feedback Needs: Repro
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
react/react-native#58659 · 2 comentários ·
Mantenedores costumam responder em até 2 dias
-
Needs: Author Feedback Needs: Repro
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 92/100
react/react-native#58621 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
Needs: Author Feedback Needs: Repro
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
react/react-native#58610 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
Needs: Triage :mag:
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
react/react-native#58565 · 1 comentário · 2 reações ·
Mantenedores costumam responder em até 2 dias
-
Needs: Attention Needs: Repro
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
react/react-native#58526 · 2 comentários ·
Mantenedores costumam responder em até 2 dias
Todas as issues de react/react-native
Issues semelhantes
-
bug
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 88/100
isl-org/Open3D#7585 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
Unconfirmed bug
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
luanti-org/luanti#17605 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
area: config area: firmware priority: P2 - medium size: S type: bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mizithra/ActiveTerrain#16 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
grumpycoders/pcsx-redux#2171 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
Mantenedores costumam responder em até 2 dias