From 778981ec893baea12ac3182122817cfc1ce405a5 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 13 Jun 2018 11:01:58 +0200 Subject: [PATCH] Catch, and propagate, errors in the `requestAnimationFrame` branch of `InternalRenderTask._scheduleNext` To support these changes, `InternalRenderTask._next` now returns a Promise. --- src/display/api.js | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/display/api.js b/src/display/api.js index 6e71f8cc7..1ebdd22ed 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -2455,30 +2455,34 @@ var InternalRenderTask = (function InternalRenderTaskClosure() { _scheduleNext: function InternalRenderTask__scheduleNext() { if (this.useRequestAnimationFrame && typeof window !== 'undefined') { - window.requestAnimationFrame(this._nextBound); + window.requestAnimationFrame(() => { + this._nextBound().catch(this.callback); + }); } else { Promise.resolve().then(this._nextBound).catch(this.callback); } }, _next: function InternalRenderTask__next() { - if (this.cancelled) { - return; - } - this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, - this.operatorListIdx, - this._continueBound, - this.stepper); - if (this.operatorListIdx === this.operatorList.argsArray.length) { - this.running = false; - if (this.operatorList.lastChunk) { - this.gfx.endDrawing(); - if (this._canvas) { - canvasInRendering.delete(this._canvas); - } - this.callback(); + return new Promise(() => { + if (this.cancelled) { + return; } - } + this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, + this.operatorListIdx, + this._continueBound, + this.stepper); + if (this.operatorListIdx === this.operatorList.argsArray.length) { + this.running = false; + if (this.operatorList.lastChunk) { + this.gfx.endDrawing(); + if (this._canvas) { + canvasInRendering.delete(this._canvas); + } + this.callback(); + } + } + }); }, };