Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
IE11 and binary blobs #900
I have some time to start looking into IE11 support for putting attachments for binary blobs. What direction would be most fruitful for the team for me to explore (e.g. adding a script to compute MD5SUM?).
BTW, I have a demo I can throw up on CodePen.
Here is the error I get when I try to put a binary blob attachment:
// pouchdb.nightly - 2013-07-31T02:01:34
SCRIPT438: Object doesn't support property or method 'readAsBinaryString'File: pouchdb-nightly.min.js, Line: 3, Column: 12826
Just press [Download], it will clear any old DB. If you want to manually remove the PouchDB there is a [Delete DB] button to give you a clean slate.
One thing I had to add to this demo is a variable called maxThreads, which is currently set to 50 for Chrome, and 1 for Firefox. You can change the values. Chrome has an issue with SPDY protocols, it allows too many asynch XHR calls, and it kills the browser (runs out of memory and thread pool). So there some fancy code using jquery promises to make sure that there is a maximum of outstanding XHR2 calls.
Well, I have gone into the source, and created a fix that works for me in IE11, FF24, and Chrome V28. To run this demo:
It will load 171 JPG map tiles via XHR2 and stored them in PouchDB (The table tells you if Binary or Base64 (Chrome) is being used in PouchDB).
[If you want to try with more JPG and get a higher resolution map (600+ tiles) then change line 1 to
You can also [DELETE] the PouchDB databases.
Please tell me what performance you see. Behind my firewalls I am getting about 24 Files/Sec. in IE11 and Chrome
You can then look at the full downloaded map by going to:
What did I change? Well firstly, I am unable to get the source to build, so I had to hack the minified nightly downloads (can someone help me with issue https://github.com/daleharvey/pouchdb/issues/902)
What I had to do is change the IDB adapter function preprocessAttachment() it now no longer does a readAsBinaryString() but does a readAsArrayBuffer() which returns a fancy HTML5 ArrayBuffer, which I convert to a Uint8Array()
I am no expert in the internals of PouchDB, so I suspect I may have broken some things for some people. Also GitHub does not understand passworded proxies, so I have no way to do Pull requests to submit my changes.
Going to take a look at your #902 issue now, but this work is great, apologies for the radio silence, its been a busy few weeks but will start getting up to speed and try to get this merged asap
As far as I know chrome does support either arraybuffers or blobs in idb despite that still being an open issue, I keep hearing conflicting reports so will test it all out
I was about to write you. I can tell you that Chrome does support ArrayBuffers, but does not yet support blobs: https://code.google.com/p/chromium/issues/detail?id=108012 . So what I do is copy the data out of the ArrayBuffer into a string for Chrome. A small performance hit. But then the code was previously doing an btoa().
I realize that my lack of GitHub access, source copy, and PouchDB internals naivety, means that what I did is a bit of hack. But it does work for me, and hopefully it gives some help in getting IE support.
Sorry for the lack of responses. We would definitely look into a pull request if someone submitted one, but it's difficult to use the files you uploaded, since Pouch has changed considerably since then, and there's no diff.
I admit our IE support for the tests is a little lacking, though; last I checked, you can only run one test at a time, because there's some silent error in the test cleanup method. It's totally doable, though, and I've gone through the painstaking effort in a VirtualBox environment, one test at a time, as recently as here, so I know it's doable.
As an aside, anybody who's interesting in fixing all the things in IE would be a very welcome contributor to this project!
then we replace this.result with binary
Not very optimized, but very little impact to the codebase.