-
Notifications
You must be signed in to change notification settings - Fork 6k
Implement GetAllocationSize for Vertices #18756
Conversation
|
The only failure for this is fixed on master. I'd rather not rebase and find out another test flaked. Merging on red. |
|
Sorry for commenting on this so late, but I'm curious if there's an opportunity here to re-use existing TypedData arrays (like the Float32List for the vertex positions) by allowing changing the contents of the buffer instead of allocating new ones each frame. Perhaps some way to notify the Vertices that the buffer has changed and it needs to internally resync with Skia? @dnfield Let me know if you think it's worth opening an issue for this. |
|
Do the arrays resize per frame? If so then it's probably better to just allocate new ones and let the GC do its thing, because resizing the buffers would cause a lot of thrash anyway. If not then it's probably worth exploring. |
|
Alternatively, if the array has a (reasonable) upperbound, it could make sense to have an array and a length parameter for how much of the array you actually want to use. |
|
That's a good idea, but they currently do not resize. We only update the vertices when the animation animates them which currently involves moving (just changing x/y values) them. It'd also only be the position buffer that updates, the UV and index buffers are static throughout. |
|
I believe Skia is working on per vertex data (SkVertices::Attribute) that can be exposed to shaders. |
Description
Without this, the GC thinks that Vertices are super cheap. Allocating a lot of them (e.g. new ones each frame) uses tons of memory - on smaller devices, enough memory to OOM die.
Including this in the total picture memory (like in #18706) makes this further use less memory. Doing that fixes part of flutter/flutter#58438
/cc @mehmetf - this may help customer: money with some of their Rive/Flare concerns, since Flare uses this API.
/cc @luigi-rosso @cmkweber
Related Issues
Fixes flutter/flutter#54762
Possibly helps 2d-inc/Flare-Flutter#249
Tests
TODO
Breaking Change
Did any tests fail when you ran them? Please read handling breaking changes.