提问人:AndyDaMandy 提问时间:3/18/2023 最后编辑:AndyDaMandy 更新时间:3/25/2023 访问量:144
VIPs-Warning ** error in tile 0 x 1104 - Gif Crashing 网站 - Ruby on Rails
VIPs-Warning ** error in tile 0 x 1104 - Gif Crashing website - Ruby on Rails
问:
我已经将我的应用程序部署到 fly.io,并发现了一个有趣的错误,它只影响生产。使用本地存储时,相同的 gif 不会导致此问题。gif 将上传到 AWS S3
首先,我在磁贴 0 x 1104 中收到 VIPs-Warning ** 错误 后跟 ActionView::Template::Error (gifload:在图像完成之前检测到图像 EOF
这是我用来加载图像的代码:
<% 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 %>
这是有问题的 gif,我没有看到它有什么特别或奇怪的地方,我的其他更大、更宽、更高的 gif 不会导致应用程序崩溃。有没有办法使用Active Storage挽救失败的gif加载?
我尝试添加以下行:
<% 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 %>
当我重新部署站点时,这并没有解决任何问题
<% 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 %>
这会导致语法错误。显然,vips存在问题,我发现了一个关于它的旧线程,但没有关于如何处理它的解决方案:https://github.com/libvips/libvips/issues/1701
我已经在开发中使用 AWS 测试了上传和加载 gif,并且没有出现问题。
答:
0赞
jcupitt
3/19/2023
#1
您的服务器上可能有一个非常旧的 libvips 二进制文件。我会找出它是什么版本。
例如:
$ irb
irb(main):001:0> require 'vips'
=> true
irb(main):002:0> Vips::LIBRARY_VERSION
=> "8.14.0"
irb(main):003:0>
ruby-vips 是 libvips 库二进制文件的薄皮。它本身几乎没有任何功能,它只是以一种类似红宝石的方式呈现您平台上的 libvips 二进制文件中可用的功能。
libvips GIF 处理在过去几年中有了很大的改进,听起来您的生产机器可能需要更新。
评论
0赞
AndyDaMandy
3/19/2023
在我的个人机器上,它是 8.12.1,在我的生产版本(通过 fly.io)的 rails 控制台上,它是 8.10.5。我会考虑更新,并让您知道是否可以解决问题。
1赞
jcupitt
3/19/2023
是的,这可能是问题所在。libvips 曾经使用 giflib 来加载 GIF,但在 8.11 中切换到(更好的)nsgif 加载器。
评论