From b13b78388bab426233af0065fbe68700bf415684 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 7 May 2016 16:06:35 +0200 Subject: [PATCH] Prevent intermittent "Node was not found" errors when removing the `zoomLayer` in `PDFPageView_draw` I've seen the above error occasionally when the scale is updated many times in quick succession, but I've not been able to pinpoint exactly why it happens. Since the error isn't caught, this means that the `pageViewDrawCallback` function doesn't run to completion. Unfortunately, given the very intermittent nature of the issue, I haven't got any good STR for reliably reproducing this issue. However, I hope that this patch can be accepted anyway, since it's simple and should help prevent unnecessary errors. --- web/pdf_page_view.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index 87f1ceacb..2a29f21ed 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -443,7 +443,12 @@ var PDFPageView = (function PDFPageViewClosure() { zoomLayerCanvas.width = 0; zoomLayerCanvas.height = 0; - div.removeChild(self.zoomLayer); + if (div.contains(self.zoomLayer)) { + // Prevent "Node was not found" errors if the `zoomLayer` was + // already removed. This may occur intermittently if the scale + // changes many times in very quick succession. + div.removeChild(self.zoomLayer); + } self.zoomLayer = null; }