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

Gif Animation Support #7330

Merged
merged 37 commits into from Nov 21, 2019
Merged

Gif Animation Support #7330

merged 37 commits into from Nov 21, 2019

Conversation

@PureWeen
Copy link
Contributor

PureWeen commented Aug 30, 2019

Description of Change

Adds basic GIF image animation support on UWP/IOS/Android. NOTE, according to issue this implementation intends to target small animated GIF's meaning that current implementation does NOT include support for caching or streaming. This could of course be added in future if needed and some preparations have been done to support streaming in implemented GIF decoder.

Implementation on UWP uses OS support for animated GIF's included in 1607 (anniversary update) or later. No support added to previous versions. The minimum UWP version supported by Xamarin Forms (master branch) should be 1607.

Implementation on IOS uses IOS GIF parser and key frame animations to present correctly timed key frames to image control.

Implementation on Android includes GIF parser used to parse, decode and create bitmaps from encoded in GIF sources. Implementation uses AnimationDrawable to present correctly timed animation buffers to image control. GIFs are currently only enabled on FastRenderers so if you have the Legacy Renderers flag set then GIFs won't play

Issues Resolved

API Changes

New animation properties and methods on Image:

public bool IsAnimationPlaying;

Starting and stopping is controlled through IsAnimationPlaying. Originally we were going to use Start and Stop methods but all these did was set IsAnimationPlaying to true or false respectively. This way it can also be started and stopped via Binding!!

Behavioral Changes

Nothing, if the animation auto play property has not been set then images will be loaded normal. Trying to use animation support on none GIF image sources will fail the load and fallback trying to load as regular image (Android) or as a 1 frame keyframe animation (IOS).

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard
  • Consolidate commits as makes sense
@samhouts samhouts added this to In Progress in vCurrent (4.4.0) Aug 30, 2019
@PureWeen PureWeen changed the title [WiP] Gif animations Gif Animation Support Aug 30, 2019
@PureWeen PureWeen marked this pull request as ready for review Aug 30, 2019
@PureWeen PureWeen requested a review from StephaneDelcroix as a code owner Aug 30, 2019
@PureWeen PureWeen mentioned this pull request Aug 30, 2019
4 of 4 tasks complete
@samhouts samhouts moved this from In Progress to In Review in vCurrent (4.4.0) Aug 30, 2019
@samhouts samhouts added this to Ready for Review (PRs) in Sprint 158 Aug 30, 2019
@samhouts samhouts added the inactive label Aug 30, 2019
@samhouts samhouts moved this from In Review to In Progress in vCurrent (4.4.0) Aug 30, 2019
@samhouts samhouts moved this from Ready for Review (PRs) to In progress in Sprint 158 Aug 30, 2019
@samhouts samhouts added the inactive label Aug 31, 2019
@PureWeen PureWeen removed the inactive label Sep 3, 2019
@samhouts samhouts added API-change Core and removed Core labels Sep 4, 2019
@PureWeen PureWeen force-pushed the gif_animations branch from e5599fd to a2fe1f3 Nov 19, 2019
@PureWeen PureWeen changed the base branch from master to 4.4.0 Nov 19, 2019
@PureWeen

This comment has been minimized.

Copy link
Contributor Author

PureWeen commented Nov 19, 2019

Rebased

Kicked off build

@PureWeen PureWeen force-pushed the gif_animations branch from d6c9d2d to 57b8ed6 Nov 20, 2019
@samhouts samhouts added the blocker label Nov 21, 2019
@PureWeen PureWeen merged commit d012853 into 4.4.0 Nov 21, 2019
11 of 12 checks passed
11 of 12 checks passed
xamarin-forms-uitests xamarin-forms-uitests in progress
Details
iOS11 uitests
Details
iOS11-ISSUES uitests
Details
iOS11-MANUAL uitests
Details
iOS12 uitests
Details
iOS12-ISSUES uitests
Details
iOS12-MANUAL uitests
Details
iOS13 uitests
Details
iOS13-ISSUES uitests
Details
iOS13-MANUAL uitests
Details
license/cla All CLA requirements met.
Details
xamarin-forms-ci #4.4.0.936708+0-pr.7330-sha.e28a85625-azdo.10110 succeeded
Details
vNext (4.5.0) automation moved this from In Progress to Done Nov 21, 2019
Sprint 162 automation moved this from Ready for Review (PRs) to Done Nov 21, 2019
@PureWeen PureWeen deleted the gif_animations branch Nov 21, 2019
@samhouts samhouts removed this from Done in vNext (4.5.0) Nov 22, 2019
@samhouts samhouts added this to Done in vCurrent (4.4.0) Nov 22, 2019
@samhouts samhouts added this to the 4.4.0 milestone Nov 26, 2019
felipebaltazar added a commit to felipebaltazar/Xamarin.Forms that referenced this pull request Dec 1, 2019
* Add image animation API.

* Add animated image tests.

* Add animated image UWP implementation.

* Add animated image IOS implementation.

* Add animated image Android implementation.

Also include GIF image parser base class + android parser sub class.

* Add animation finished playing event to Android/IOS for image.

* Add fallback when loading none GIF as animation image.

* Adding a couple of additional tests for animated images.

* Adjusting image animation support based on PR feedback.

* Add support to reload as animated image on StartAnimation call.

* Add UITest and activity indicator when loading from source for Issue1704.

* Reduce number of temporary bitmaps when scaling.

* Implemented review feedback.

* Animation problems related to Android API level 19 and earlier
due to a couple of bugs and changed behavior in AnimationDrawable class.
Implemented a couple of fixes and workaround related to these bugs, fixing
the animation issues on devices before Android Lollipop.

* Moved a couple of methods implemented in FormsAnimationDrawable into an
interface that is used to hide implementation details. Enables possibility
to factor different implementations of animation support going forward.

* Fixed review feedback and comments.

* Notify IOS to redraw control when changing animation layer.

* - android rebase fixes

* - first set of iOS changes for gifs

* - uwp Gif changes

* - clean up android gif code and enable gif for ImageButtons

* - cleanup iOS gif implementation

* - fix imagebutton and other sources

* - add imagebutton to tests

* - getting rid of start/stop and just using IsAnimationPlaying

* - image button

* - adding animation handler for android

* - replace gifs

* - fix rebase issues

* Added gif samples in Core Gallery

* Updated gif Core Gallery sample

* Fixed UWP gif samples path

* - remove auto play
- fix uwp so it plays correctly on load

* Added support to Url gifs on Android

* - fix rebase

* - fix NRE and iOS repeat

* - fix android loop counter

* - fix animation stopped on ios

* - fix removed ImageHandler interface Android

* - add top margin so ui tests can click button
jonathanpeppers added a commit to jonathanpeppers/Xamarin.Forms that referenced this pull request Dec 13, 2019
Context: https://github.com/jonathanpeppers/glidex/tree/xf-4.4

In the linked sample, the `xf-4.4` branch, I am getting this exception
in the log for any `ImageCell` and no image loads:

    [0:] BaseCellView: Error loading image: System.NullReferenceException: Object reference not set to an instance of an object.
      at Xamarin.Forms.Platform.Android.ImageViewExtensions.UpdateBitmap (Android.Widget.ImageView imageView, Xamarin.Forms.IImageElement newView, Xamarin.Forms.IImageElement previousView, Xamarin.Forms.ImageSource newImageSource, Xamarin.Forms.ImageSource previousImageSource) [0x000f8] in D:\a\1\s\Xamarin.Forms.Platform.Android\Extensions\ImageViewExtensions.cs:49
      at Xamarin.Forms.Platform.Android.BaseCellView.UpdateBitmap (Xamarin.Forms.ImageSource source, Xamarin.Forms.ImageSource previousSource) [0x0003a] in D:\a\1\s\Xamarin.Forms.Platform.Android\Cells\BaseCellView.cs:195

Looking at the exact line:

https://github.com/xamarin/Xamarin.Forms/blob/10dafc5dcddede946163a1fd83d7feaac8021e1b/Xamarin.Forms.Platform.Android/Extensions/ImageViewExtensions.cs#L49

It looks like there is a missing null check, and this probably only
happens for `ImageCell`?

It looks like this might have been introduced with:

xamarin#7330
samhouts added a commit that referenced this pull request Dec 17, 2019
Context: https://github.com/jonathanpeppers/glidex/tree/xf-4.4

In the linked sample, the `xf-4.4` branch, I am getting this exception
in the log for any `ImageCell` and no image loads:

    [0:] BaseCellView: Error loading image: System.NullReferenceException: Object reference not set to an instance of an object.
      at Xamarin.Forms.Platform.Android.ImageViewExtensions.UpdateBitmap (Android.Widget.ImageView imageView, Xamarin.Forms.IImageElement newView, Xamarin.Forms.IImageElement previousView, Xamarin.Forms.ImageSource newImageSource, Xamarin.Forms.ImageSource previousImageSource) [0x000f8] in D:\a\1\s\Xamarin.Forms.Platform.Android\Extensions\ImageViewExtensions.cs:49
      at Xamarin.Forms.Platform.Android.BaseCellView.UpdateBitmap (Xamarin.Forms.ImageSource source, Xamarin.Forms.ImageSource previousSource) [0x0003a] in D:\a\1\s\Xamarin.Forms.Platform.Android\Cells\BaseCellView.cs:195

Looking at the exact line:

https://github.com/xamarin/Xamarin.Forms/blob/10dafc5dcddede946163a1fd83d7feaac8021e1b/Xamarin.Forms.Platform.Android/Extensions/ImageViewExtensions.cs#L49

It looks like there is a missing null check, and this probably only
happens for `ImageCell`?

It looks like this might have been introduced with:

#7330
@rookiejava rookiejava mentioned this pull request Jan 2, 2020
0 of 2 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Sprint 158
  
Ready for Review (PRs)
Sprint 159
  
Continued in next sprint
Sprint 160
  
Continued in next sprint
Sprint 161
  
Continued in next sprint
Sprint 162
  
Done
5 participants
You can’t perform that action at this time.