question

robin avatar image
robin asked

Kindle Fire HD7 - File System API Insight needed file write

Have attempted File System API example, but unable to determine where files are saved [1] Is there a Kindle security setting that need be modified to get this example to work? C.R.U.D. is available "in a sandboxed section of a local file system. The File System API makes it easier to store data locally without using a database." [1] When following the W3 spec and examples, modifying the methods and attributes to PERSISTENT or window.PERSISTENT the web page result just renders a blank page [2][1] I am able to view the Html page on the host server using Firefox on a desktop PC running WinXP Pro When I load that Url into the WebApp Tester 'Enter your app URL' and depress 'Save' then launch, the screen within the WebApp Tester remains white. Attempting to view errors using LogCat only show sensors data for the accelerometer. No error messages appear to be generated, and the example doesn't appear to execute. Any assistance to move forward troubleshooting would be helpful. e.g. Where in the file system will WebApp Tester error messages be? What other debug methods are available when LogCat doesn't show msgs? [1] http://docs.aws.amazon.com/silk/latest/developerguide/html5-apis.html#file-system-api [2] http://www.w3.org/TR/file-system-api/ Thank you, Robin
fire tablet
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Robin, Thank you for writing to us. Have you tried running the File System API example on Silk browser in Kindle? Does it work there?
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

robin avatar image
robin answered
In the original post entry, I wasn't definitive in explaining the page loads were within the Silk browser instance. When that failed, and for comparison, I then attempted in the web-app tester instance. Just recently in a separate thread, it was explained the web-app tester is using a web kit .apk wrapper to launch within it's own process space. I now understand they are in fact separate and distinct. At that time, I was attempting to provide as much information as possible to locate the run time issue. I'm not a Java developer. When I load the example from [1] "File System API" in the Silk browser, and click the 'Create Files' button, the page does in fact render two bulleted items. When I use ES3 to view "/mnt/sdcard/" there are no folders or files that are present nor do any existing file-folder time stamps change value. Scanning other folders at random doesn't show any other file-folder time stamps changing value either. The code: fileSystem.root.getFile implies the root of the folder structure. I looked there and even backing out of the /sdcard/ sub-folder and also opening each /data/ folder I could locate. While the attribute for code: window.webkitRequestFileSystem(window.TEMPORARY indicates 'TEMPORARY' I suppose a file may never be made persistent as the attribute isn't requesting that. But, that idea contradicts what the spec implies. 4.1 Temporary vs. Persistent Storage [3] "Temporary storage may . . . , but the data stored there may be deleted at the UA's convenience, e.g. to deal with a shortage of disk space." This implies the files are written to the file system. ref: "data stored there may be deleted" So, . . . I followed the W3 spec [3] from inside [1] below and it can be determined that: Using [1] and it's reference to [2] we know that we are dealing with a physical file on the device. Sect 1 Intro [2] "The File interface represents file data typically obtained from the underlying file system" Following the attributes in [4] changing window.TEMPORARY to window.PERSISTENT 4.4.1 Using LocalFileSystem [3] "All instances of the Window type are defined to also implement the LocalFileSystem interface." then attempting to click on the 'Create Files' button, only produces a white screen within the Silk browser, leaving only the button visible and no bulleted items. Checking the folder "/mnt/sdcard/" no folders or files that are present nor do any existing file-folder time stamps change value. Also in a separate test using the code example Sec 2.2 [4] var tempFS = requestFileSystem(TEMPORARY, 1024 * 1024); produced the same result. No effect. If one is developing a Html5 app and viewing through Firefox, one may use Firebug to view internal data and step through code. LogCat seems (I'm not a Java developer) to be the means when one develops a native .apk app and test via the web-app tester. The Silk browser doesn't appear to have this luxury. Note: The example [1] shows code: console.log("An error occurred."); but those type of Html entries don't appear within LogCat when I run through the Silk browser. In separate tests, they do output when viewing when started from the web-app tester. Q1: What is the suggested debug methodology for this type of Html5 page using *any* of the APIs listed? [1] e.g. how to step through code? Q2: Where are the files written? folder-path? Q3: What other Silk resources are available to we developers other than [1] and it's suggested hyperlink references? Q4: Are there any of these examples deployed at an Amazon web site, such that we developers may d/l-view-test-learn rather than rely on incomplete available documentation? Ultimately, this has to work in order for we Html5 developers to overcome the Kindle app-store limitation imposed on us, to *move* resources for Html5 apps that are d/l from the Amazon store that run in the web kit .apk instance, into a Html5 app that requires use of localStorage that is only available inside the Silk browser instance that can not be d/l from the Amazon store. Note: as localStorage has to be called within the page at a specified domain, it is not possible to pull the data from the process space of the purchased d/l instance that runs inside the web kit web-view instance. More examples would help please. Latest ver 7.4.6_user_4620220 swipe down >> device >> about Silk ver 1.0.68.293-Gen5_34034610 Thank you, Robin [1] http://docs.aws.amazon.com/silk/latest/developerguide/html5-apis.html#file-system-api [2] http://www.w3.org/TR/FileAPI/ [3] http://www.w3.org/TR/file-system-api/ [4] http://www.w3.org/TR/file-system-api/#temporary-vs.-persistent-storage
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

robin avatar image
robin answered
I have created some additional test pages, deployed them on a remote host and are able to view the rendered button inside the Silk browser. When using the app tester to launch and view debug detail within the Chrome debugger, Type errors occur when using the following: Using apparent Amazon proprietary 'webkitRequestLocalFileSystem()' Test: 'window.PERSISTENT' window.webkitRequestLocalFileSystem(window.PERSISTENT, 5*1024*1024, onInitFs, errorHandler); "Uncaught TypeError: Object [object global] has no method 'webkitRequestLocalFileSystem'" Test: 'PERSISTENT' window.webkitRequestLocalFileSystem(PERSISTENT, 5*1024*1024, onInitFs, errorHandler); "Uncaught TypeError: Object [object global] has no method 'webkitRequestLocalFileSystem'" W3C literal method name 'requestFileSystem' Test: 'window.PERSISTENT' with W3 spec defined method 'requestFileSystem' window.requestFileSystem(window.PERSISTENT, 5*1024*1024, onInitFs, errorHandler); "Uncaught TypeError: Object [object global] has no method 'requestFileSystem'" Test: 'PERSISTENT' with W3 spec defined method 'requestFileSystem' window.requestFileSystem(PERSISTENT, 5*1024*1024, onInitFs, errorHandler); "Uncaught TypeError: Object [object global] has no method 'requestFileSystem'" This line does execute, but only the page elements are updated. window.webkitRequestFileSystem(window.TEMPORARY, 5*1024*1024, onInitFs, errorHandler); Using ES3 and RS [1][2] I am not able to find any reference to ' exampleFile.txt' and 'exampleDirectory' anywhere I have attempted modifying the directory path-folder to other visible folder name in a last ditch effort. The /data/ folder is empty and has the date of my purchase d/w attr 'Empty Folder' The /root/ folder is empty and has the date of my purchase d/w attr 'Empty Folder' /data /system/app/ /root/ If I look under /sdcard/data/ only one folder there 'flixter' /sdcard/ /sdcard/data/ /sdcard/Download /sdcard/amazon_sdktester Q1: Has the above been duplicated by Amazon AWS staff? e.g. is it a known issue or specific to my KF HD7 Q2: Should the 'window.TEMPORARY' attribute create a physical file on the device? [W3 spec says yes] Q3: If yes to Q2, where on the device is the file created, so that I can verify File I/O The Chrome debugger steps over the init methods, blocking the ability to trap inside the API methods Robin File explorers [1] ES3 ES Mobile [2] Rhythm Software Folder with gear
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Robin, The example works on the new Amazon Web View which is present on up-to-date 2nd (HD 7 and HD 8.9 ) and 3rd generation devices. The API is supported in Chromium-based Amazon Web View and the API works in said devices. The example does not work on the Android Web View which is used for Kindle 1st generation and all generic Android devices.
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

robin avatar image
robin answered
The response presented and the example apply to temporary storage only. That wasn't my original post inquiry which indicated persistent storage. As I indicated in entry above, 'Posted: Oct 17, 2013 10:14 AM' I agree the example given does in fact execute, but it only creates TEMPORARY storage, hence the reason I posted this thread to inquire about PERSISTENT storage. See fourth sentence in opening entry "modifying the methods and attributes to PERSISTENT or window.PERSISTENT" Why we don't want temporary storage as, directly from the W3 spec: "Temporary storage may be easier to get, at the UA's discretion [looser quota restrictions, available without prompting the user], but the data stored there may be deleted at the UA's convenience, e.g. to deal with a shortage of disk space." For Html5 apps, localStorage is too restrictive and blocks a user from deploying multiple apps (that require use of localStorage) in the same domain as sub-domain requirements are additive. Should we make use of temporary file storage, there is no guarantee that our saved data will be there on next application launch. Any app store Html5 app that downloads paid for resources will have that content sandboxed within the .apk wrapper instance and therefore there isn't a mechanism to get the data available from a Silk browser request. The Silk browser is key here as the end user is famialiar navigating the web with it, saving bookmarks and favorites and getting to the app store where, if I may, the content for sale for profit resides. Back to the PERSISTENT flag and user granting permission dialog error. Have been successful at retrieving a temporary requestQuota() of 1.17Gig but, I have attempted many iterations for persistent data using examples at https://developers.google.com/chrome/whitepapers/storage#query and continue to get this error, and in ten seconds followed by the web-app tester crashing. The same is true should I launch this in the Silk browser, but crashes the Silk browser after thirty seconds window.webkitStorageInfo.requestQuota(webkitStorageInfo.PERSISTENT, 32*1024, grantedBytes); 11-09 10:56:41.883: A/libc(25014): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1) 11-09 10:56:42.289: I/DEBUG(24991): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 11-09 10:56:42.289: I/DEBUG(24991): Build fingerprint: 'Android/tate/tate:4.0.3/IML74K/7.4.6_user_4620220:user/release-keys' 11-09 10:56:42.289: I/DEBUG(24991): pid: 25014, tid: 25041 >>> com.amazon.webapps.performancetester <<< 11-09 10:56:42.289: I/DEBUG(24991): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000 followed by a byte data dump too lengthy to list here. As you'll note, 'Fatal' indicates to me either the web-app tester is not capable of providing the detail needed for we developers to debug this example, the Kindle OS doesn't support what the AWS web page indicates it does, there is a catch-22 in that it might work only after an app submission wherein the approval team fiddles with the resultant .apk file, or some other mysterious reason which has not been responded to by the requests posted here. Should the above line of code not be what is required to execute on Kindle devices, please provide we developers a link to a working example that we may launch directly from the web-app tester. As the FileSystem API is sandboxed along with Html5 localStorage, there shouldn't be any reason the above request couldn't be met and a simple sample deployed. It could even appear as a page here within the / forums.developer.amazon.com/ space for developers once logged in. This would save enormous amounts of wasted developer struggle trying to guess what does work, what the development teams actually has tested and would save the need for we developers to post here in an attempt to obtain precious missing documentation. Could it be my device is not updating to the latest OS release? Silk browser seems to have updated. Latest ver 7.4.6_user_4620220 Silk ver 1.0.135.187-Gen5_38038010 Robin
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.