Skip to content
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

[canvaskit] Add animation detection for GIFs #54483

Merged

Conversation

harryterkelsen
Copy link
Contributor

Detect if a GIF is animated to determine if we need to use Skia to decode it or if we can use tag decoding.

Fixes flutter/flutter#151911

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added the platform-web Code specifically for the web engine label Aug 9, 2024
@kevmoo
Copy link
Contributor

kevmoo commented Aug 9, 2024

Nit: I wish the source pointed to some docs about how this all was interpreted.

Would ease maintenance later.

@harryterkelsen
Copy link
Contributor Author

I linked to the GIF 89a spec in the doc comment for the class. Unfortunately since it's a text file I can't link to specific sections corresponding to the methods, but I stick to the terminology in the spec so the sections should be easy to find if you have the spec open.

Copy link
Contributor

@mdebbar mdebbar left a comment

Choose a reason for hiding this comment

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

LGTM!

return chunkFourCC == expectedHeader;
}

/// Reads the WebP header. Returns [false] if this is not a valid WebP header.
bool _readWebpHeader() {
final String riffBytes = _readFourCC();

// Read file size byte.
_readUint32();
// Skip reading file size byte.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
// Skip reading file size byte.
// Skip reading file size bytes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@harryterkelsen harryterkelsen added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 13, 2024
@auto-submit auto-submit bot merged commit 2fcb51a into flutter:main Aug 13, 2024
29 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 14, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 14, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 14, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 14, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Aug 14, 2024
…sions) (#153413)

Manual roll requested by zra@google.com

flutter/engine@019f9e3...5909666

2024-08-14 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Roll Dart SDK from 44635f897535 to 733062367c2e (1 revision) (#54541)" (flutter/engine#54552)
2024-08-14 98614782+auto-submit[bot]@users.noreply.github.com Reverts "macOS: Clean up create_ios_framework.py (#54543)" (flutter/engine#54550)
2024-08-14 98614782+auto-submit[bot]@users.noreply.github.com Reverts "macOS: refactor create_macos_framework.py (#54546)" (flutter/engine#54549)
2024-08-14 chris@bracken.jp macOS: refactor create_macos_framework.py (flutter/engine#54546)
2024-08-13 flar@google.com [DisplayList] Allow random access to ops through indexing (flutter/engine#54484)
2024-08-13 mit@google.com Update dartdoc for gpu.dart (flutter/engine#54529)
2024-08-13 chris@bracken.jp macOS: Clean up create_ios_framework.py (flutter/engine#54543)
2024-08-13 skia-flutter-autoroll@skia.org Roll Dart SDK from 44635f897535 to 733062367c2e (1 revision) (flutter/engine#54541)
2024-08-13 skia-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 2LTVy4Gv76DcMpz4V... to MeV5i7xXXFPHF5sBK... (flutter/engine#54542)
2024-08-13 1961493+harryterkelsen@users.noreply.github.com [canvaskit] Add animation detection for GIFs (flutter/engine#54483)
2024-08-13 matej.knopp@gmail.com Preserve background frame damage (flutter/engine#54540)
2024-08-13 68449066+zijiehe-google-com@users.noreply.github.com [fuchsia] Use BundledTestRunner from test-scripts (flutter/engine#54404)

Also rolling transitive DEPS:
  fuchsia/sdk/core/linux-amd64 from 2LTVy4Gv76Dc to MeV5i7xXXFPH

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
DBowen33 pushed a commit to DBowen33/flutter that referenced this pull request Aug 16, 2024
…sions) (flutter#153413)

Manual roll requested by zra@google.com

flutter/engine@019f9e3...5909666

2024-08-14 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Roll Dart SDK from 44635f897535 to 733062367c2e (1 revision) (flutter#54541)" (flutter/engine#54552)
2024-08-14 98614782+auto-submit[bot]@users.noreply.github.com Reverts "macOS: Clean up create_ios_framework.py (flutter#54543)" (flutter/engine#54550)
2024-08-14 98614782+auto-submit[bot]@users.noreply.github.com Reverts "macOS: refactor create_macos_framework.py (flutter#54546)" (flutter/engine#54549)
2024-08-14 chris@bracken.jp macOS: refactor create_macos_framework.py (flutter/engine#54546)
2024-08-13 flar@google.com [DisplayList] Allow random access to ops through indexing (flutter/engine#54484)
2024-08-13 mit@google.com Update dartdoc for gpu.dart (flutter/engine#54529)
2024-08-13 chris@bracken.jp macOS: Clean up create_ios_framework.py (flutter/engine#54543)
2024-08-13 skia-flutter-autoroll@skia.org Roll Dart SDK from 44635f897535 to 733062367c2e (1 revision) (flutter/engine#54541)
2024-08-13 skia-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 2LTVy4Gv76DcMpz4V... to MeV5i7xXXFPHF5sBK... (flutter/engine#54542)
2024-08-13 1961493+harryterkelsen@users.noreply.github.com [canvaskit] Add animation detection for GIFs (flutter/engine#54483)
2024-08-13 matej.knopp@gmail.com Preserve background frame damage (flutter/engine#54540)
2024-08-13 68449066+zijiehe-google-com@users.noreply.github.com [fuchsia] Use BundledTestRunner from test-scripts (flutter/engine#54404)

Also rolling transitive DEPS:
  fuchsia/sdk/core/linux-amd64 from 2LTVy4Gv76Dc to MeV5i7xXXFPH

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Buchimi pushed a commit to Buchimi/flutter that referenced this pull request Sep 2, 2024
…sions) (flutter#153413)

Manual roll requested by zra@google.com

flutter/engine@019f9e3...5909666

2024-08-14 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Roll Dart SDK from 44635f897535 to 733062367c2e (1 revision) (flutter#54541)" (flutter/engine#54552)
2024-08-14 98614782+auto-submit[bot]@users.noreply.github.com Reverts "macOS: Clean up create_ios_framework.py (flutter#54543)" (flutter/engine#54550)
2024-08-14 98614782+auto-submit[bot]@users.noreply.github.com Reverts "macOS: refactor create_macos_framework.py (flutter#54546)" (flutter/engine#54549)
2024-08-14 chris@bracken.jp macOS: refactor create_macos_framework.py (flutter/engine#54546)
2024-08-13 flar@google.com [DisplayList] Allow random access to ops through indexing (flutter/engine#54484)
2024-08-13 mit@google.com Update dartdoc for gpu.dart (flutter/engine#54529)
2024-08-13 chris@bracken.jp macOS: Clean up create_ios_framework.py (flutter/engine#54543)
2024-08-13 skia-flutter-autoroll@skia.org Roll Dart SDK from 44635f897535 to 733062367c2e (1 revision) (flutter/engine#54541)
2024-08-13 skia-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 2LTVy4Gv76DcMpz4V... to MeV5i7xXXFPHF5sBK... (flutter/engine#54542)
2024-08-13 1961493+harryterkelsen@users.noreply.github.com [canvaskit] Add animation detection for GIFs (flutter/engine#54483)
2024-08-13 matej.knopp@gmail.com Preserve background frame damage (flutter/engine#54540)
2024-08-13 68449066+zijiehe-google-com@users.noreply.github.com [fuchsia] Use BundledTestRunner from test-scripts (flutter/engine#54404)

Also rolling transitive DEPS:
  fuchsia/sdk/core/linux-amd64 from 2LTVy4Gv76Dc to MeV5i7xXXFPH

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[canvaskit] Determine if image is animated by reading its header and use Skia to decode in that case
3 participants