Bug #15059

Don't rely on FileReader.readAsBinaryString()

Added by sajolida 2017-12-14 15:40:53 . Updated 2018-03-02 15:11:18 .

Status:
Rejected
Priority:
Normal
Assignee:
Category:
Installation
Target version:
Start date:
2017-12-14
Due date:
% Done:

0%

Feature Branch:
Type of work:
Code
Blueprint:

Starter:
Affected tool:
Verification Extension
Deliverable for:


Subtasks


History

#1 Updated by sajolida 2017-12-22 18:32:32

  • Assignee changed from sajolida to uzairfarooq

#2 Updated by uzairfarooq 2017-12-30 05:41:53

  • Assignee changed from uzairfarooq to sajolida
  • QA Check set to Ready for QA

#3 Updated by Anonymous 2018-01-15 15:15:20

Maybe we should review this soonish.

#4 Updated by sajolida 2018-01-17 17:18:23

  • Status changed from Confirmed to In Progress
  • Assignee changed from sajolida to uzairfarooq
  • QA Check changed from Ready for QA to Dev Needed

u: I informed Uzair of my availability over private email last week. co6 is also in the loop for a final check.

Uzair: I tested your patch locally and it seems to break the extension. Symptoms are that the progress bar appears but remains at 0%. Rolling back to readAsBinaryString makes the extension work again for me.

My patch to make it work again:

diff --git a/scripts/contentscript/verify.js b/scripts/contentscript/verify.js
index 64a1a74..de81211 100644
--- a/scripts/contentscript/verify.js
+++ b/scripts/contentscript/verify.js
@@ -100,7 +100,8 @@ class VerifyDownload {
     fr.onload = e => {
       let chunk = e.target.result;
       let progressPercent;
-      self.sha256.update(ArrayBufferToString(chunk));
+      //self.sha256.update(ArrayBufferToString(chunk));
+      self.sha256.update(chunk);
       offset += CHUNK_SIZE;
       progressPercent = parseInt((offset/file.files[0].size)*100);
       if (progressPercent>100) progressPercent = 100;
@@ -118,7 +119,8 @@ class VerifyDownload {
     };

     let slice = file.files[0].slice(offset, offset + CHUNK_SIZE);
-    fr.readAsArrayBuffer(slice);
+    //fr.readAsArrayBuffer(slice);
+    fr.readAsBinaryString(slice);

     if(offset === 0){

#5 Updated by anonym 2018-01-23 19:52:41

  • Target version changed from Tails_3.5 to Tails_3.6

#6 Updated by uzairfarooq 2018-01-26 13:28:40

  • Status changed from In Progress to Fix committed
  • Assignee changed from uzairfarooq to sajolida
  • QA Check changed from Dev Needed to Ready for QA

#7 Updated by sajolida 2018-01-31 15:52:01

  • Status changed from Fix committed to In Progress
  • Assignee changed from sajolida to uzairfarooq
  • QA Check changed from Ready for QA to Dev Needed

The extension is working again now but it’s extremelly slow:

console.log(endTime-startTime); gives me 1150650. Is that 19 minutes?

Could you make it so we’re back to something close to the previous execution time?

#8 Updated by uzairfarooq 2018-02-21 10:33:43

The library we are using accepts only binary string and if we don’t use FileReader.readAsBinaryString() method, we have to use FileReader.readAsArrayBuffer() and then convert it to a binary string using native javascript methods.

The problem is that the conversion takes to binary string takes too much time. We are only using native methods for conversion so I don’t think we can do much to improve the time.

#9 Updated by sajolida 2018-03-02 15:11:18

  • Status changed from In Progress to Rejected
  • Assignee deleted (uzairfarooq)
  • QA Check deleted (Dev Needed)

Then I prefer to keep relying on FileReader.readAsBinaryString() than to have a ~20x performance loss.

So I rewrote the Git history to remove your commits and reject this ticket.

NB: I checked this decision with co6, our special JS reviewer.