Disable work on firefox using feature detection

This commit is contained in:
Julian Viereck 2011-11-10 18:33:45 +01:00
parent 70767b4522
commit 99254891e6
2 changed files with 16 additions and 7 deletions

View File

@ -15,10 +15,6 @@ if (!globalScope.PDFJS) {
globalScope.PDFJS = {}; globalScope.PDFJS = {};
} }
// Temporarily disabling workers until 'localhost' FF bugfix lands:
// https://bugzilla.mozilla.org/show_bug.cgi?id=683280
globalScope.PDFJS.disableWorker = true;
// getPdf() // getPdf()
// Convenience function to perform binary Ajax GET // Convenience function to perform binary Ajax GET
// Usage: getPdf('http://...', callback) // Usage: getPdf('http://...', callback)
@ -471,6 +467,7 @@ var PDFDoc = (function pdfDoc() {
this.objs = new PDFObjects(); this.objs = new PDFObjects();
this.pageCache = []; this.pageCache = [];
this.fontsLoading = {};
this.workerReadyPromise = new Promise('workerReady'); this.workerReadyPromise = new Promise('workerReady');
// If worker support isn't disabled explicit and the browser has worker // If worker support isn't disabled explicit and the browser has worker
@ -484,7 +481,16 @@ var PDFDoc = (function pdfDoc() {
throw 'No PDFJS.workerSrc specified'; throw 'No PDFJS.workerSrc specified';
} }
var worker = new Worker(workerSrc); var worker
try {
worker = new Worker(workerSrc);
} catch (e) {
// Some versions of FF can't create a worker on localhost, see:
// https://bugzilla.mozilla.org/show_bug.cgi?id=683280
globalScope.PDFJS.disableWorker = true;
this.setupFakeWorker();
return;
}
var messageHandler = new MessageHandler('main', worker); var messageHandler = new MessageHandler('main', worker);
@ -505,8 +511,6 @@ var PDFDoc = (function pdfDoc() {
} else { } else {
this.setupFakeWorker(); this.setupFakeWorker();
} }
this.fontsLoading = {};
} }
constructor.prototype = { constructor.prototype = {

View File

@ -7,6 +7,11 @@
'use strict'; 'use strict';
// Disable worker support for running test as
// https://github.com/mozilla/pdf.js/pull/764#issuecomment-2638944
// "firefox-bin: Fatal IO error 12 (Cannot allocate memory) on X server :1."
PDFJS.disableWorker = true;
var appPath, browser, canvas, currentTaskIdx, manifest, stdout; var appPath, browser, canvas, currentTaskIdx, manifest, stdout;
var inFlightRequests = 0; var inFlightRequests = 0;