Hi Team,
In the attached sample, we have tried to layout a child view (i.e., Content) of our custom view (i.e., ExtendedView) with two different animations i.e., Fade and Layout simultaneously using ValueAnimator in AnimatorSet. But unfortunately, when two different ValueAnimator animations are play together for a View or ViewGroup in AnimatorSet, reported exception gets thrown.
Note :
When we layout the child view from 0 position, reported issue is not replicated. It replicates only when we layout the view with some position. For example : 51 in the sample.
Refer the code snippet
this.Content.Layout(0, 51, this.Width, (int)this.animator.AnimatedValue);
Also, if we animate either one ValueAnimator or skip to update the Alpha value in FadeAnimator_Update method for the Content, exception is not thrown.
Refer the code snippet
this.Content.Alpha = (float)this.fadeAnimator.AnimatedValue;
`ExtendedFrameLayout.ApplyAnimation(0, 1000, true);`
` private FrameLayout Content { get; set; }`
`public void ApplyAnimation(int top, int bottom, bool isExpanded)
{
double animationDuration = 1000;
var contenttop = Resources.DisplayMetrics.HeightPixels;
this.fadeAnimator = isExpanded ? ValueAnimator.OfFloat(0.0f, 1.0f) : ValueAnimator.OfFloat(1.0f, 0.0f);
this.animator = isExpanded ? ValueAnimator.OfFloat(top + 1, bottom) : this.animator = ValueAnimator.OfFloat(top + contenttop, top);
this.animator.SetDuration((long)animationDuration);
this.animator.Update += this.Animator_Update;
this.fadeAnimator.SetDuration((long)animationDuration);
this.fadeAnimator.Update += this.FadeAnimator_Update;
var easingValue = new LinearInterpolator();
this.animator.SetInterpolator(easingValue);
this.fadeAnimator.SetInterpolator(easingValue);
this.animationSet = new AnimatorSet();
this.animationSet.PlayTogether(this.animator, this.fadeAnimator);
this.animationSet.Start();
}`
`private void FadeAnimator_Update(object sender, ValueAnimator.AnimatorUpdateEventArgs e)
{
this.Content.Alpha = (float)this.fadeAnimator.AnimatedValue;
}
private void Animator_Update(object sender, ValueAnimator.AnimatorUpdateEventArgs e)
{
this.Content.Layout(0, 51, this.Width, (int)this.animator.AnimatedValue);
}`
Apply Animation button.java.lang.IllegalStateException: Unable to create layer for FrameLayout, size 1088x0 max size 16384 color type 4 has context 1View need to be animated with both ValueAnimator as expected.
Exception throws when View is animated with two ValueAnimator.
10-03 14:26:36.704 E/OpenGLRenderer(20667): Font Cache (CPU):
10-03 14:26:36.704 E/OpenGLRenderer(20667): Size: 16.74 kB
10-03 14:26:36.704 E/OpenGLRenderer(20667): Glyph Count: 6
10-03 14:26:36.704 E/OpenGLRenderer(20667): CPU Caches:
10-03 14:26:36.704 E/OpenGLRenderer(20667): GPU Caches:
10-03 14:26:36.704 E/OpenGLRenderer(20667): Other:
10-03 14:26:36.704 E/OpenGLRenderer(20667): Buffer Object: 63.00 KB (2 entries)
10-03 14:26:36.704 E/OpenGLRenderer(20667): Image:
10-03 14:26:36.704 E/OpenGLRenderer(20667): Texture: 158.20 KB (1 entry)
10-03 14:26:36.704 E/OpenGLRenderer(20667): Scratch:
10-03 14:26:36.704 E/OpenGLRenderer(20667): Buffer Object: 64.00 KB (2 entries)
10-03 14:26:36.704 E/OpenGLRenderer(20667): Texture: 1.00 MB (1 entry)
10-03 14:26:36.704 E/OpenGLRenderer(20667): Other Caches:
10-03 14:26:36.704 E/OpenGLRenderer(20667): Current / Maximum
10-03 14:26:36.704 E/OpenGLRenderer(20667): VectorDrawableAtlas 0.00 kB / 0.00 KB (entries = 0)
10-03 14:26:36.704 E/OpenGLRenderer(20667): Layers Total 0.00 KB (numLayers = 0)
10-03 14:26:36.704 E/OpenGLRenderer(20667): Total GPU memory usage:
10-03 14:26:36.704 E/OpenGLRenderer(20667): 1340624 bytes, 1.28 MB (285.20 KB is purgeable)
10-03 14:26:36.705 D/AndroidRuntime(20667): Shutting down VM
10-03 14:26:36.707 E/AndroidRuntime(20667): FATAL EXCEPTION: main
10-03 14:26:36.707 E/AndroidRuntime(20667): Process: com.companyname, PID: 20667
10-03 14:26:36.707 E/AndroidRuntime(20667): java.lang.IllegalStateException: Unable to create layer for FrameLayout, size 1088x0 max size 16384 color type 4 has context 1
10-03 14:26:36.707 E/AndroidRuntime(20667): at android.os.MessageQueue.nativePollOnce(Native Method)
10-03 14:26:36.707 E/AndroidRuntime(20667): at android.os.MessageQueue.next(MessageQueue.java:326)
10-03 14:26:36.707 E/AndroidRuntime(20667): at android.os.Looper.loop(Looper.java:160)
10-03 14:26:36.707 E/AndroidRuntime(20667): at android.app.ActivityThread.main(ActivityThread.java:6762)
10-03 14:26:36.707 E/AndroidRuntime(20667): at java.lang.reflect.Method.invoke(Native Method)
10-03 14:26:36.707 E/AndroidRuntime(20667): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
10-03 14:26:36.707 E/AndroidRuntime(20667): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
10-03 14:26:36.716 E/OpenGLRenderer(20667): Font Cache (CPU):
10-03 14:26:36.716 E/OpenGLRenderer(20667): Size: 16.74 kB
10-03 14:26:36.716 E/OpenGLRenderer(20667): Glyph Count: 6
10-03 14:26:36.716 E/OpenGLRenderer(20667): CPU Caches:
10-03 14:26:36.716 E/OpenGLRenderer(20667): GPU Caches:
10-03 14:26:36.716 E/OpenGLRenderer(20667): Other:
10-03 14:26:36.716 E/OpenGLRenderer(20667): Buffer Object: 63.00 KB (2 entries)
10-03 14:26:36.716 E/OpenGLRenderer(20667): Image:
10-03 14:26:36.716 E/OpenGLRenderer(20667): Texture: 158.20 KB (1 entry)
10-03 14:26:36.716 E/OpenGLRenderer(20667): Scratch:
10-03 14:26:36.716 E/OpenGLRenderer(20667): Buffer Object: 64.00 KB (2 entries)
10-03 14:26:36.716 E/OpenGLRenderer(20667): Texture: 1.00 MB (1 entry)
10-03 14:26:36.716 E/OpenGLRenderer(20667): Other Caches:
10-03 14:26:36.716 E/OpenGLRenderer(20667): Current / Maximum
10-03 14:26:36.716 E/OpenGLRenderer(20667): VectorDrawableAtlas 0.00 kB / 0.00 KB (entries = 0)
10-03 14:26:36.716 E/OpenGLRenderer(20667): Layers Total 0.00 KB (numLayers = 0)
10-03 14:26:36.716 E/OpenGLRenderer(20667): Total GPU memory usage:
10-03 14:26:36.716 E/OpenGLRenderer(20667): 1340624 bytes, 1.28 MB (285.20 KB is purgeable)
10-03 14:26:36.732 E/OpenGLRenderer(20667): Font Cache (CPU):
10-03 14:26:36.732 E/OpenGLRenderer(20667): Size: 16.74 kB
10-03 14:26:36.732 E/OpenGLRenderer(20667): Glyph Count: 6
10-03 14:26:36.732 E/OpenGLRenderer(20667): CPU Caches:
10-03 14:26:36.732 E/OpenGLRenderer(20667): GPU Caches:
10-03 14:26:36.732 E/OpenGLRenderer(20667): Other:
10-03 14:26:36.732 E/OpenGLRenderer(20667): Buffer Object: 63.00 KB (2 entries)
10-03 14:26:36.732 E/OpenGLRenderer(20667): Image:
10-03 14:26:36.732 E/OpenGLRenderer(20667): Texture: 158.20 KB (1 entry)
10-03 14:26:36.732 E/OpenGLRenderer(20667): Scratch:
10-03 14:26:36.732 E/OpenGLRenderer(20667): Buffer Object: 64.00 KB (2 entries)
10-03 14:26:36.732 E/OpenGLRenderer(20667): Texture: 1.00 MB (1 entry)
10-03 14:26:36.732 E/OpenGLRenderer(20667): Other Caches:
10-03 14:26:36.732 E/OpenGLRenderer(20667): Current / Maximum
10-03 14:26:36.732 E/OpenGLRenderer(20667): VectorDrawableAtlas 0.00 kB / 0.00 KB (entries = 0)
10-03 14:26:36.732 E/OpenGLRenderer(20667): Layers Total 0.00 KB (numLayers = 0)
10-03 14:26:36.732 E/OpenGLRenderer(20667): Total GPU memory usage:
10-03 14:26:36.732 E/OpenGLRenderer(20667): 1340624 bytes, 1.28 MB (285.20 KB is purgeable)
Unhandled Exception:
Java.Lang.IllegalStateException:
10-03 14:26:36.883 I/chatty (20667): uid=10811(com.companyname) RenderThread identical 9 lines
10-03 14:26:36.900 E/OpenGLRenderer(20667): Font Cache (CPU):
10-03 14:26:36.900 E/OpenGLRenderer(20667): Size: 16.74 kB
10-03 14:26:36.900 E/OpenGLRenderer(20667): Glyph Count: 6
10-03 14:26:36.900 E/OpenGLRenderer(20667): CPU Caches:
10-03 14:26:36.900 E/OpenGLRenderer(20667): GPU Caches:
10-03 14:26:36.900 E/OpenGLRenderer(20667): Other:
10-03 14:26:36.900 E/OpenGLRenderer(20667): Buffer Object: 63.00 KB (2 entries)
10-03 14:26:36.900 E/OpenGLRenderer(20667): Image:
10-03 14:26:36.900 E/OpenGLRenderer(20667): Texture: 158.20 KB (1 entry)
10-03 14:26:36.900 E/OpenGLRenderer(20667): Scratch:
10-03 14:26:36.900 E/OpenGLRenderer(20667): Buffer Object: 64.00 KB (2 entries)
10-03 14:26:36.900 E/OpenGLRenderer(20667): Texture: 1.00 MB (1 entry)
10-03 14:26:36.900 E/OpenGLRenderer(20667): Other Caches:
10-03 14:26:36.900 E/OpenGLRenderer(20667): Current / Maximum
10-03 14:26:36.900 E/OpenGLRenderer(20667): VectorDrawableAtlas 0.00 kB / 0.00 KB (entries = 0)
10-03 14:26:36.900 E/OpenGLRenderer(20667): Layers Total 0.00 KB (numLayers = 0)
10-03 14:26:36.900 E/OpenGLRenderer(20667): Total GPU memory usage:
10-03 14:26:36.900 E/OpenGLRenderer(20667): 1340624 bytes, 1.28 MB (285.20 KB is purgeable)
Video :
7791- Video.zip
Sample :
7791 - Sample.zip
Note : I work for Syncfusion. We are experiencing the reported issue in our Expander control.
@DineshBabuYadav I don't feel like this is a XF issue but just a native android issue since your reproduction isn't really using any Forms elements. It's just a renderer that subclasses a native FrameLayout
This not so helpful SO post
https://stackoverflow.com/questions/53088846/java-lang-illegalstateexception-unable-to-create-layer-for-linearlayout-size-0/53098943
Shows someone else having this issue
If I slightly modify the code to queue those settings to the UI Thread
```C#
private void FadeAnimator_Update(object sender, ValueAnimator.AnimatorUpdateEventArgs e)
{
Device.BeginInvokeOnMainThread(() =>
{
System.Diagnostics.Debug.WriteLine("FadeAnimator_Update " + (int)this.animator.AnimatedValue);
this.Content.Alpha = (float)this.fadeAnimator.AnimatedValue;
});
}
private void Animator_Update(object sender, ValueAnimator.AnimatorUpdateEventArgs e)
{
Device.BeginInvokeOnMainThread(() =>
{
System.Diagnostics.Debug.WriteLine("Animated Value : " + (int)this.animator.AnimatedValue);
this.Content.Layout(0, 51, this.Width, (int)this.animator.AnimatedValue);
});
}
```
then it doesn't crash. So I think this is more an Android API 28 native crash and not really something forms can address
Let me know if I missed something please and I can reopen
@PureWeen , i tried with your suggestion i.e., updating the values in UI thread. But it doesn't work. I tried the same behaviour in Xamarin Android similar scenario. And it works as expected. Can you suggest any solution on this?
Can you suggest any solution on this?
If you add a delay does it still crash?
```C#
Device.BeginInvokeOnMainThread(async () =>
{
await Task.Delay(1000)
System.Diagnostics.Debug.WriteLine("Animated Value : " + (int)this.animator.AnimatedValue);
this.Content.Layout(0, 51, this.Width, (int)this.animator.AnimatedValue);
});
```
@PureWeen , we are facing this issue in our source i.e., SfExpander control. And we have replicated this issue in a simple sample for better understanding. And we can't able to add delay manually in our source which will affect other cases.
Yea it's more to just arrive at a non crashing scenario then work backwards. The fact that this doesn't crash in pre 28 APIs and that this is all renderer side tells me that this is something that's not Forms related. Also I copied the ExtendedFrameLayout into a Native Android Project and was able to reproduce the same exception

@PureWeen , yeah i agree with you. Its not related with XForms. Can you share me the sample? which you have replicated in native project which'll be useful for me to check with the team.
@PureWeen , Thanks. Can you please share me the link where i can log this bug report and get the further updates?
@DineshBabuYadav I don't follow what you're asking.
If you think this is a bug with Android I'd log it here
https://source.android.com/setup/contribute/report-bugs
@PureWeen , thanks 馃憤 . Someone already created a bug report. I have commented in the same.