imgcache.js icon indicating copy to clipboard operation
imgcache.js copied to clipboard

Uncaught TypeError: savedFS is not a function

Open Defcon0 opened this issue 7 years ago • 18 comments

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?

Defcon0 avatar Apr 01 '17 12:04 Defcon0

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

chrisben avatar Apr 01 '17 12:04 chrisben

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.

Defcon0 avatar Apr 01 '17 12:04 Defcon0

I've just merged a PR that fixes browser detection for ionic into master, could you please check with that version?

chrisben avatar Apr 01 '17 12:04 chrisben

@chrisben Problem seems to be not fixed. Still can see it on Android devices

adascal avatar Sep 12 '17 16:09 adascal

I'm also seeing this happen, even with the latest version of ionic-img-cache installed.

ghost avatar Oct 25 '17 17:10 ghost

Same issue here, with version 1.2.0

jyve avatar Oct 28 '17 09:10 jyve

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!

csicky avatar Nov 08 '17 13:11 csicky

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!

chrisben avatar Nov 09 '17 13:11 chrisben

Maybe this should be put somewhere more prominent :-)

Defcon0 avatar Nov 09 '17 13:11 Defcon0

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 avatar Nov 09 '17 15:11 chrisben

@chrisben Ah, ok, I'll check later on today (or on weekend) and reply afterwards.

Defcon0 avatar Nov 09 '17 15:11 Defcon0

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 avatar Nov 09 '17 16:11 chrisben

@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.

Defcon0 avatar Nov 10 '17 16:11 Defcon0

for me it also does not work at all on android.

renanmoraes avatar Feb 06 '18 18:02 renanmoraes

I'm also seeing this problem on android (cordova). I call init function when deviceready has been triggered. image

yurii-zadryhun avatar Mar 26 '18 08:03 yurii-zadryhun

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);
});

chrisben avatar May 06 '18 07:05 chrisben

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

ragunathans avatar Jul 12 '18 09:07 ragunathans

I've faced this issue, but found that cordova.js was missing on my app

vdias38 avatar Sep 23 '20 06:09 vdias38