Images (randomly?) corrupted with Firefox 58+
See original GitHub issueHi,
I have been trying to debug this for some time and I would like to get your insight on this.
On my app, users can upload a lot of pictures, and I am using pica to resize them before uploading. On Firefox (saw this happening for users on mac, linux and windows) some images, not always the same when I try multiple times, are not correct once on the server. As I am calculating the checksum before upload, it is not caused by a network error.
Here is an example:
- Original image: https://www.dropbox.com/s/go5tra5czulbfsm/IMGL7717.jpg?dl=0
- Image after processing: https://www.dropbox.com/s/37n7ba5qhcl8vfq/314luvAL9s5OcI0ugieEKK-3cf7b61d9e.jpg?dl=0
I am using a code inspired by https://github.com/nodeca/nodeca.users/blob/master/client/users/uploader/uploader.js to extract the EXIF data, resize the image using pica
, and then put it back together.
For each file:
- Read it using
readAsArrayBuffer
- call
filterJPEG
- create a new
Image
- set the
src
usingwindow.URL.createObjectURL(file)
- create 2
canvas
elements, set their size - draw the image on the first one
- call pica to resize on the second canvas (one shared pica instance, using
const pica = Pica({ idle: 10000 })
) - get a blob from the
dst
canvas - put back together the JPEG header (from
filterJPEG
) and the body from the blob
Once this is done, I use a webworker to calculate the MD5 checksum of the previously created blob
, and upload it to my server (where the MD5 checksum is checked again).
Do you have an idea of what can cause this? There are a lot of moving parts and I am only seeing the issue on Firefox. I would estimate than less than 0.5% of the files are corrupted like this, and retrying a corrupted file usually works fine. I havent seen this problem on Safari / Chrome.
I know this may not be related to Pica, but I spent quite a lot of time trying to understand where it may come from, and I am not sure of how to pin it down.
Thanks!
UPD: probably a browser bug https://github.com/nodeca/pica/issues/130#issuecomment-371617724
Issue Analytics
- State:
- Created 6 years ago
- Comments:18 (8 by maintainers)
FYI the bug has been fixed (see the bugzilla link above). I am no longer able to reproduce it using Firefox Beta (v61). The fix may be backported to Firefox 60 ESR if it does not cause any regression.
Firefox 61 is planned to be released on 2018-06-26.
Here is the bugzilla link: https://bugzilla.mozilla.org/show_bug.cgi?id=1450302