xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.63k stars 1.87k forks source link

[Bug] Animations are not working in 4.2.0.709249 #7291

Closed Nullstr1ng closed 5 years ago

Nullstr1ng commented 5 years ago

Description

I have some part of my apps that animates. Fading in and out and translating from A to B. They are all working in 4.1.0.673156 but after upgrading to 4.2.0.709249, animations are not working anymore. FadeTo and TranslateTo are getting called when debugging. But no animations are happening.

Steps to Reproduce

Use Xamarin.Forms version 4.1.0.673156 and have some small animations like FadeTo and TranslateTo then upgrade to the latest version: 4.2.0.709249

Expected Behavior

It should animate

Actual Behavior

It's not animating

Basic Information

Screenshots

n/a

Reproduction Link

n/a

Nullstr1ng commented 5 years ago

In version 4.1.0.709244 - The animations are also working. So I'll stick with that version for the mean time until it's fixed in 4.2.0.X

jfversluis commented 5 years ago

Could you please see if #7255 describes your issue?

Nullstr1ng commented 5 years ago

The same I guess but in my code, I am using these

GridCoursePreview.FadeTo(1, 300, Easing.CubicInOut);
await GridCoursePreview.TranslateTo(0, 0, 300, Easing.CubicInOut);

That let's my Grid fade in and scroll up fast when previewing a Course full description and same FadeTo and TranslateTo methods are used to close the Grid control.

anim_prev

I can only test in my actual device running Android 8.1 API 27 and Emulator which runs the same versions.

lassana commented 5 years ago

Same problem, animations are completely broken on Android.

Codelisk commented 5 years ago

Same problem for me. Animations completely disappeared at Android 9 with 4.3.0.1099-nightly.

KSemenenko commented 5 years ago

Same problem

mkieres commented 5 years ago

Yep, not working for me either

Nullstr1ng commented 5 years ago

anyone got a workaround for this in version 4.2.0.709249 ? I need the Scrolled event in CollectionView which is only available in 4.2.0.709249

jfversluis commented 5 years ago

@Nullstr1ng Not one I'm aware of at this point, sorry. I see the fix is merged into 4.2 so a new release with the fix should be here in a reasonable amount of time.

petermajor commented 5 years ago

@Nullstr1ng

Yes. If you're desperate, you can use reflection:

public static class ReflectionExtensions
    {
        static readonly Lazy<FieldInfo> _androidTicker_AnimatorEnabled;

        static ReflectionExtensions()
        {
            _androidTicker_AnimatorEnabled = new Lazy<FieldInfo>(Get_AndroidTicker_AnimatorEnabled);
        }

        static FieldInfo Get_AndroidTicker_AnimatorEnabled()
        {
            var type = Type.GetType("Xamarin.Forms.Platform.Android.AndroidTicker, Xamarin.Forms.Platform.Android", true);
            var fieldInfo = type.GetField("_animatorEnabled", BindingFlags.NonPublic | BindingFlags.Instance);
            return fieldInfo;
        }

        // Fix for https://github.com/xamarin/Xamarin.Forms/issues/7291
        public static void AndroidTicker_SetAnimatorEnabled()
        {
            try
            {
                var fieldInfo = _androidTicker_AnimatorEnabled.Value;
                fieldInfo.SetValue(Ticker.Default, true);
            }
            catch
            {
                Console.WriteLine("Error setting AndroidTicker._animatorEnabled via reflection.");
            }
        }
    }
mdbill commented 5 years ago

Some animations fixed, but still broken in 4.2.0.778463 I have a visual.Rotateto and visualTranslateto. One or both of those is not working.

BioTurboNick commented 5 years ago

@samhouts Animations not working on 4.2.0.778463. It's like they are jumping to their end state and staying there, regardless of the other settings for the animation.

This is on Android 9.0, Samsung Galaxy S9+.

The workaround with developer options doesn't seem to work.

BioTurboNick commented 5 years ago

Nevermind, apparently it was caused by power saving mode! @mdbill

jfversluis commented 5 years ago

@mdbill could you confirm that for you it also had to do with the power saving mode?

mdbill commented 5 years ago

It's not power saving mode for me. I downgrade to 4.1 and it works again. I'm using an 8.1 emulator and android 7 device.

maexsp commented 5 years ago

It is fixed with 4.3.0.778476-pre1. I´ve tested it on Samsung tablet and Huawai phone, iPad and UWP! It was not a power saving issue. Thanks for the fix Xamarin-Team.

jfversluis commented 5 years ago

That is great to hear @maexsp! Thanks!

@mdbill sorry to bother you once again but would it be possible to try 4.3-pre1 to see if that fixes your issue?

mdbill commented 5 years ago

Yes, fixes my issue. Thanks!

DanKyungu commented 5 years ago

I Confirm, it's fixed ! Thx