From b0370c13c302bc747f0cb3736a3a79e79ae4f7cd Mon Sep 17 00:00:00 2001 From: Michael Klimushyn Date: Thu, 7 Feb 2019 14:47:23 -0800 Subject: [PATCH] Decode using the last cached required frame (#7715) `MultiFrameCodec` now uses whatever previously cached required frame is available instead of panicking if it doesn't have the exact frame requested by `SkCodec::FrameInfo#fRequiredFrame`. `SkCodec::FrameInfo#fRequiredFrame` doesn't point to the one and only frame that's required to decode the given frame. It points to the latest frame that's disposal method none and filling a greater surface area than the current frame. The last required frame `MultiFrameCodec` has actually cached is also valid in these cases and can be supplied as `fPriorFrame` instead. [flutter/flutter#26757](https://github.com/flutter/flutter/issues/26757#issuecomment-459522530) has a more detailed explanation. Fixes flutter/flutter#26757 --- lib/ui/painting/codec.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ui/painting/codec.cc b/lib/ui/painting/codec.cc index 18e123d99..0555d8269 100644 --- a/lib/ui/painting/codec.cc +++ b/lib/ui/painting/codec.cc @@ -408,11 +408,15 @@ sk_sp MultiFrameCodec::GetNextFrameImage( options.fFrameIndex = nextFrameIndex_; const int requiredFrameIndex = frameInfos_[nextFrameIndex_].fRequiredFrame; if (requiredFrameIndex != SkCodec::kNoFrame) { - if (lastRequiredFrame_ == nullptr || - lastRequiredFrameIndex_ != requiredFrameIndex) { + if (lastRequiredFrame_ == nullptr) { FML_LOG(ERROR) << "Frame " << nextFrameIndex_ << " depends on frame " - << requiredFrameIndex << " which has not been cached."; + << requiredFrameIndex + << " and no required frames are cached."; return NULL; + } else if (lastRequiredFrameIndex_ != requiredFrameIndex) { + FML_DLOG(INFO) << "Required frame " << requiredFrameIndex + << " is not cached. Using " << lastRequiredFrameIndex_ + << " instead"; } if (lastRequiredFrame_->getPixels() && -- GitLab