mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-23 00:28:06 +02:00
Ensure that the correct data is sent, with the test
message, from the worker if typed arrays aren't properly supported
With native typed array support now being mandatory in PDF.js, since version 2.0, this probably isn't a huge problem even though the current code seems wrong (it was changed in PR 6571). Note how in the `!(data instanceof Uint8Array)` case we're currently attempting to send `handler.send('test', 'main', false);` to the main-thread, which doesn't really make any sense since the signature of the method reads `send(actionName, data, transfers) {`. Hence the data that's *actually* being sent here is `'main'`, with `false` as the transferList, which just seems weird. On the main-thread, this means that we're in this case checking `data && data.supportTypedArray`, where `data` contains the string `'main'` rather than being falsy. Since a string doesn't have a `supportTypedArray` property, that check still fails as expected but it doesn't seem great nonetheless.
This commit is contained in:
parent
dc6e1b4176
commit
eef53347fe
2 changed files with 2 additions and 3 deletions
|
@ -335,7 +335,7 @@ var WorkerMessageHandler = {
|
|||
|
||||
// check if Uint8Array can be sent to worker
|
||||
if (!(data instanceof Uint8Array)) {
|
||||
handler.send('test', 'main', false);
|
||||
handler.send('test', false);
|
||||
return;
|
||||
}
|
||||
// making sure postMessage transfers are working
|
||||
|
|
|
@ -1480,8 +1480,7 @@ var PDFWorker = (function PDFWorkerClosure() {
|
|||
terminateEarly();
|
||||
return; // worker was destroyed
|
||||
}
|
||||
var supportTypedArray = data && data.supportTypedArray;
|
||||
if (supportTypedArray) {
|
||||
if (data && data.supportTypedArray) {
|
||||
this._messageHandler = messageHandler;
|
||||
this._port = worker;
|
||||
this._webWorker = worker;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue