Open mehmetf opened 4 years ago
Tried adding another penguin actor with a different animation full size in a column. The memory usage does not increase for that:
App Summary
Pss(KB)
------
Java Heap: 1880
Native Heap: 33900
Code: 9496
Stack: 60
Graphics: 91796
Private Other: 19524
System: 4005
TOTAL: 160661 TOTAL SWAP PSS: 62
body: Column(
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
child: FlareActor(
"assets/Penguin.flr",
alignment: Alignment.center,
//isPaused: true,
fit: BoxFit.cover,
animation: "walk",
),
),
Expanded(
child: FlareActor(
"assets/Penguin.flr",
alignment: Alignment.center,
//isPaused: true,
fit: BoxFit.cover,
animation: "music_walk",
),
),
],
),
Loading an entirely different (but much simpler) animation together with penguin also does not affect the memory significantly.
App Summary
Pss(KB)
------
Java Heap: 1780
Native Heap: 35532
Code: 9504
Stack: 60
Graphics: 91656
Private Other: 19924
System: 4018
TOTAL: 162474 TOTAL SWAP PSS: 63
However, it is interesting to note that native heap is the only dimension that goes up with a different animation.
Replacing both animations with the simple animation also results in same memory profile. The new animation is mostly white with small balloons and confetti floating around periodically. I would have expected the graphics memory to be lower for this kind of setup.
I commented on this elsewhere to you, but what happens if you reduce the resource cache using the Skia system channel?
I suspect that the animation is gobbling up available resource cache space from Skia, and that's what's causing this.
@jacob314 FYI
The linked engine PR lowers memory consumption by the penguin animation by about 4 or 5 megabytes locally for me.
That's really interesting because the penguin animation doesn't use any vertices (unless something it uses allocates vertices under the hood). That's a vector-only animation, flare_flutter will only directly allocate and draw vertices when it has raster content.
The issue generally addressed by that PR does sound like it would help with other Skia objects too. For example, we'll regenerate paths which animate each frame. This causes Skia to use up more cache bytes. It doesn't recoup those until the animation loop's been idle for some amount of time (I think it was 15 seconds). Skia has a way to mark Paths that animate often as volatile which may help in cases like this. Maybe the ability to set this flag could be bubbled up to the app layer in Flutter?
We are debugging memory problems of some of our key customers in Google. As part of that, we are trying to see which assets end up consuming the most memory.
As a first data point, loading
penguin.flr
from a sample app into a simple hello_flutter app bumps memory usage by nearly 80M.Before Flare:
After Flare:
A sizable increase is observed in native heap (+23M), graphics (+30M) and dart heap (+15M).
If the FlareActor is paused, the usage drops dramatically but is still 13M higher than baseline.
With animation looping and size reduced to 10x10:
Code:
I have been getting these memory dumps in release mode using
adb shell dumpsys meminfo
.Similar to issue: https://github.com/2d-inc/Flare-Flutter/issues/238.
https://github.com/2d-inc/Flare-Flutter/pull/228 is not submitted yet so I could not test turning off AA.
Is there any path here to reducing the Flare memory usage?