I've deployed my app to fly.io and found an interesting error that only affects production. The same gif doesn't cause this issue using local storage. The gif is uploaded to AWS S3
First I get the VIPs-Warning ** error in tile 0 x 1104 Followed by ActionView::Template::Error (gifload: Image EOF detected before image complete
Here's the code I'm using to load the image:
<% if post.images.attached? %>
<% post.images.each do |image| %>
<%= image_tag image.representation(loader: { n: -1 }, resize_to_fit: [400, nil]).processed, class: "img-fluid" %>
<% end %>
Here's the gif in question, I don't see anything particularly special or weird about it and my other gifs that are larger, wider, and taller, don't cause the app to crash. Is there a way to rescue a failed gif load with Active Storage?
I've tried adding these lines:
<% if post.images.attached? %>
<% post.images.each do |image| %>
<%= image_tag image.representation(loader: { n: -1 }, resize_to_fit: [400, nil]).processed, class: "img-fluid", onerror: "this.style.display='none'" %>
<% end %>
This didn't fix anything when I redeployed the site
<% if post.images.attached? %>
<% post.images.each do |image| %>
<%= image_tag image.representation(loader: { n: -1 }, resize_to_fit: [400, nil]).processed, class: "img-fluid", rescue nil %>
<% end %>
This causes a syntax error. Clearly there's an issue with vips and I found an old thread about it, but no solution on how to deal with it: https://github.com/libvips/libvips/issues/1701
I've tested uploading and loading the gif with AWS in development and there hasn't been an issue.