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

Animated WebP images work in development but not when building #39317

Closed
1 task done
aaditmshah opened this issue Aug 4, 2022 · 3 comments · Fixed by #39325
Closed
1 task done

Animated WebP images work in development but not when building #39317

aaditmshah opened this issue Aug 4, 2022 · 3 comments · Fixed by #39325
Labels
Image (next/image) Related to Next.js Image Optimization. Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).

Comments

@aaditmshah
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Fri, 15 Jul 2022 15:33:02 +0000
Binaries:
  Node: 16.16.0
  npm: 8.11.0
  Yarn: 1.22.19
  pnpm: N/A
Relevant packages:
  next: 12.2.4-canary.11
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

  1. When I run yarn dev and open http://localhost:3000/, I can see the animated image of the cat.

  2. However, when I run yarn build I get the following error.

    Failed to compile.
    
    ./assets/cat.webp
    TypeError: Cannot read properties of null (reading 'width')
        at Object.processBuffer (/home/aaditmshah/Repositories/animated-webp-static-import-bug/node_modules/next/dist/server/lib/squoosh/main.js:64:46)
        at async Object.resizeImage (/home/aaditmshah/Repositories/animated-webp-static-import-bug/node_modules/next/dist/server/image-optimizer.js:619:21)
        at async Span.traceAsyncFn (/home/aaditmshah/Repositories/animated-webp-static-import-bug/node_modules/next/dist/trace/trace.js:79:20)
        at async /home/aaditmshah/Repositories/animated-webp-static-import-bug/node_modules/next/dist/build/webpack/loaders/next-image-loader.js:52:38
        at async Span.traceAsyncFn (/home/aaditmshah/Repositories/animated-webp-static-import-bug/node_modules/next/dist/trace/trace.js:79:20)
    
    Import trace for requested module:
    ./pages/index.tsx
    
    
    > Build failed because of webpack errors
    

Expected Behavior

  • When I run yarn build the Next.js app should build without any errors.
  • After that, if I run yarn start and open http://localhost:3000/, I should see the animated image of the cat.

Link to reproduction

https://github.com/aaditmshah/animated-webp-static-import-bug

To Reproduce

  1. Install the dependencies using yarn install.
  2. Run yarn dev and open http://localhost:3000/ to see the animated image of the cat.
  3. Run yarn build to see the aforementioned build error.
@aaditmshah aaditmshah added the bug Issue was opened via the bug report template. label Aug 4, 2022
@balazsorban44 balazsorban44 added Image (next/image) Related to Next.js Image Optimization. kind: bug Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.). and removed bug Issue was opened via the bug report template. labels Aug 4, 2022
@balazsorban44
Copy link
Member

balazsorban44 commented Aug 4, 2022

Thanks for reporting. This seems to be an issue with squoosh, the local image processing library. I am trying to debug this, in the meantime, installing sharp should be a workaround. 🙏

For some reason, this returns null:

const mod = await encoder.dec()
const rgba = mod.decode(new Uint8Array(buffer))
return rgba

@aaditmshah
Copy link
Author

Thank you so much. Installing sharp resolved the issue for me.

@kodiakhq kodiakhq bot closed this as completed in #39325 Aug 5, 2022
kodiakhq bot pushed a commit that referenced this issue Aug 5, 2022
We were resizing animated images when importing them, but we don't optimize images when they come from an upstream provider. For consistency, we can skip resizing for local animated images as well.

Fixes #39317

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
@github-actions
Copy link
Contributor

github-actions bot commented Sep 5, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Image (next/image) Related to Next.js Image Optimization. Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants