-
Notifications
You must be signed in to change notification settings - Fork 639
[Drawable Painter] Fix AnimatedImageDrawable rendered in wrong size for systems below Android 12 #1817
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
Conversation
@bentrengrove Hello. We are affected by this problem pretty seriously because we use a lot of animated webp images in our app. Coil is using DrawablePaint for Drawables. We now use a custom version of AsyncImage and in it we use a modified DrawablePainter, but people can easily forget about the problem and use the vanilla AsyncImage which still have the problem. Thanks in advance. |
Unfortunately, this is intentional behaviour. I suggest forking this implementation if that is what is required for your use case, we couldn't ship this because we would suddenly be scaling every drawable. This was previously closed here https://github.com/google/accompanist/pull/1771/files |
@bentrengrove How about adding condition to apply this only for AnimatedImageDrawable on systems below Android 12? This is definitely wrong rendering behavior and not intentional. The root cause is in the framework base, but that's not something we can change now. Otherwise, I can only suggest coil to make a fork and fix this, and I don't think the position off is intentional, although it's AnimatedImageDrawable who was not following the spec. |
OK. Yes, I would accept a PR that only applied this workaround as you describe. On Android <12 and for AnimatedImageDrawable. Would you be willing to make those changes? |
No problem. I will make that change today. Thank you very much for considering this!!! |
I've made the changes. Let me know if anything should be further adjusted. Thanks |
Looks like you just have spotless errors
|
Head branch was pushed to by a user without write access
Okay. It's done. |
This has been released as 0.37.3 |
thank you!! ❤️ |
AnimatedImageDrawable doesn't respect bounds set to it when the Android version is below 12.
On Android version below 12, if we use the current way to render (setBounds), the size doesn't change with the container at all. It's always following intrinsic size which is wrong.
I've created a sample project for you to test it out.
issue-demo-animated-image-drawable.zip
Also, you can see from following videos to understand the issue.
Tested on Android 10
android.10.11.result.mov
Tested on Android 12
android.12.result.mov
Following is the commit in AOSP to add setBounds to AnimatedImageDrawable.
https://cs.android.com/android/_/android/platform/frameworks/base/+/be969efdb0234b7b39636ec0a586dbb708ec480d
This first appeared in android-12.0.0_r1, and this is the proof.
