Add a timeout before sending the pdf doc to the worker such that there is no too-long-js-running hint

This commit is contained in:
Julian Viereck 2011-10-09 11:25:33 +02:00
parent 20a348fc0c
commit d313115d19

11
pdf.js
View File

@ -4224,7 +4224,11 @@ var PDFDoc = (function() {
WorkerProcessorHandler.setup(processorHandler);
}
processorHandler.send('doc', this.data);
this.workerReadyPromise = new Promise('workerReady');
setTimeout(function() {
processorHandler.send('doc', this.data);
this.workerReadyPromise.resolve(true);
}.bind(this));
}
constructor.prototype = {
@ -4233,7 +4237,10 @@ var PDFDoc = (function() {
},
startRendering: function(page) {
this.processorHandler.send('page_request', page.page.pageNumber + 1);
// The worker might not be ready to receive the page request yet.
this.workerReadyPromise.then(function() {
this.processorHandler.send('page_request', page.page.pageNumber + 1);
}.bind(this));
},
getPage: function(n) {