Improve work-around for importScripts bug.
Reverts "Hack to avoid intermidiate Chrome failures during tests."
(2b2c521213
).
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
This commit is contained in:
parent
58329f7f92
commit
097e273ca4
@ -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();
|
||||
|
@ -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': '.'}});
|
||||
|
Loading…
Reference in New Issue
Block a user