diff --git a/src/display/canvas.js b/src/display/canvas.js index abf958e968ba22..b98d0598caa64f 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -1009,8 +1009,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { endDrawing: function CanvasGraphics_endDrawing() { // Finishing all opened operations such as SMask group painting. - if (this.current.activeSMask !== null) { - this.endSMaskGroup(); + while (this.stateStack.length || this.current.activeSMask !== null) { + this.restore(); } this.ctx.restore();