question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Images (randomly?) corrupted with Firefox 58+

See original GitHub issue

Hi,

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:

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 using window.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:closed
  • Created 6 years ago
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
renchapcommented, May 10, 2018

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.

1reaction
renchapcommented, Mar 30, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

Random images on websites will get corrupted.
I'm having a weird problem with Firefox. Occasionally, images that I'm viewing on websites will become corrupted. The image will look like ...
Read more >
Files downloaded with Firefox are often corrupt - Super User
Regular web usage w/ Firefox seems to exhibit no problems. Web pages and images do not appear corrupt. However, downloads of extension ...
Read more >
227491 - Corrupt downloads and images in Chrome only
What went wrong? I'm seeing a lot of corruption with large-ish files when downloading and I'm seeing frequent images that appear corrupted randomly...
Read more >
Has anyone else had issues with firefox corrupting random ...
Half the time i download an image through firefox, it corrupts it. I don't seem to have this same issue on chrome.
Read more >
BSODs, browser crashes, and corrupted images - Windows 10 Forums
I had Firefox Task Manager open at the time and before attempting the login all addons were in the list and not using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found