Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26145] Windows: Improve File.getDirectoryListing() performance in Resources directory

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2018-06-28T06:41:37.000+0000
Affected Version/sRelease 7.3.0
Fix Version/sn/a
ComponentsWindows
Labelsperformance
ReporterJoshua Quick
AssigneeKota Iguchi
Created2018-06-21T04:15:49.000+0000
Updated2018-06-29T05:36:19.000+0000

Description

*Summary:* On Windows, accessing files/directories under "Resources" is slower than it should be. These files are stored within the APPX 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));
*Recommended Solution:* An Windows APPX is really a zip file. We should open the APPX 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.

Comments

  1. Kota Iguchi 2018-06-28

    Closing as invalid, I observed the symptom completely wrong. There should be no difference between reading resource directory and other directory because all contents in appx end up extracted into normal directory so technically there's no need to "unzip" it.
  2. Joshua Quick 2018-06-28

    That's sounds about right. A Windows Phone Silverlight XAP app is unzipped as well. So, I wouldn't be surprised if APPX worked the same way. But this should mean getDirectoryListing() performance should be roughly the same between the "Resources" directory and any other directory on storage, right? The only major difference is that we should be listing the encrypted JS files under "Resources" as well and merging that list with what we've grabbed from storage.
  3. Kota Iguchi 2018-06-29

    Yes, getDirectoryListing performance should be roughly same. One interesting thing is that applications are stored in restricted folder called WindowsApps to isolate the app onto sandbox (I guess) so it may be slightly affecting to the performance but it should be very small.

JSON Source