wulfsolter / angular2-signaturepad

Angular2 Component for szimek / signature_pad
MIT License
176 stars 157 forks source link

iOS/safari canvas memory leak #92

Closed cyptus closed 4 years ago

cyptus commented 4 years ago

signaturepad leads into an memory leak in iOS because the canvas is not destroyed correctectly: https://stackoverflow.com/questions/52532614/total-canvas-memory-use-exceeds-the-maximum-limit-safari-12

The error occurred under iOS after multiple instances have been created over the lifetime of an app. It seems to be an Bug in WebKit by Apple which wont get fixed from angular.

I fixed this by implementating OnDestroy and setting canvas width and height to zero, like mentioned in the stackoverflow post:

  ngOnDestroy() {
    this.signaturePad.set('canvasHeight', 0);
    this.signaturePad.set('canvasWidth', 0);
  }

SignaturePad Component should already do this itself as this error is hard to find.