[TIMOB-12816] Android: Clean up the Image View
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-03-14T00:10:23.000+0000 |
Affected Version/s | Release 3.1.0 |
Fix Version/s | Release 3.1.0, 2013 Sprint 05 API, 2013 Sprint 05 |
Components | Android |
Labels | n/a |
Reporter | Ping Wang |
Assignee | Ping Wang |
Created | 2013-02-21T23:48:06.000+0000 |
Updated | 2017-03-16T21:00:21.000+0000 |
Description
Since we did many image operations in UI thread, for example creating the drawable reference from file or URL and resizing the image after it's loaded, the Table View with remote images was very slow (TIMOB-11282). To fix that, we moved some of those operations to non-UI threads and tried to run them in parallel using multiple threads. But this [fix](https://github.com/appcelerator/titanium_mobile/pull/3395) introduces several other issues: (see the comments in TIMOB-11282 for more info)
1. The RejectedExecutionException can happen when workqueue in the ThreadPoolExecutor is full and the Executor cannot accept more tasks.
2. Even when the image is in the cache, it is not fetched/used correctly.
3. Since rows with the same className are reused, when the table is scrolled, rows will first render the old images, then update with the correct content.
Need to clean up the code in the image view and fix the above issues.
I can confirm that this was not properly fixed. Not only that it makes the table view completely useless and MUCH slower than 3.0.0 GA. Cannot use this build.
PR https://github.com/appcelerator/titanium_mobile/pull/3936 In this PR, 1. Use TiDownloadManager which uses an unbounded pool to cache the remote images in the SD card instead of AsyncTask because AsyncTask uses a bounded pool and it may cause RejectedExecutionException. 2. Implement TiLoadImageManager which uses an unbounded pool to fetch and decode bitmaps. 3. Use both memory cache and disk cache. 4. Don't pre-scale the images in our code. Let native Android take care of scaling. 5. Download and decode bitmaps in the background thread so it won't block the UI.
Closing ticket as fixed.