{ "id": "170775", "key": "TIMOB-25663", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "10100", "description": "This issue won't be actioned.", "name": "Won't Do" }, "resolutiondate": "2020-06-30T14:42:06.000+0000", "created": "2018-01-11T12:55:06.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "Android", "HttpClient", "ImageView", "parity" ], "versions": [], "issuelinks": [ { "id": "56955", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "172521", "key": "TIMOB-26501", "fields": { "summary": "Android: Add \"cache\" property support to HTTPClient", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } } ], "assignee": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2020-06-30T14:42:06.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "In iOS Titanium.Network.HttpClient has _cache_ property, which allow to store http responses in locally on device, Ti SDK for Android lack this property. But remote images loaded by ImageView are stored in cache and there is no way to disable it.\r\n\r\nI have implemented HttpResponseCache module for Android (simple binding to \t[android.net.http.HttpResponseCache|https://developer.android.com/reference/android/net/http/HttpResponseCache.html]), also I've added _cache_ properties to HttpClient and ImageView.\r\nSo attached pathes intoduces this features:\r\n- conditional caching for HttpClient responses and for remote images loaded by ImageView\r\n- configurable http-response cache storage with some statistics\r\n\r\nIn patches _Ti.Android.HttpResponseCache_ is not installed (enabled) on application start and should be installed manually by calling \"install\" method. Without enabled _Ti.Android.HttpResponseCache_ \"HttpClient.cache = true\" will work with _TiResponseCache_, but \"ImageView.cache = false\" will not work, because images cached by _TiResponseCache_ anyway.\r\n\r\nI think, if you'll find this changes usefull, _TiResponseCache_ class could be totally removed because, as I understand correctly, _TiResponseCache_ was created when _HttpResponseCache_ wasn't exists and stays for now as legacy.", "attachment": [ { "id": "63952", "filename": "0001-Android.-Add-HttpResponseCache-module.patch", "author": { "name": "s.volkov", "key": "s.volkov", "displayName": "Sergey Volkov", "active": true, "timeZone": "Europe/Moscow" }, "created": "2018-01-11T12:53:02.000+0000", "size": 9302, "mimeType": "text/x-patch" }, { "id": "63951", "filename": "0002-Android.-Add-HttpClient.cache-property.patch", "author": { "name": "s.volkov", "key": "s.volkov", "displayName": "Sergey Volkov", "active": true, "timeZone": "Europe/Moscow" }, "created": "2018-01-11T12:53:02.000+0000", "size": 3337, "mimeType": "text/x-patch" }, { "id": "63950", "filename": "0003-Android.-Add-ImageView.cache-property.patch", "author": { "name": "s.volkov", "key": "s.volkov", "displayName": "Sergey Volkov", "active": true, "timeZone": "Europe/Moscow" }, "created": "2018-01-11T12:53:02.000+0000", "size": 8137, "mimeType": "text/x-patch" } ], "flagged": false, "summary": "Android. HttpClient.cache. ImageView.cache", "creator": { "name": "s.volkov", "key": "s.volkov", "displayName": "Sergey Volkov", "active": true, "timeZone": "Europe/Moscow" }, "subtasks": [], "reporter": { "name": "s.volkov", "key": "s.volkov", "displayName": "Sergey Volkov", "active": true, "timeZone": "Europe/Moscow" }, "environment": null, "closedSprints": [ { "id": 1000, "state": "closed", "name": "2018 Sprint 04 SDK", "startDate": "2018-02-12T04:23:01.913Z", "endDate": "2018-02-26T04:23:00.000Z", "completeDate": "2018-02-26T19:36:01.769Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "433036", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hey [~s.volkov], the patches look interesting! You can submit a pull-request to the [titanium_mobile|https://github.com/appcelerator/titanium_mobile] repository to include this in the SDK. We will then review your pull request and guide you to the right direction if something is missing. Let us know if you can do that! Moving to TIMOB.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-01-11T15:12:57.000+0000", "updated": "2018-01-11T15:12:57.000+0000" }, { "id": "433039", "author": { "name": "s.volkov", "key": "s.volkov", "displayName": "Sergey Volkov", "active": true, "timeZone": "Europe/Moscow" }, "body": "https://github.com/appcelerator/titanium_mobile/pull/9719", "updateAuthor": { "name": "s.volkov", "key": "s.volkov", "displayName": "Sergey Volkov", "active": true, "timeZone": "Europe/Moscow" }, "created": "2018-01-11T15:50:21.000+0000", "updated": "2018-01-11T15:50:21.000+0000" }, { "id": "433079", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Assigning to version 7.1.0 for now, but it depends on the team resources for new features. Some general thoughts on the PR:\r\n* The PR is Android only, which is against the parity-first approach. So we might want to think about an iOS solution as well\r\n* Right now it seems like you are the only person requesting this feature, so we will need to investigate how critical it is for the general SDK\r\n* The PR misses [unit-tests|https://github.com/appcelerator/titanium_mobile/#unit-tests]. You can see some examples [here|https://github.com/appcelerator/titanium-mobile-mocha-suite/tree/master/Resources]", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-01-12T13:22:44.000+0000", "updated": "2018-01-12T13:22:58.000+0000" }, { "id": "433153", "author": { "name": "s.volkov", "key": "s.volkov", "displayName": "Sergey Volkov", "active": true, "timeZone": "Europe/Moscow" }, "body": "[~hknoechel], this case is mostly about restoring parity, because iOS already has _cache_ property on httpClient.\r\n\r\nI've added tests for HttpResponseCache module and HttpClient.cache. It is currently impossible to create tests for ImageView.cache, because images are cached in memory by TiImageLruCache which is not exposed to js.", "updateAuthor": { "name": "s.volkov", "key": "s.volkov", "displayName": "Sergey Volkov", "active": true, "timeZone": "Europe/Moscow" }, "created": "2018-01-15T14:56:02.000+0000", "updated": "2018-01-15T14:56:02.000+0000" }, { "id": "433185", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hey [~s.volkov], thanks for your reply. -I am mostly concerned about the fact that iOS and Windows use the {{cache}} property as a boolean, where by the Android platform will use an own proxy.- EDIT: I saw it incorrectly! It's actually a boolean as well and the {{HttpResponseCache}} is for global configuration! Cool!\r\n\r\nBut - I also agree caching should become more configurable, so we'd rather look for a {{Ti.Network.HttpResponseCache}} cache that will be exposed on all platforms. Properties like {{httpCacheSize}} should be easy to expose, methods like {{flush}}, {{install}} and {{close}} seem quite Android-specific. \r\n\r\nI would also like to consult [~jquick] for additional feedback, but due to the fact that we currently focus on bug-fixing across the SDK, this PR might need to wait for a later release than 7.1.0. We'll keep you posted in either way!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-01-16T14:12:28.000+0000", "updated": "2018-01-16T14:16:26.000+0000" }, { "id": "434439", "author": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Bumping out of 7.1.0 so we can work out a solution that's compatible with all platforms.", "updateAuthor": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-02-13T22:17:59.000+0000", "updated": "2018-02-13T22:17:59.000+0000" }, { "id": "443114", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I do agree that we should support the \"cache\" property in {{HTTPClient}} on Android.\r\n\r\nI don't like the idea of replacing our {{TiResponseCache}} with Google's {{HttpResponseCache}}. We definitely don't want to lose the custom features we've added to our class such as our relatively new \"redirect\" methods. Any new caching features we want to add should be added to our class.\r\n\r\nI don't think we should add any more network related APIs to our {{ImageView}}. I'd rather we keep {{ImageView}} simple. If an app developer wants more control over the HTTP request/response handling, then it should be done via {{HTTPClient}} and the downloaded image should then be applied to the {{ImageView}} via a file path. Case-in-point, [~topener] has created a \"ti.imageview\" module that wraps an {{ImageView}} and allows you to specify the HTTP request headers. Internally, it uses {{HTTPClient}} to do so. This is all done in pure JavaScript by dog-fooding our Titanium APIs, which means all platforms Titanium supports (Android, iOS, Windows) get this feature for free.\r\nhttps://github.com/appcelerator-modules/ti.imageview\r\n", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-10-31T00:47:56.000+0000", "updated": "2018-10-31T00:47:56.000+0000" }, { "id": "443127", "author": { "name": "s.volkov", "key": "s.volkov", "displayName": "Sergey Volkov", "active": true, "timeZone": "Europe/Moscow" }, "body": "Everything below IMHO, I mean no offence.\r\n\r\nIt's been almost two years since I wrote this patch for 6.0.0 SDK, but anyway:\r\n\r\nI understand why TiResponseCache was written in 2010, but don't see any reason to keep it now (even for your newly written methods, because HttpResponseCache should also handle redirects). It seems obvious that _less code == less bugs_ ([this|https://github.com/NetrisTV/ti.exoplayer/issues/3], for example, caused by bug in TiResponseCache: it tries to get response for POST request from cache; just have no time to properly file the issue and PR).\r\n\r\nI've seen \"ti.imageview\" (and [Topener/To.ImageCache|https://github.com/Topener/To.ImageCache] by Rene). It's seems ok, except possible overhead with copying blob from java to js and back to java; also I'm not sure how it will work with TiImageLruCache.\r\n\r\nAbout \"Android-specific API\": {{HttpResponseCache}} is in Ti.Android namespace and mirroring native module API why wouldn't it be Android specific? It's not like you already have any other incompatible API for cache control by now.\r\n\r\nI'm fine if you'll close this ticket and PR, but I'm going to keep using this patch-set for local SDK builds because currently there is no other way for my use case.", "updateAuthor": { "name": "s.volkov", "key": "s.volkov", "displayName": "Sergey Volkov", "active": true, "timeZone": "Europe/Moscow" }, "created": "2018-10-31T11:10:31.000+0000", "updated": "2018-10-31T11:10:31.000+0000" }, { "id": "443137", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Your code loses an optimization we've made in {{ImageView}} where we directly check the HTTP response cache if the image has already been downloaded before proceeding with a threaded-out HTTP request. If the cached response is a redirect, then it'll keep following it in the cache until it reaches the end-point for the image. This is especially important for our image loading APIs such as {{backgroundImage}} and {{defaultImage} which still do a \"blocking\" download.\r\n\r\nRegarding {{TiImageLruCache}}, our plan is to remove it. It's not our job to decide which images/photos should be cached and it increases the likelihood of out-of-memory exceptions. Its biggest issue is that it keeps hard reference to images. It's up to app developers to decide which images should be cached in memory and that is best done via blobs. There is no additional overhead with blob usage since an image needs to be decoded into memory before being displayed anyways. In fact, it improves image loading performance since Google's Android APIs do not cache images outside of the APK \"res\" folder. (We may implement a weak-reference cache instead; we'll see.)", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-10-31T18:52:32.000+0000", "updated": "2018-10-31T18:52:32.000+0000" }, { "id": "445208", "author": { "name": "s.volkov", "key": "s.volkov", "displayName": "Sergey Volkov", "active": true, "timeZone": "Europe/Moscow" }, "body": "I've closed the PR. Feel free to close this ticket.", "updateAuthor": { "name": "s.volkov", "key": "s.volkov", "displayName": "Sergey Volkov", "active": true, "timeZone": "Europe/Moscow" }, "created": "2019-01-11T09:53:19.000+0000", "updated": "2019-01-11T09:53:19.000+0000" } ], "maxResults": 10, "total": 10, "startAt": 0 } } }