imgcache.js
imgcache.js copied to clipboard
Uncaught TypeError: savedFS is not a function
When running imgcache I get:
Uncaught TypeError: savedFS is not a function at imgcache.js:633
Am I doing something wrong or is it a bug?
Could you please explain how you're running imgcache? This part of code should be triggered when running with Chrome.
If you run the following in your browser console, what response do you get ?
window.requestFileSystem || window.webkitRequestFileSystem
I use the angular wrapper (angular-imgcache.js#^1.1.0) and get the error when using the Chrome developer tools after running my ionic app on an Android device. If you need further detail, don't hesitate to contact me again :-)
Initially I get:
INFO: ImgCache initialising imgcache.js:49 INFO: LocalFileSystem opened imgcache.js:49 INFO: Local cache folder opened: cdvfile://localhost/persistent/imgcache/ imgcache.js:49 INFO: .nomedia file created.
After running
window.requestFileSystem || window.webkitRequestFileSystem
I get:
function (type, size, successCallback, errorCallback) { argscheck.checkArgs('nnFF', 'requestFileSystem', arguments); var fail = function(code) { if (errorCallback) { …
Strange thing is that it doesn't happen everytime. Just now and then. But when the error message pops up I mentioned in my first post, window.requestFileSystem || window.webkitRequestFileSystem returns undefined.
I've just merged a PR that fixes browser detection for ionic into master, could you please check with that version?
@chrisben Problem seems to be not fixed. Still can see it on Android devices
I'm also seeing this happen, even with the latest version of ionic-img-cache installed.
Same issue here, with version 1.2.0
Hi, I had the same issue. window.requestFileSystem
was undefined and because of this it entered the wrong path, in Chrome instead of Cordova and savedFS
also was undefined.
The solution for me was to properly wait for deviceready
event and only then to init ImageCache and start using it. I hope it helps others with same problem.
Very helpful library, thx for making it!
Thanks @csicky for pointing this out. It's actually part of the documentation:
If you're using imgcache.js with PhoneGap/Cordova, ImgCache.init() must be called after the onDeviceReady event has been triggered, not before!
Maybe this should be put somewhere more prominent :-)
I also accept pull requests for the README :) @Defcon0 : did that fix your problem ? Let me know so that we can close this issue.
@chrisben Ah, ok, I'll check later on today (or on weekend) and reply afterwards.
README paragraph now bold. There's also a bold statement in the CORDOVA.md document.
By the way I also merged my long standing 2.x branch, 2.0.0 is out now!
@chrisben Still no luck :-( The problem occurs with this code:
document.addEventListener('deviceready', function() {
ImgCache.$init();
});
called in app.module.js.
I have imgcache.js 1.1.0 and angular-imgcache 1.2.0.
for me it also does not work at all on android.
I'm also seeing this problem on android (cordova). I call init function when deviceready has been triggered.
Could someone please test the following and check what the console logs display:
document.addEventListener('deviceready', function() {
// init
ImgCache.init();
console.log('isCordova?', ImgCache.helpers.isCordova());
console.log('requestFileSystem', window.requestFileSystem);
console.log('cordova', typeof cordova);
console.log('phonegap', typeof phonegap);
console.log('platformId', (cordova||phonegap).platformId);
});
You need to install following plugins to fix the savedFS is not a function issue.
ionic cordova plugin add cordova-plugin-file --save
ionic cordova plugin add cordova-plugin-device --save
ionic cordova plugin add cordova-plugin-file-transfer --save
I've faced this issue, but found that cordova.js was missing on my app