react-signature-canvas icon indicating copy to clipboard operation
react-signature-canvas copied to clipboard

Warning in browser console: `Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true` when calling `toDataURL`

Open nmalancea opened this issue 1 year ago • 8 comments

Screenshot 2024-04-29 at 1 01 41 PM

I get this warning in the browser console when calling toDataURL:

Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true

Any ideas how to correctly configure the canvas to set { willReadFrequently: true }?

nmalancea avatar Apr 29 '24 10:04 nmalancea

We might need to add a prop for the canvas's contextAttributes

agilgur5 avatar Apr 29 '24 14:04 agilgur5

Hello, I have the same problem. Could you give me an exemple please ?

Beatriz2529 avatar Jun 05 '24 15:06 Beatriz2529

I don't believe there's a workaround for this as the CanvasContext manipulation is not user-facing. That's why I wrote that this may require new props to support. It is an open feature request, there are no existing examples.

In any case, this is a warning from a more recent browser feature and can safely be ignored.

agilgur5 avatar Jun 05 '24 15:06 agilgur5

Does this error cause any performance issue? since you haven't added the feature yet shall I ignore this error at the moment? @agilgur5

hossain45 avatar Jul 06 '24 04:07 hossain45

It's not an error, it's a warning, so by definition you can ignore it.

And the warning is about a newer browser feature that did not exist until years after this library was created. It worked fine without the feature and will continue to work fine without it.

Enabling it for some use-cases will allow for a performance optimization (which is what this issue is labeled as). But again, it works fine without this.

agilgur5 avatar Jul 06 '24 11:07 agilgur5

We might need to add a prop for the canvas's contextAttributes

Looks like upstream enabled the same: https://github.com/szimek/signature_pad/pull/761#issuecomment-1986951356

agilgur5 avatar Jul 31 '24 15:07 agilgur5

Looks like upstream enabled the same: https://github.com/szimek/signature_pad/pull/761#issuecomment-1986951356

@agilgur5 refer to signature_pad that it's fixed there, but it's useless for this package react-signature-canvas. It is not updated or compatible with the given version of signature_pad.

Would you update the react-signature-canvas package to be compatible with the new version of signature_pad?

thank you very much

mbohovic avatar Sep 03 '24 22:09 mbohovic

@agilgur5 refer to signature_pad that it's fixed there, but it's useless for this package react-signature-canvas. It is not updated

I'm very aware of that, that's why this issue is still open, and not closed. Recording a note that upstream introduced a similar feature is worthwhile in and of itself as it will be useful for future implementation.

Would you update the react-signature-canvas package to be compatible with the new version of signature_pad?

There is already a separate issue(s) for that, see https://github.com/agilgur5/react-signature-canvas/issues/73#issuecomment-2052280336.

agilgur5 avatar Sep 03 '24 23:09 agilgur5