Skip to content
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

Issues during size scaling of images (mostly occurs with jpeg) #403

Closed
hyatt03 opened this issue Apr 8, 2016 · 7 comments
Closed

Issues during size scaling of images (mostly occurs with jpeg) #403

hyatt03 opened this issue Apr 8, 2016 · 7 comments
Labels

Comments

@hyatt03
Copy link

hyatt03 commented Apr 8, 2016

I have a hard time describing the issue, so I've attached an example instead:

a333e056b387-48e8-8265-d2f96531b354_large

As you can see, it seems an issue occurs while scaling jpeg images, however it's not a consistent issue, and libvips throws warnings when it happens. For example

vips warning: VipsJpeg: read gave 2 warnings
vips warning:
Assertion failed: (loop->watchers[w->fd] == w), function uv__io_stop, file ../deps/uv/src/unix/core.c, line 864.
Program node main.js exited with code null

If I can listen for these warnings, that would be sufficient.
Here is the original image:
a333e056b387-48e8-8265-d2f96531b354

It seems to occur in about 0.6% of scaling jobs, for reference here is the code I use to scale the image (edited for brevity):

let imageObject = sharp(fileobj.name);
        imageObject.metadata().then((metadata) => {
          if (metadata.orientation) {
            imageObject.rotate();
          }

          return imageObject;
        }).then((image) => {
          imageObject = image;

          if (width && height) {
            imageObject.resize(width, height).withoutEnlargement();
          }
          else {
            imageObject.resize(width).max().withoutEnlargement();
          }

          imageObject.toBuffer()
            .then(function (outputBuffer) {
              logger.info('finished image transcoding job', {
                    size: width && height ? `${width}x${height}` : `${width}x${width}`,
                    data: job.data
                  });
                }
              );
            })
            .catch(function (err) {
              done();
              logger.error('an error occurred while transcoding image', {job: job.data, error: err});
            });
        }).catch((err) => {
          done();
          logger.error('an error occurred while transcoding image', {job: job.data, error: err});
        });
@lovell
Copy link
Owner

lovell commented Apr 8, 2016

"Assertion failed: (loop->watchers[w->fd] == w), function uv__io_stop, file ../deps/uv/src/unix/core.c, line 864."

Hello, this is an error I've not seen before.

The vips warning messages and the truncated JPEG suggest there might have been an unclean thread shutdown, possibly based on a fatal error in another thread.

Could main.js be dependent on any other modules that deal with file watching or hot-reloading? Are you able to share a list of the other (native) modules upon which it depends?

@lovell lovell added the triage label Apr 8, 2016
@lovell
Copy link
Owner

lovell commented Apr 8, 2016

@lovell
Copy link
Owner

lovell commented Apr 9, 2016

If this is caused by libvips writing to stderr (rather than that being a side-effect of another problem) then nodejs/node#3422 looks relevant with mscdex/node-mariasql@f777a0e being the fix referred to.

sharp doesn't directly use any of libuv's file handling logic so my best guess remains that another module is doing so - if not MariaDB then perhaps a logging or monitoring library that's trying to watch stderr.

@hyatt03
Copy link
Author

hyatt03 commented Apr 11, 2016

Thank you for the response!

I've looked at our logs, and it turns out the assertion error doesn't always happen in conjunction with a read error, in fact, most of the time the read error happens with an assertion error.

The process continues nontheless, without reporting an error, and that's our primary concern.

@lovell
Copy link
Owner

lovell commented Apr 11, 2016

Are you able to set the VIPS_WARNING=0 environment variable to silence these warnings? This will (temporarily, at least) help separate what might be two different problems interfering with each other.

@hyatt03 hyatt03 closed this as completed Apr 15, 2016
@lovell
Copy link
Owner

lovell commented Apr 15, 2016

Were you able to solve this? If so, are you able to share details in case others have the same problem? Thanks!

@hyatt03
Copy link
Author

hyatt03 commented Apr 15, 2016

Thank you for trying to help me. I was not able to solve it, and I had to replace the library as it caused a sigabort (I think libvips -> imagemagick), which crashed my application (forever detected the sigabort and killed the process). If I get the time to look into the cause, I will, but for now I must leave you without an answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants