[TIMOB-14875] Android: HTTP requests generate SkImageDecoder message for non-image responses
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-06-20T22:27:21.000+0000 |
Affected Version/s | Release 3.1.1 |
Fix Version/s | Release 3.3.0, Release 3.4.0 |
Components | Android |
Labels | module_network, qe-testadded |
Reporter | Jeff English |
Assignee | Hieu Pham |
Created | 2013-08-13T23:02:36.000+0000 |
Updated | 2014-06-24T22:51:49.000+0000 |
Description
HTTP requests that return non-image data (e.g. content-type of 'application/json') are processing the content as potential images and thus are generating extraneous messages in the console saying "SkImageDecoder::Factory returned null". This is also adding overhead to every non-image HTTP request (albeit minor).
I tracked it down to the 'loadBitmapInfo' method that is called in 'blobFromData' (line 182 in TiBlob.java), which is called from 'handleEntityData' (line 358 in TiHTTPClient.java). It looks like the logic on line 216 in TiBlob.java is incorrect:
if (mt == null || mt.startsWith("image/")) {
Should be
if (mimetype == null || mimetype.startsWith("image/")) {
What is happening is that 'guessContentTypeFromStream' is returning null for 'application/json' type data (which is correct, but it means that 'mt' is null) and it ends up thinking that the data should be processed as an image, when in fact the mimetype value is 'application/json' and thus should not be processed as a potential image.
Looks like the wrong variable is being checked on line 216 of TiBlob.java. I did a quick test and changed the logic to the latter and the warning messages went away.
To reproduce:
1) Issue an Ti.Network.HTTPClient request that returns JSON text
Note in the log the "SkImageDecoder::Factory returned null" message
I can confirm this issue. HTTP requests asking for a XML in the reply cause numerous messages of SkImageDecoder::Factory returned null.
Bug still seems present in 3.2.0 version
Still present on 3.3.0.RC. This is a trivial issue with a simple solution, provided in the description.
Please fix it.
Can you please fix it?
Still present, +1 to fix it!
Testing Code:
master PR: https://github.com/appcelerator/titanium_mobile/pull/5832 3.3.X PR: https://github.com/appcelerator/titanium_mobile/pull/5833
Verified the fix using the test code. We do not get " SkImageDecoder::Factory returned null" logs anymore. Closing. Environment: Appc Studio : 3.3.0.201406231625 Ti SDK : 3.3.0.v20140624130120 Mac OSX : 10.8.5 Alloy : 1.4.0-rc2 CLI - 3.3.0-rc2 Code Processor: 1.1.1 Nexus 5 - android 4.4.4