Rive drains battery in the background on Android
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- android, react-native, typescript
- 領域
- mobile, performance
調査の方向性
Start with android/src/new/java/com/rive/RiveReactNativeView.kt and android/src/new/java/com/margelo/nitro/rive/HybridRiveFileFactory.kt, the two frame-callback loops identified in the report. Reproduce on Android using the linked Expo app and the provided atrace command; compare callbacks after pressing Home with the reported baseline. Done means the app no longer continuously wakes the main thread in the background when Rive views are paused or unmounted.
索引モデルが issue の本文から書いたものです。
説明
Submission checklist
- I have confirmed the issue is present in the latest version of
@rive-app/react-native - I have searched the documentation and forums and could not find an answer
- I have searched existing issues and this is not a duplicate
Description
On Android with the new backend, once an app has loaded a Rive file it keeps a Choreographer frame callback posted on every vsync for the rest of the process. Even when every Rive view is paused or unmounted, the main thread wakes 60 times a second. This is not a big deal while the app running normally, but it keeps happening when the app is backgrounded.
Here's what my Claude found, but you probably know better:
Two loops are responsible. Both have been there since the new backend landed in 0.5.0 (#134):
- The view's render loop never stops while paused. In
RiveReactNativeView.kt#L172-L178,
a paused view with nothing to redraw just refresheslastFrameTimeNsand posts itself again.
Every other path posts again too (L221).
The loop only stops when the view is disposed.- The CommandQueue is polled on every vsync for the life of the process. Once the shared worker
exists,HybridRiveFileFactory.startPolling
posts a frame callback that callspollMessages()and re-posts itself forever, even when no Rive
view is mounted.
Previous working version
No response
Reproduction steps / code
https://github.com/Nezz/expo-repro/tree/repro/RivePausedFrames
bun install
npx expo run:android --variant release
scripts/run.sh 3
Then press Home and count frame callbacks for 10 s:
adb shell atrace -t 10 view | grep -c "B|$(adb shell pidof com.adamys.exporepro)|Choreographer#doFrame"
That gives ~600. The same app before it loads a Rive file gives 0.
Upload your reproduction files / stack trace
No response
Source .riv / .rev file
No response
Screenshots / video
No response
@rive-app/react-native version
0.5.4
Platform
Android only
React Native version
0.86.3
React Native environment info
Expo setup
Yes — Expo prebuild / EAS Build
Expo SDK version (if applicable)
No response
iOS device & OS version (if applicable)
57.0.27
Android device & OS version (if applicable)
Android Emulator — API Level 36 (Medium Phone, 60 Hz)
Additional context
New Android backend, release build
- 主要言語
- TypeScript
- スター
- 157
- フォーク
- 17
- 平均マージ
- 1日 10時間
- マージ済み PR(30日)
- 20
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rive-app/rive-nitro-react-native のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
rive-app/rive-nitro-react-native#424 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Android] Fit.Layout content stale after resize on the new backend (surface keeps creation size)対応中かも @mfazekas が 6 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
rive-app/rive-nitro-react-native#418 ·
メンテナーはふだん 1 日以内に返信
-
[Android] RiveFonts: loadFont({name}) fails for script fonts on OEM fonts.xml; systemFallback() is not script-aware (tofu for Thai/Hebrew/Arabic/CJK)対応中かも @mfazekas が 16 日前に担当しました。 オープンandroid bug
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
rive-app/rive-nitro-react-native#369 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement iOS
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
rive-app/rive-nitro-react-native#58 · コメント 7 件 ·
メンテナーはふだん 1 日以内に返信
rive-app/rive-nitro-react-native の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
simkimsia/netlify-axi#19 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
subhranshudash13-dotcom/Contribo#74 ·
メンテナーはふだん 1 日以内に返信
-
enhancement frontend good first issue Stellar Wave trivial
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Godgift-care/sci-healthcare-frontend#166 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
backend good first issue security Stellar Wave trivial
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
Godgift-care/sci-healthcare-backend#171 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信