Status: In QE Test
Affects Version/s: None
Fix Version/s: Release 8.3.0
Seen on Android 7
Sprint:2019 Sprint 13, 2019 Sprint 14, 2019 Sprint 15
When downloading an image file greater than 512 KB via HTTPClient, the resulting "responseData" Blob will return zero "width" and "height". This is not an issue with smaller image files.
Steps to reproduce:
- Acquire an Android device that has Internet access.
- Build and run the below code on that Android device.
- Tap on the "Download" button.
- An alert is displayed indicating that the image blob width/height is 0x0. (This is the bug.)
- Notice that the image blob is successfully displayed in an ImageView. Meaning this is only an issue with the "width" and "height" returned by the blob object.
When the HTTP response is over 512 KB (Titanium's default max buffer size), then HTTPClient will download the response to a temp file instead of in memory. This bug happens because HTTPClient immediately wraps this temp file with a "responseData" blob before any bytes have been written to it (ie: the temp file is currently empty). This means that the blob will fail to fetch image info. The solution is to re-read the image file's info once HTTPClient finishes the download.
In the HTTPClient object's "onload" callback, you can work-around this issue by creating a new blob from the "responseData" blob's file. The new blob will re-read the image file's info now that it has finished downloading.