janko / image_processing

High-level image processing wrapper for libvips and ImageMagick/GraphicsMagick
MIT License
863 stars 76 forks source link

ImageProcessing gem hangs in GitHub Actions CI #128

Closed rodrigoargumedo closed 2 months ago

rodrigoargumedo commented 2 months ago

Hi,

I was doing some research why the image_processing gem was causing to hang and having it to fail after 6 hours of running the GitHub Actions runner container.

        ...
       - name: Install vips
          run: |
            sudo apt-get update
            sudo apt-get install -y libvips
       - name: Run tests
         run: bundle exec rails test
      ...

Rails tries to invoke the image_processing gem with following resource that I made in test for sampling purposes:

setup do
  @account = accounts(:one)
  ...
end

test 'avatar attached' do
  @account.avatar.attach(io: File.open('test/fixtures/files/test.png', filename: 'test.png')
  assert @account.avatar.variant(resize: '100x100')
end

However, version 1.13.x broke GitHub Actions CI runner and causing a lot of headaches and issues for those who updated to this version. The only workaround I found is by downgrading to version 1.12.2 and additionally adding image_magick to the stack and temporarily resolves the problem.

Before: Before Source

After: After Source

Is there a permanent solution to this issue?

janko commented 2 months ago

Did you determine which change caused the hanging? Also, by "additionally adding ImageMagick to the stack" did you mean that you changed Active Storage's processor to MiniMagick? If yes, could you also try the ImageProcessing 1.13.0 with MiniMagick? Because I think the difference is in processors, not ImageProcessing version, so I want to rule that out.

Which libvips version does your GitHub CI install? Are you able to reproduce that hanging with the same libvips version locally?

rodrigoargumedo commented 2 months ago

Did you determine which change caused the hanging?

I ran multiple test sessions yesterday and the cause of the hang is when ActiveRecord tries to attach the file via image_processing and the transaction is written to the database record. It tries to do the test assertions from the written record, but then the transaction hangs in the process thinking we're waiting for additional instructions from image_processing gem, as illustrated in the screenshot in the OP issue message.

Also, by "additionally adding ImageMagick to the stack" did you mean that you changed Active Storage's processor to MiniMagick?

No changes to the processor at this time.

Which libvips version does your GitHub CI install?

libvips42 via Ubuntu apt

Are you able to reproduce that hanging with the same libvips version locally?

Yes, that is correct, sir.

janko commented 2 months ago

I suggest you make a minimal self-contained example that reproduces the hanging using ruby-vips (no Active Storage, and ideally no ImageProcessing), and report it to the ruby-vips repository. I don't think there is anything in ImageProcessing gem that could cause the hanging.