-
Notifications
You must be signed in to change notification settings - Fork 29.1k
Do not cache itemBuilder calls in a GridView #61033
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
Conversation
I would be more comfortable if we validated this claim; either via benchmarks or if that's too hard, by manual testing. Is the performance acceptable with the repro case that the client gave us (200 6M images)? I admit it is highly synthetic but it could give us an idea of what we are losing. |
The use case this should help is when you have a GridView and rapidly scroll back and forth, it's caching the result of the itemBuilder function and so doesn't have to keep invoking it. Anecdotally, I don't notice any significant performance difference with the customer's simplified demo, which I think is fairly close to their real use case. But I'm also testing on relatively recent hardware (iPhone 11, Pixel 4). Is there any chance the customer has any benchmarks for this? I didn't think transitions perf would be much impacted by this, but it looks like the numbers are better overall:
|
I'm going to go ahead with this. I can't come up with a case where this would cause problems, and if we find one we can fix it. |
Description
Avoid caching the result of the itemBuilder for GridView. This causes problems particularly when the widget being built is expensive to hold in memory, such as when it's a memory image.
Ideally, this shouldn't land until after #61025 has run through the devicelab to show the improvement in memory usage expected.
This might potentially regress frame performance, but I can't find a benchmark ti should negatively impact. Either way, it's causing OOMs for a customer so it needs to be fixed. If we can determine a memory safe way of doing an LRU cache for this we could try that. However, we generally say that things that build widgets should be fast - I doubt we're really saving much time with this optimization.
/cc @chunhtai @Hixie
Related Issues
Fixes #61006
Tests
I added the following tests:
Unit test that we call the itemBuilder when scrolling.
Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.