NativeScript / NativeScript/android

setInterval(()=>null,0) makes any animation much smoother

オープン
#1,491 コメント 10 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. 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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。