Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-26144

Android: Improve File.getDirectoryListing() performance in Resources directory

    Details

    • Story Points:
      5
    • Sprint:
      2018 Sprint 13 SDK, 2018 Sprint 14 SDK, 2018 Sprint 15 SDK, 2018 Sprint 16 SDK, 2016 Sprint 17 SDK, 2018 Sprint 18 SDK, 2018 Sprint 19 SDK

      Description

      Summary:
      On Android, accessing files/directories under "Resources" is slower than it should be. These files are stored within the APK where a list of file paths from "assets" can be easily extracted... which should make it faster than storage access.

      Test:
      Run the below code to fetch a listing of all files under the "Resources" directory. Observe the log for the duration of this function.

      var startTime = new Date();
      var file = Ti.Filesystem.getFile(Ti.Filesystem.getResourcesDirectory());
      var listing = file.getDirectoryListing();
      Ti.API.info("@@@ getDirectoryListing() duration: " + (new Date() - startTime));
      

      Results:
      For a project have about 160 files under "Resources", I get the following results...

      • Android 4.1 Emulator: 80 ms
      • Galaxy Nexus (Android 4.1): 70 ms
      • Amazon Fire HD 8 (7th Generation): 19 ms
      • Pixel XL (Android 8.0): 3 ms

      Recommended Solution:
      An Android APK is really a zip file. We should open the APK as a zip file and fetch/store all zip entries referencing files under the "assets" directory. This way we can have fast hash table lookups when doing existence checks and fetching directory listings.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jquick Joshua Quick
                Reporter:
                jquick Joshua Quick
                Reviewer:
                Gary Mathews
                Tester:
                Lokesh Choudhary
              • Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Source Code