Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14875] Android: HTTP requests generate SkImageDecoder message for non-image responses

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-06-20T22:27:21.000+0000
Affected Version/sRelease 3.1.1
Fix Version/sRelease 3.3.0, Release 3.4.0
ComponentsAndroid
Labelsmodule_network, qe-testadded
ReporterJeff English
AssigneeHieu Pham
Created2013-08-13T23:02:36.000+0000
Updated2014-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

Comments

  1. Bernhard Dengler 2013-12-09

    I can confirm this issue. HTTP requests asking for a XML in the reply cause numerous messages of SkImageDecoder::Factory returned null.
  2. Nico de Groot 2014-01-22

    Bug still seems present in 3.2.0 version
  3. Pier Paolo Ramon 2014-06-13

    Still present on 3.3.0.RC. This is a trivial issue with a simple solution, provided in the description.
  4. Viktor Korol 2014-06-14

    Please fix it.
  5. Alexey Chulochnikov 2014-06-19

    Can you please fix it?
  6. Nastya Lytvyn 2014-06-19

    Still present, +1 to fix it!
  7. Hieu Pham 2014-06-20

    Testing Code:
       var xhr = Titanium.Network.createHTTPClient();
       xhr.onreadystatechange = function()
       {
          Ti.API.info("xhr.onreadystatechange");
       }
       // open the client
       xhr.open('GET','http://www.appcelerator.com/assets/The_iPad_App_Wave.pdf');
            
       // send the data
       xhr.send();
       
    master PR: https://github.com/appcelerator/titanium_mobile/pull/5832 3.3.X PR: https://github.com/appcelerator/titanium_mobile/pull/5833
  8. Lokesh Choudhary 2014-06-24

    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

JSON Source