FIX: Detect resize failures in the client size image optimization (#13589)
On iOS 15 beta, if you select the camera app when uploading an image and try to upload a freshly taken picture, from the second picture onwards the resize WASM operation will return an array filled with zeroes.
Since every 4th byte is alpha, and at this step we are only dealing with non-transparent images this a O(1) way to detect that the bug was hit. (On normal images, all 4th bytes are 255 at this point)
Also adds a “catch-all” when the original image became too small to try to accomodate other bugs of the same type. By default we only trigger this whole operation on images over 1MB, so if the end result is <20KB something weird did happen. Throwing here will let the upload continue using the original file, so nothing is lost and the user can continue.
GitHub sha: 9b51b9bf4e7856fe836034ca8820c837ab0a829e