Problems with Ionic + localForage + IndexedDB


#1

Hi,

I am having with this configuration on android devices with low available disk space (< 1 gb). When I try to write with:
localforage.setItem

It returns this error:

vendor.js:1 ERROR Error: Uncaught (in promise): QuotaExceededError
    at c (polyfills.js:3)
    at polyfills.js:3
    at IDBTransaction.r.onabort.r.onerror (vendor.js:1)
    at IDBTransaction.H (polyfills.js:3)
    at t.invokeTask (polyfills.js:3)
    at Object.onInvokeTask (vendor.js:1)
    at t.invokeTask (polyfills.js:3)
    at r.runTask (polyfills.js:3)
    at e.invokeTask [as invoke] (polyfills.js:3)
    at p (polyfills.js:2)

With > 1Gb of available disk space it works fine.

Inspecting with chrome on devices with enough available disk (>1gb) storage the aplication tab shows this:

330mb of quota.

With mobiles with low available disk space (< 1gb) inspector shows 1kb of 1kb quota available

I already know that the space available to store information is up to quota by I can’t understand how a mobile with 600-700mb of available disk storage sets quota to unusable value.

Is this normal?

Ionic info:

@ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1
global packages:
    cordova (Cordova CLI) : 7.0.1 
local packages:
    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 6.4.0 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2
System:
    Android SDK Tools : 26.1.1
    ios-sim           : 6.1.2 
    Node              : v10.0.0
    npm               : 5.6.0 
    OS                : macOS High Sierra
    Xcode             : Xcode 9.3 Build version 9E145

LocalForage library version: 1.7.1


#2

Does not sound normal, but it depends. Mobile devices often advertise 1GB of memory and then you realize most of it is already hard devoted to OS backup etc.

If you have access to more of devices try that and compare.


#3

I have tried on emulator(Nexus 5x) , Sony and Samsung devices J3, J5, J7.


#4

Someone no founded in this problem with indexeddb?


#5

Hi @Hanzo,

I’m also facing same issue but with IonicStorageModule (’@ionic/storage’) using indexedDB. Did you find any solution?

Thanks,
Messy


#6

Unfortunately not. I asked into the official repo of localForage with no lucky.

They says that is a cordova problem and recommend switch to sqlLite driver on cordova apps.

Switching to sqlLite driver solves the problem. Also i recommend you to choose the order of driver preference choosing indexeddb the last option.
LocalStorage driver has a 10mb dedicated space to storage info. The other ones uses system quote tha is the origin of the problem.
[sqllite,localStorage…indexeddb]


#7

I’m happy to see this post (well, not happy for your problems, but happy that I’m not the only person facing this issue). I posted this a few days ago: Compatible Data Storage: Is it this hard?

To address your Qs:

  1. I found that on some Android phones, IndexDB configuration worked, but setItem failed. One reported phone was a Huawei phone running Android 7, while the other was a Samsung Note running android 5.x - so its not really “legacy phones only” Both phones had 800MB+ of free storage. Its interesting you got a QuotaExceeded error. In my case, the error handler simply returned an empty response. It was also interesting to see your available space experiments - given my issues occurred with phones that I don’t own (reported by non-technical users) it was not possible for me to debug deeper beyond a point. There may be something to your conclusion: a threshold for available space is what is causing it

  2. I found that on some Android phones, trying to save a large data blob in SQLite via local forage caused the phone to freeze

  3. Bottom line, I found data store to be somewhat of a mess if you have an app that is widely deployed

I finally reverted to a strategy of trying an actual setItem/getItem that tried to test the selected storage every time the app ran and if it failed, fell back to another medium. You’d think this is what local forage’s setDriver should do with an array of DB order, but it seems to have no problem configuring a medium that doesn’t really work in practice. I do fear a situation where its possible in some random run, the test indicates that a proper medium is invalid due to some odd issue, but so far it seems to be holding on.

My app is ionic- v1, but this doesn’t really matter. The core problem is the same.


#8

You have an option to debug this problem. Configure an android 7.0 emulator with low storage. Then try to execute the app and debug their logs.

Also debug the app execution with ‘Application’ chrome dev tools section and you will can see how the quote is very lower and unnusable.


#9

I’ve actually tried that option.
I have a 7.1.1 image configured with 500MB internal storage and no errors happen.

With respect to remote chrome debugging, I don’t see any quota graph like in your screenshot. Here is what I see :

In the “clear storage” part, there is no graph either