NativeScript / NativeScript/android
setInterval(()=>null,0) makes any animation much smoother
まだ誰も着手していません。
- 主要言語
- C++
- スター
- 563
- フォーク
- 144
- 平均マージ
- 10時間 46分
- マージ済み PR(30日)
- 14
説明
Environment
- CLI: 6.1.2
- Android Runtime: 6.0.2 / 6.1.2
Describe the bug
I'm working on custom animation (screen blinking at 60fps) on Android, and I was very surprised that using of stupid setInterval(() => {...}, 0) works much better that the native android's Choreographer.
With setInterval(() => {...}, 0) I've got stable 60 FPS even on android 5 devices, but with Choreographer (that should work much efficiency, code below) I got drops to 50 FPS on powerful OnePlus 6 on Android 9.0
android.view.Choreographer.getInstance().postFrameCallback(...);
But if I write down setInterval(() => null); near the Choreographer callback definition - I will achieve stable FPS and low GPU utilisation (LOL, right?).
To Reproduce
I have created app on playground where everybody can test it. Turn on 'Profile GPU rendering' - 'On screen as bars' in 'developer options' menu and launch this simple app with simple loader on 2 pages - one with absolutely empty component, another one with setInterval(() => {}, 0) in OnInit.
Sample project
Nativescript Playground
Additional context
I've recorded animations to demonstrate this behaviour Imgur
And my question on StackOverflow (without any answer) link
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、Profile GPU rendering を有効にした Android 上でリンク先の NativeScript Playground を再現し、空の画面、setInterval(..., 0)、Choreographer.postFrameCallback のケースを比較します。次に、setInterval と Choreographer の Android runtime におけるスケジューリングのエントリポイントを追跡します。完了条件は、フレームレートの違いを説明または修正し、報告されたデバイスで比較を検証することです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- android, javascript
- 領域
- mobile-dev, performance
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100