Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Only cache required frames#8837

Merged
mklim merged 3 commits intoflutter:masterfrom
mklim:remove_cache
May 13, 2019
Merged

Only cache required frames#8837
mklim merged 3 commits intoflutter:masterfrom
mklim:remove_cache

Conversation

@mklim
Copy link
Contributor

@mklim mklim commented May 3, 2019

Remove the extra decodedCacheRatioCap parameter, and the
_frameBitmaps member from Codec. This means that small looped images
will consume more CPU but prevents us from hitting OOM exceptions based
on trying to render multiple larger images.

Breaking Change: https://groups.google.com/forum/#!topic/flutter-announce/LXAL4RjbkT0
Fixes flutter/flutter#26081

@mklim mklim requested a review from amirh May 3, 2019 20:29
@mklim mklim marked this pull request as ready for review May 3, 2019 20:29
Future<Codec> instantiateImageCodec(Uint8List list, {
double decodedCacheRatioCap = 0,
}) {
Future<Codec> instantiateImageCodec(Uint8List list) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should follow the breaking changes protocol here and below

Copy link
Contributor Author

@mklim mklim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should follow the breaking changes protocol here and below

I followed the policy for the framework PR: flutter/flutter#32041. Do you think there should be an additional announcement for the dart:ui changes?

@amirh
Copy link
Contributor

amirh commented May 8, 2019

We should follow the breaking changes protocol here and below

I followed the policy for the framework PR: flutter/flutter#32041. Do you think there should be an additional announcement for the dart:ui changes?

I think we should make another announcement as we didn't announce a breaking change to instantiateImageCodec and decodeImageFromPixels

@mklim
Copy link
Contributor Author

mklim commented May 8, 2019

I think we should make another announcement as we didn't announce a breaking change to instantiateImageCodec and decodeImageFromPixels

Makes sense. Posted an announcement to https://groups.google.com/forum/#!topic/flutter-announce/LXAL4RjbkT0.

Copy link
Contributor

@amirh amirh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

One caveat is the discussion we had offline regarding whether to keep frameInfos_ or not, since I can't currently tell which option is better I'm ok with both, but happy to take another look if you want to change that part.

@mklim
Copy link
Contributor Author

mklim commented May 9, 2019

One caveat is the discussion we had offline regarding whether to keep frameInfos_ or not, since I can't currently tell which option is better I'm ok with both, but happy to take another look if you want to change that part.

Talked to Skia and it sounds like we're not really saving anything by creating and managing the frameInfos_ vector ourselves. Added a commit where I swapped it out with calls to getFrameInfo(int frame, FrameInfo* frame) instead.

Michael Klimushyn added 3 commits May 13, 2019 10:34
Remove the extra `decodedCacheRatioCap` parameter, and the
`_frameBitmaps` member from `Codec`. This means that small looped images
will consume more CPU but prevents us from hitting OOM exceptions based
on trying to render multiple larger images.
Previously we looped over every single SkCodec::FrameInfo, tracked its
`fRequiredFrame`, and then saved any frames matching those indeces.
Doing this instead avoids that initialization loop and extra data
structure.
Also adds some missing `const`s.
@mklim mklim merged commit 14c82d9 into flutter:master May 13, 2019
@mklim mklim deleted the remove_cache branch May 13, 2019 18:18
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 13, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 13, 2019
engine-flutter-autoroll added a commit to flutter/flutter that referenced this pull request May 13, 2019
flutter/engine@f4d23ef...904cfc4

git log f4d23ef..904cfc4 --no-merges --oneline
904cfc4 Add @UiThread to MethodChannel and related classes/calls (#32642). (flutter/engine#8947)
c9406d4 Roll src/third_party/skia d696f8e6bca3..0221e8b22687 (5 commits) (flutter/engine#8948)
1b649a5 update docs (flutter/engine#8928)
47fd66c Terminate debug background task on expiry (flutter/engine#8930)
14c82d9 Only cache required frames (flutter/engine#8837)

The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md

If the roll is causing failures, please contact the current sheriff ([email protected]), and stop
the roller if necessary.
huqiuser pushed a commit to huqiuser/engine that referenced this pull request Jun 12, 2019
Remove the extra `decodedCacheRatioCap` parameter, and the
`_frameBitmaps` member from `Codec`. This means that small looped images
will consume more CPU but prevents us from hitting OOM exceptions based
on trying to render multiple larger images.

Also switch to fDisposalMethod for caching frames.

Previously we looped over every single SkCodec::FrameInfo, tracked its
`fRequiredFrame`, and then saved any frames matching those indeces.
Doing this instead avoids that initialization loop and extra data
structure.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove in memory decoded frame cache

3 participants