agilgur5 / react-signature-canvas

A React wrapper component around signature_pad (in < 150 LoC). Unopinionated and heavily updated fork of react-signature-pad
https://agilgur5.github.io/react-signature-canvas/
Other
539 stars 117 forks source link

Weird artifacts using Next.js 13 #95

Closed michaelbonner closed 1 year ago

michaelbonner commented 1 year ago

Some really bizarre things are happening while using Next.js 13. There's a dotted line from the top left of the canvas to where the cursor is drawing.

Here's a reference image:

Screenshot 2022-11-15 at 7 32 35 PM

It only happens when using a production build. npm run dev works fine, but npm run build and npm run start makes the weirdness happen.

Bare Bones Reproduction

repo: https://github.com/michaelbonner/react-signature-pad-next-test

deployed URL: https://react-signature-pad-next-test.vercel.app/

vladshcherbin commented 1 year ago

Same with another wrapper package - https://github.com/michaeldzjap/react-signature-pad-wrapper

I believe it's something with underlying signature_pad package and new SWC compiler which is ON by default in next 13.

agilgur5 commented 1 year ago

I believe it's something with underlying signature_pad package and new SWC compiler which is ON by default in next 13.

Yea, as per above, this seems to be due to some compiler optimization screwing something up. And if it exists in other signature_pad packages, it's independent of this library. This issue does not pop up elsewhere, and as such there's not really anything this library can do -- either swc or Next.js or maybe signature_pad would have to fix this. So this is out-of-scope for this library.

ElTimuro commented 1 year ago

For everyone else facing this: I was able to fix this by disabling swcMinify in the next config:

const nextConfig = {
  reactStrictMode: true,
  swcMinify: false,
};