Closed CodeReadOnlyUser closed 4 months ago
This is not surprising because with render mode software, the canvas is backed by a bitmap which inherently has bounds due to the bitmap and there is nothing Lottie can do to render beyond that.
with render mode software
I tested again on devices with Android >= 8.0. If SOFTWARE rendering is manually enabled, nothing is rendered. So the real behavior is LottieDrawable without setting bounds will not be visible in SOFTWARE rendering mode.
And the reason why HARDWARE rendering is used starting from Android Oreo can be found here. https://github.com/airbnb/lottie-android/blob/aebf9bc07bc54979633f3355ada3d3e6e12986a3/lottie/src/main/java/com/airbnb/lottie/RenderMode.java#L38
Thanks for your answer🙏
@CodeReadOnlyUser It not being visible doesn't sound right. Can you create a project that repros this?
https://github.com/1970633640/Lottietest
change this line to HARDWARE to render visible animations: https://github.com/1970633640/Lottietest/blob/fc1fe639e8537101dab38de186558f4b61035b75/app/src/main/java/com/example/lottietest/CustomLottieDrawable.kt#L57
Lottie is supported and developed on nights and weekends. Issues from Lottie sponsors will be prioritized.
Describe the bug
When using
RenderMode.SOFTWARE
or renderMode not specified. LottieDrawable without setting bounds beforeresumeAnimation()
cannot be rendered usinglottieDrawable.draw(canvas)
on devices with Android version < Oreo (API 26)When using
RenderMode.HARDWARE
or devices with Android version >= Oreo (API 26). LottieDrawable without setting bounds beforeresumeAnimation()
will be rendered. The bounds will belottieDrawable.composition.bounds
What version of Lottie did you test this on?
implementation("com.airbnb.android:lottie:6.4.0")
and some older versions.What version of Android did you test this on? Android API 23, API 25, API 26, API 32, API 34
Steps To Reproduce Steps to reproduce the behavior:
Custom drawable with lottie example:
Then, setting this CustomLottieDrawable as some view's background.
Uncomment any lines with ⚠️ comment to render properly on pre Android Oreo devices.
Additional information:
When debugging using
lottieDrawable.toBitmap(,,)
, the bitmap is the correct rendered image. So I am wondering why renderMode and Android version can cause different render result.Solution Set
lottieDrawable.bounds
before callinglottieDrawable.resumeAnimation()
Screenshots Nothing visible