Closed josecorretjer-drizly closed 1 year ago
Lottie doesn't render videos, it renders JSON files. Your animation is likely trying to render with software rendering. Are you setting renderMode
to software anywhere? If you are intentionally using software rendering, it may be that your View doesn't have a constrained size so it's trying to draw much larger than your screen. Can you ensure that your View's bounds aren't too big? You can make it full screen with scaleType
set to centerCrop
or centerInside
if you want.
We're not even explicitly setting the render mode. What are the benefits of picking a mode?
Depends on what you consider "too big". Our view bounds are set to the parent and we're targeting phone devices.
Yeah we're setting the scale to centerCrop
Can you try inspecting your view to ensure that the view bounds aren't larger than the screen? This error isn't coming from Lottie, it's coming from Android which won't render to a bitmap-backed canvas that is too large. That size is always larger than the screen size.
That's where things get complicated. View height/width are set to match_parent
. If I could determine if the size of the view is too large then I could do something to handle this problem, but this error is generated from within setAnimationFromJson
. You make a very good point about the size being larger than the screen size. I could maybe wrap setAnimationFromJson in a condition that compares the response dimensions against the device
This is likely not something you should need to worry about yourself unless the view winds up being too large which is an issue with your view hierarchy, not your animation. The LottieAnimationView may be match_parent but if the parent is larger than the screen the you could still hit this.
I wish it were that easy, but it's not. The parent layout is also set to match_parent
. Maybe something is increasing its size. I think my best option is the conditional statement I mentioned before.
v "5.7.4"
fr 29.9700012207031
ip 0
op 120.0000048877
w 828
h 1792
nm "Composed Mobile - Web"
ddd 0
The animation height(1792) is smaller than the actual device. I tested on a device with a height value of 2148
. Even though the animation height is smaller it's still crashing. Looking at the LottieValueAnimator
argument for the onAnimationStart
listener. I can see that the preCompHeight
for the only available layers
item of the composition
is almost twice(4928) as big as the original. Not sure how that's even possible when the parent and child views are set to the match_parent
. That one solution I spoke about doesn't work because of this.
I'm on version 6.1.0
Below is the response I'm trying to use
If I pass that into
setAnimationFromJson
, throws aJava.lang.RuntimeException: Canvas: trying to draw too large(374038120bytes) bitmap
.Is there a way to stop or prevent the animation from rendering if it's too large?
Everything works as expected, if the video source response is small. The dimensions mentioned above are the ones that are giving me trouble.