Excuse the essay, but I have a very odd issue that I have singled down to Cordova which happens in a very specific circumstance on Android.
I have provided a project of the stock Cordova Android project which can be found here: http://www.filedropper.com/windowfstest - with a minor modification for the issue I am having.
I have uploaded a compiled APK to install to your device here: http://www.filedropper.com/windowfstest140509-1404
Steps to replicate are:
1) Download and install that APK onto your device (I was using the Samsung Galaxy S4 with Android 4.4.2 running, no root, and stock TouchWiz ROM, I hope this occurs on other Android devices but have not had an opportunity to verify).
2) Start the application and observe an alert appears stating 'dr', then afterwards another alert appears, 'got FS' - if you check the code, you'll see this is normal from my app.initialize().
3) Once those two alerts have appeared, press the Android 'home' button, to quit to the main Android home screen.
4) Go into another app or two and just use your phone normally. What we are trying to achieve here is for the Android memory management system to 'end'/kill the WindowFSTest app in the backend.
5) Go into Apps > WindowFSTest (i.e. the app in question) and hopefully it will have restarted - the app has to have restarted for the bug to occur, and observe a few things here:
a) Verify the app has restarted, this can be verified by the 'dr' popup occuring when Cordova loads.
b) Once you are confident the app has been restarted, observe the initial 'dr' popup, but not the 'got FS' popup - this is the bug, the window.requestFileSystem does not fire the callbacks for some reason - and I do not know why.
N.b. there are a few things to note here which is why the bug is tricky to replicate AND I imagine will be even more difficult to debug at a lower level
1) The Android system has to kill the app in the backend once you've pressed the 'home' button - there's no way of determining when this has happened, just use the phone like ordinary for half a minute or so - normally it kills it after a short period.
2) The way to restart the app is via Apps > WindowFSTest (not via the task manager).
3) **IMPORTANT** the above two steps seem to occur only when you run it from a compiled APK, not directly from source/debug APK - so it's not as easy to debug since you cannot put line breaks in the Java file(s).
Although not perfect, one way to fix this is to use:
In AndroidManifest.xml - since it ensures the app is 'resumed' instead of restarted.
I can provide a video upon request illustrating the issue.