NativeScript / NativeScript/android
setInterval(()=>null,0) makes any animation much smoother
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C++
- Star
- 563
- Fork
- 144
- Merge trung bình
- 10 giờ 46 phút
- Pull request đã merge (30 ngày)
- 14
Mô tả
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện NativeScript Playground được liên kết trên Android với Profile GPU rendering được bật, đồng thời so sánh màn hình trống, setInterval(..., 0) và các trường hợp Choreographer.postFrameCallback. Sau đó, truy vết các điểm vào lập lịch của Android runtime cho setInterval và Choreographer; công việc được xem là hoàn tất khi sự khác biệt về tốc độ khung hình đã được giải thích hoặc khắc phục và phép so sánh đã được xác minh trên các thiết bị được báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- android, javascript
- Lĩnh vực
- mobile-dev, performance
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100