mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-23 08:38:06 +02:00
Attempt to clean-up/restore pending rendering operations when errors occurs while a RenderTask
runs (PR 10202 follow-up)
This piggybacks of the existing `cancel` functionality, to ensure that any pending operations are closed *and* that any temporary canvases are actually being removed. Also simplifies `finishPaintTask` in `PDFPageView.draw` slightly, by converting it to an async function.
This commit is contained in:
parent
40863eb275
commit
5081063b9e
2 changed files with 8 additions and 9 deletions
|
@ -2434,7 +2434,7 @@ const InternalRenderTask = (function InternalRenderTaskClosure() {
|
|||
}
|
||||
}
|
||||
|
||||
cancel() {
|
||||
cancel(error = null) {
|
||||
this.running = false;
|
||||
this.cancelled = true;
|
||||
if (this.gfx) {
|
||||
|
@ -2443,8 +2443,8 @@ const InternalRenderTask = (function InternalRenderTaskClosure() {
|
|||
if (this._canvas) {
|
||||
canvasInRendering.delete(this._canvas);
|
||||
}
|
||||
this.callback(new RenderingCancelledException(
|
||||
'Rendering cancelled, page ' + this.pageNumber, 'canvas'));
|
||||
this.callback(error || new RenderingCancelledException(
|
||||
`Rendering cancelled, page ${this.pageNumber}`, 'canvas'));
|
||||
}
|
||||
|
||||
operatorListChanged() {
|
||||
|
@ -2480,10 +2480,10 @@ const InternalRenderTask = (function InternalRenderTaskClosure() {
|
|||
_scheduleNext() {
|
||||
if (this._useRequestAnimationFrame) {
|
||||
window.requestAnimationFrame(() => {
|
||||
this._nextBound().catch(this.callback);
|
||||
this._nextBound().catch(this.cancel.bind(this));
|
||||
});
|
||||
} else {
|
||||
Promise.resolve().then(this._nextBound).catch(this.callback);
|
||||
Promise.resolve().then(this._nextBound).catch(this.cancel.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue