Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardware automatic recognition #381

Closed
talentqing opened this issue Jul 13, 2017 · 18 comments
Closed

Hardware automatic recognition #381

talentqing opened this issue Jul 13, 2017 · 18 comments

Comments

@talentqing
Copy link

talentqing commented Jul 13, 2017

Can you according to the features of animation to decide use hardware? Because most animations is so simple and no hardware porblem, if any animation use software will be stuck when the ui is complex and the mobile phone performance is bad.

for exmaple:
test.zip
this animation in hardware is performance obviously better than in software.

So I thing can according to the api of features and phone info to auto decide use hardware or software.

@gpeal
Copy link
Collaborator

gpeal commented Jul 13, 2017

Yup, it's been on my mind to do something like this!

@talentqing
Copy link
Author

Do you plan to add this feature in the next release?

@gpeal
Copy link
Collaborator

gpeal commented Jul 13, 2017

@talentqing Not sure, maybe.

@gpeal
Copy link
Collaborator

gpeal commented Jul 13, 2017

@talentqing You can enable it manually today though.

@AndroidDeveloperLB
Copy link

@gpeal But how could we know when it's safe to enable it?
According to what I've found (written about it here) , I think it's safe to use it starting from Android L (API 21)

@gpeal
Copy link
Collaborator

gpeal commented Apr 8, 2018

I've decided to not do this because some animations perform much worse with hardware acceleration even when it supports it. It should continue to be used on a case by case basis.

@gpeal gpeal closed this as completed Apr 8, 2018
@gpeal
Copy link
Collaborator

gpeal commented Apr 8, 2018

@AndroidDeveloperLB
Copy link

@gpeal Can you please provide an example (animation file) that enabling hardware acceleration makes it perform worse?
Also, do you really thing the default behavior, of having it disabled - is usually performing better ?
If not, why having this as the default behavior?
After all, even choosing not to do anything still have a default behavior, which is having it disabled.
This was the case on Android too: for some time, hardware acceleration was disabled by default, and starting from certain Android version, it became enabled by default. Developers can still disable it if they want.

@gpeal
Copy link
Collaborator

gpeal commented Apr 9, 2018

@AndroidDeveloperLB Please read the article linked to in the docs.
There are also cases where certain phones have GAIA bugs that cause things to render incorrectly with hardware acceleration even if they are supported. Facebook stopped using hardware acceleration to render reactions for this exact reason. That's why it's disabled by default. It's easy to enable though so feel free to use it if it works well for you.

@AndroidDeveloperLB
Copy link

This article is very old, and I've read it already. In fact some of my comments are there.

Question is, if it's safe to use now starting from certain Android version, why not enable by default?
I've noticed it's so slow (frame skips) on some cases without hardware acceleration.

Do you think the " GAIA bugs" still occur on today's smartphones? Even on Android 5, 6, 7, 8 ... ?
Can you please show an example of an animation file that has issues on such Android versions, when HA is enabled ?
For us, we've decided to enable it from Android 5, because of how slow it can be without HA enabled, but if you show me an animation file that shows issues on smartphones of these versions, we should re-consider even using this library, because we can't afford having slow animations.

@AndroidDeveloperLB
Copy link

I mean, how could I know for sure that I can enable HA, and when ?
Why would I have this choice, if there is a chance it won't work at all, or maybe even crash?

@gpeal
Copy link
Collaborator

gpeal commented Apr 9, 2018

@AndroidDeveloperLB You should ask Samsung, Huawei, Xiaomi, and whoever else makes Android phones. Phones, just like the software you or I ship, have bugs sometimes. For the most part, phones are getting more reliable and we've turned HA on for most of our animations but software acceleration is safer and since lottie is on billions of phones, I'm leaving the default on the safer option.

@AndroidDeveloperLB
Copy link

@gpeal What's the logic you've chosen on your apps that use Lottie, of determining when to enable HA and when to disable it ?
It's impractical to test on all devices, so I think you've chosen some arbitrary solution, right?

@gpeal gpeal reopened this Dec 12, 2018
@gpeal
Copy link
Collaborator

gpeal commented Dec 12, 2018

@talentqing I'm going to re-investigate this.

@gpeal
Copy link
Collaborator

gpeal commented Dec 16, 2018

Fixed by #1048

@gpeal gpeal closed this as completed Dec 16, 2018
@AndroidDeveloperLB
Copy link

AndroidDeveloperLB commented Dec 16, 2018

@gpeal So no need anymore for this API of enabling HA ?
If so, from which version of the library?

@gpeal
Copy link
Collaborator

gpeal commented Dec 17, 2018

@AndroidDeveloperLB Correct, this will now be automatic and no manual work will be needed. The existing APIs were also removed. It will be in the next version that I'm preparing. Stay tuned. Not sure if it will be 2.9 or 3.0.

@AndroidDeveloperLB
Copy link

@gpeal Good. Last time you were pessimistic about when I should enable it. :)

gpeal added a commit that referenced this issue Jan 4, 2019
While testing, I discovered that animations with lots of/large masks and mattes perform significantly worse with hardware acceleration than software acceleration on pre-Pie devices because of RenderNode#textureUpload. It is really hard to detect this dynamically so I'm leaving the default on automatic (with an additional heuristic for >4 mattes and masks) but having an option to set it to hardware/software manually.

#381
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants