APNG is broken when processed

I’m using APNG lately. It finally enjoys excellent browser support and for certain screencasting applications it’s good enough (lossless and compact).

I’m running 2.2.0-beta2 and having an issue when embedding APNGs within posts.

APNGs are basically PNGs with additional block types. Applications which deal with PNG and are not (yet) aware of APNG can simply ignore those (and you’re left with a static image).

So, this is the behavior I’m experiencing:

  1. I create a post like this one and embed an APNG file, like this:
  2. preview shows it correctly (animated);
  3. I save the post;
  4. the post looks correct, with its APNGs being animated and all;
  5. I _just wait for a minute or so;
  6. I refresh the page;
  7. the post now has static PNGs instead;

So, I know what’s happening. A background job is generating multiple versions of uploads, so a lower-bandwidth, optimized version of the image is used subsequently.

Looks like this is not happening in this installation. Maybe this is newer or there’s something

  1. uploaded: https://assets-meta-cdck-prod-meta.s3.dualstack.us-west-1.amazonaws.com/original/3X/c/6/c678f1d99ef6278f5293bc844efa6e52913abd98.png
  2. processed: https://d11a6trkgmumsb.cloudfront.net/original/3X/c/6/c678f1d99ef6278f5293bc844efa6e52913abd98.png

image_optim fixes this regression in 1.5.0, by ignoring APNGs altogether [1], but discourse_image_optim does not have that merged (it’s 2 years old).

[1] APNG are convented to static PNG · Issue #142 · toy/image_optim · GitHub


I think the reason this bug is not triggered in this installation is because of the CDN.

Could it be that Discourse is disabling optimization when configured to use a CDN?

Are you on latest discourse? When did you rebuild your container last?