-
Notifications
You must be signed in to change notification settings - Fork 75
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
Apng fails to render with versions newer then 2.23.0 #188
Comments
device-2023-07-07-120042.mp4 |
I use latest code to animate this image, it seems to work normally |
Sorry, this isn't fixed in 2.26.0, I still see this same problem in Tusky. It's tricky to track down because I can't easily build APNG4Android locally (I'll file a separate issue for that with more details), but I've tracked this down to a difference in the bitmap sizes in In 2.23.0 (which works), if I debug In 2.24.0 and above (which doesn't work) the dimensions of The native dimensions of the source PNG file are 128 x 128 x 32bpp. |
e8f8fd3 is the problematic commit. If I revert that then Tusky displays the animated PNG correctly. That commit was to fix #165 Tusky's code to get and display the animated PNG is https://github.com/tuskyapp/Tusky/blob/develop/app/src/main/java/com/keylesspalace/tusky/util/CustomEmojiHelper.kt. The image is being loaded in to a drawable that will be displayed as a Span. The Span ( I'll keep looking... |
Can you provide me a demo project with the related images? |
I can, but I think I've found the bug. I think there's a race condition between This race happens in 1 public void setBounds(int left, int top, int right, int bottom) {
2 super.setBounds(left, top, right, bottom);
3 boolean sampleSizeChanged = frameSeqDecoder.setDesiredSize(getBounds().width(), getBounds().height());
4 matrix.setScale(
5 1.0f * getBounds().width() * frameSeqDecoder.getSampleSize() / frameSeqDecoder.getBounds().width(),
6 1.0f * getBounds().height() * frameSeqDecoder.getSampleSize() / frameSeqDecoder.getBounds().height());
7
8 if (sampleSizeChanged)
9 this.bitmap = Bitmap.createBitmap(
10 frameSeqDecoder.getBounds().width() / frameSeqDecoder.getSampleSize(),
11 frameSeqDecoder.getBounds().height() / frameSeqDecoder.getSampleSize(),
12 Bitmap.Config.ARGB_8888);
13 } Line 3 checks to see if the sample size has changed by calling If it has changed it calls This worked before e8f8fd3 because After that commit 1 public boolean setDesiredSize(int width, int height) {
2 boolean sampleSizeChanged = false;
3 final int sample = getDesiredSample(width, height);
4 if (sample != this.sampleSize) {
5 sampleSizeChanged = true;
6 final boolean tempRunning = isRunning();
7 workerHandler.removeCallbacks(renderTask);
8 workerHandler.post(new Runnable() {
9 @Override
10 public void run() {
11 innerStop();
12 try {
13 sampleSize = sample;
14 initCanvasBounds(read(getReader(mLoader.obtain())));
15 if (tempRunning) {
16 innerStart();
17 }
18 } catch (IOException e) {
19 e.printStackTrace();
20 }
21 }
22 });
23 }
24 return sampleSizeChanged;
25 }
There's the race condition -- |
I think you should not mannually call setBounds or trigger it at any time, like this issue: #182 . Inappropriate call or invoke on it may cause issue |
Yes, calling But the race condition didn't exist in 2.23.0. And expecting to be able to call The problem this was supposed to fix was described in #165. Unfortunately, Google Translate is not providing enough information that I can understand the original problem, and why changing If you could explain the original problem from #165 I might be able to suggest an alternative fix that doesn't have this race condition. |
This is still a problem for us @jingpeng @penfeizhou |
New Issue Checklist
Issue Info
Issue Description and Steps
This apng fails to load on version 2.24.0 and 2.25.0. The console is spammed with
FrameAnimationDrawable onRender:Buffer not large enough for pixels
. When I tell Glide to load the image with smaller dimensions, it renders, but has completely wrong dimensions. Screenshots and additional info can be found in our issue: tuskyapp/Tusky#3631When I downgrade to 2.23.0, it works just fine.
The text was updated successfully, but these errors were encountered: