[Pkg-javascript-commits] [pdf.js] 185/414: Improve work-around for importScripts bug.

David Prévot taffit at moszumanska.debian.org
Tue Jun 28 17:12:20 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 097e273ca444804c0c3efd66d05096e14521eee8
Author: Rob Wu <rob at robwu.nl>
Date:   Fri Jan 22 01:27:28 2016 +0100

    Improve work-around for importScripts bug.
    
    Reverts "Hack to avoid intermidiate Chrome failures during tests."
    (2b2c5212133dc69d238a286ae69d49eda571db2f).
    
    require.js uses importScript asynchronously, which activates the worker
    GC bug in WebKit. This patch works around a bug in a way that is similar
    in the upcoming (but not yet released) require.js 2.1.23
    
    The advantage of the new work-around is that it allows the runtime to
    garbage-collect idle Workers.
    
    References:
    - https://crbug.com/572225
    - https://webkit.org/b/153317
---
 src/display/api.js   |  9 ---------
 src/worker_loader.js | 11 +++++++++++
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/display/api.js b/src/display/api.js
index d94a4bd..8f9a1f9 100644
--- a/src/display/api.js
+++ b/src/display/api.js
@@ -1276,16 +1276,7 @@ var PDFWorker = (function PDFWorkerClosure() {
           // https://bugzilla.mozilla.org/show_bug.cgi?id=683280
           var worker = new Worker(workerSrc);
           var messageHandler = new MessageHandler('main', 'worker', worker);
-//#if !PRODUCTION
-          // Don't allow worker to be destroyed by Chrome, see:
-          // https://code.google.com/p/chromium/issues/detail?id=572225
-          var jsWorkerId = '_workerKungfuGrip_' + Math.random();
-          window[jsWorkerId] = worker;
-//#endif
           messageHandler.on('test', function PDFWorker_test(data) {
-//#if !PRODUCTION
-            delete window[jsWorkerId];
-//#endif
             if (this.destroyed) {
               this._readyCapability.reject(new Error('Worker was destroyed'));
               messageHandler.destroy();
diff --git a/src/worker_loader.js b/src/worker_loader.js
index ea480c7..5c3af1a 100644
--- a/src/worker_loader.js
+++ b/src/worker_loader.js
@@ -15,6 +15,17 @@
 
 'use strict';
 
+//#if !PRODUCTION
+//// Patch importScripts to work around a bug in WebKit and Chrome 48-.
+//// See https://crbug.com/572225 and https://webkit.org/b/153317.
+self.importScripts = (function (importScripts) {
+  return function() {
+    setTimeout(function () {}, 0);
+    return importScripts.apply(this, arguments);
+  };
+})(importScripts);
+//#endif
+
 importScripts('../node_modules/requirejs/require.js');
 
 require.config({paths: {'pdfjs': '.'}});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list