Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

webkitSlice breaks HTML5 + chunking on Android Browser #613

Closed
inghamc opened this Issue · 7 comments

3 participants

@inghamc

ASUS Transformer running Andoid 4.0.3

User Agent: Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; Transformer TF101 Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30

Plupload 1.5.4

After extensive testing and debugging I have determined that any upload attempt involving chunking under HTML5 on the Android browser fails. More specifically, any path within plupload.html5.js that involves Blob.webkitSlice(start, end) fails.

After calling webkitSlice(start, end), the returned blob reports the correct .size, but when added and POSTed to the server using FormData.append() and xhr.send(formData), 0 bytes of binary data are included in the POST.

Working around this issue required loading the entire file using FileReader.readAsBinaryString(File/Blob) via the readFileAsBinary function. This code fragment shows context starting at line 755 with lines 758-760 modified to sniff for and handle Android as though it has no chunking support:

                // if there's no way to slice file without preloading it in memory, preload it
                } else if (!features.chunks && features.jpgresize) {
                    readFileAsBinary(nativeFile, sendBinaryBlob);
                } else {
                    var isAndroid = navigator.userAgent.toLowerCase().indexOf('android') > -1;
                    if (isAndroid) {
                        console.debug("Android workaround: avoiding blob.webkitSlice with readFileAsBinary(nativeFile, sendBinaryBlob)");
                        readFileAsBinary(nativeFile, sendBinaryBlob);
                    } else {
                        sendBinaryBlob(nativeFile);
                    }
                }

I would hugely appreciate if either the authors or forum readers could offer a better workaround (or challenge my findings). Otherwise, hopefully this workaround is helpful to others and could be included in a future Plupload release. I'm also trying to get my hands on a Nexus 7 tablet or similar to find an Android browser version that doesn't have this issue.

@jayarjo
Owner

It might be possible to slice off the chunk, preload it with FIleReader and send as binary. I had something similar for Gecko 2,5,6, which had a similar problem with FormData and Blobs.

@jayarjo
Owner

Addressed this in Plupload 2 code base. Actually this should be easy to backport to 1.x branch as well, as the code for workaround is already present there.

@GuillaumeAmat

Hi,

I use the latest stable version (1.5.6) of Plupload and I'm blocked by this bug :(
Have you planned to backport this fix in a 1.5.x release ? When version 2 will be released ?

Thanks for your good work ! ;)

@jayarjo
Owner

Stable Plupload 2 is going to come out this week (at least scheduled). Actually it was backported to 1.5.6. Maybe you are affected by a different bug? Post your config please.

@GuillaumeAmat

Hmmm... It's weird...
Anyway I am testing the Plupload 2 beta and it's working fine. So I will wait its stable release this week.

Thanks

@jayarjo
Owner

Ouch... overdue by 5 months. Crap. Need to push it out ASAP.

@jayarjo jayarjo closed this
@GuillaumeAmat

Any news about the Plupload 2 release ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.