Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

localForage 1.5: IndexedDB not available anymore in iOS <10.3 despite installed base due to 1.4.3 bug #676

Closed
denis1994 opened this issue Mar 21, 2017 · 15 comments
Milestone

Comments

@denis1994
Copy link

denis1994 commented Mar 21, 2017

bug: localForage 1.4.3 enables AsyncStorage (IndexedDB) on iOS 10

The default storage changes from WebSQL to AsyncStorage (IndexedDB) on upgrading from iOS 9 to iOS 10 with localForage 1.4.3.

  • localForage 1.4.3, iOS 9.3 (tested in iPhone Simulator)
	- Default driver: "webSQLStorage"
	- Supported drivers: ["webSQLStorage","localStorageWrapper"]
  • localForage 1.4.3, iOS 10.2, iPhone 6s Simulator
	- Default driver: "asyncStorage"
	- Supported drivers: ["asyncStorage","webSQLStorage","localStorageWrapper"]

This seems to be a bug - as this behavior has now been 'fixed' with #651

problem: actual users using IndexedDB in iOS 10, 10.1 & 10.2 can't access their data anymore with localForage 1.5

  • we have now users in our installed base who actually use this IndexedDB in iOS 10 - below the Safari 10.1 (i.e., without the reworked IndexedDB2.0 in Safari 10.1, which gets released with iOS 10.3).

  • However, localForage 1.5 disables using the IndexedDB on iOS <10.3 (Safari <10.1), i.e., we can't access that previously already used storage option

  • reverting to 1.4.3 is not an option, as we need to use localForage 1.5 to have the correct behaviour to new users

request for solution: re-enable IndexedDB for Safari < 10.1 (as option with warnings)

--> Request: re-enable IndexedDB for Safari < 10.1 in localForage 1.5 with an option (and some warning to not use this)

This would enable us to create a migration back to WebSQL on iOS <10.3 for our installed base users

@thgreasi
Copy link
Member

According to #604 #650 #651 we added support for IndexedDB in Safari 10.1+ in LF v1.5.
Are you sure that you used IndexedDB under iOS 10 with v1.4.3 ?
Also please take a look at the v1.5 changelog.

Lastly, you might want to use localForage-cordovaSQLiteDriver in your implementation.

@denis1994
Copy link
Author

I was also surprised that IndexedDB is used.

I'm using now localForage-cordovaSQLiteDriver but for the migration to it, I want to read the data from the IndexedDB.

@thgreasi
Copy link
Member

That's really strange and I'm not sure how I can help you.
What happens if you setDriver() to INDEXEDDB and try to retrieve the data? Does it respond with something like "no storage method found"?
Also, please try retrieving the data from WEBSQL and post back your findings.

@denis1994 denis1994 changed the title IndexedDB not supported in 1.5 under iOS 10 localForage 1.5: IndexedDB not available anymore in iOS <10.3 despite installed base due to 1.4.3 bug Mar 22, 2017
@denis1994
Copy link
Author

denis1994 commented Mar 22, 2017

I updated the first post, please take another look on it.

You can verify this conveniently in the iOS Simulator for the different iOS versions. The iOS Simulator ships with Xcode. No fiddling with different devices needed, just a Mac.

@thgreasi
Copy link
Member

thgreasi commented Mar 22, 2017

Can you also post the navigator agent strings that the two iOS emulators report?

@denis1994
Copy link
Author

  • iOS 9.3:

Mozilla/5.0 (iPhone; CPU iPhone OS 9_3 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13E233 (140474252009280)

  • iOS 10.2:

Mozilla/5.0 (iPhone; CPU iPhone OS 10_2 like Mac OS X) AppleWebKit/602.3.12 (KHTML, like Gecko) Mobile/14C89 (140445468367168)

@thgreasi
Copy link
Member

Here is a jsbin with my findings (using the user agent strings that you shared). Please run it on webkit, so that websql is also available.

9_3 1.4.3: true 1.5.0: false
10_2 1.4.3: true 1.5.0: true
// true stands for IndexedDB support

You are right that iOS 9.3 is detected as capable of IndexedDB, but since safari < 10.2 had a buggy IndexedDB implementation we tried to avoid it.
The thing is that in v1.4.3 the user agent test was just /Safari/, while in v1.5.0 it is /(Safari|iPhone|iPad|iPod)/ which seems more correct. As a result, we invalidly made IndexedDB available to safari on iOS etc. I'm not sure what we can do about v1.4.3 to solve this issue for safari v9.3 users that have saved their data on IndexedDB. @tofumatt any ideas?

PS: a hacky workaround to re-enable IndexedDB on iOS < 10.2 with localforage v1.5 on your responsibility, would/could be to:

  • detect safari < 10.2
  • use localforage.getDriver('asyncStorage') to retrieve the indexeddb driver
  • change the driver name by setting it to something else eg: driver._driver = 'muindexeddb'
  • user localforage.defineDriver(driver) & setDriver('muindexeddb') to re-define and set indexeddb as a new driver.
  • feel too hacky & fear for the results

@tofumatt
Copy link
Member

tofumatt commented Mar 27, 2017 via email

@thgreasi
Copy link
Member

From my understanding we should only support indexeddb on desktop safari for now?

I think that IndexedDB works both on desktop and iOS safari 10.2 but in neither environments before 10.2 .
The bad thing is that in lf v1.4 we didn't check for the iOS agent strings. We should have done that. As a result there probably are lf1.4 safari 9 iOS users having their data stored in the flaued IndexedDB implementation.

Could we possibly create a configuration option to set compatibility: '1.4' for those that prefer to use the old IndexedDB validity detection code?

@thgreasi
Copy link
Member

How about creating a custom driver that inherits WebSql but uses the old detection and only runs on safari? That way we could have a clear upgrade path like:

After upgrading to lf v1.5 & in order to keep safari users on their existing storage driver, please use the oldWebsqlSafari driver setDriver(['OldWebsqlSafariDriver', localforage.INDEXEDDB, localforage.WEBSQL, localforage.LOCALSTORSGE]).

@tofumatt
Copy link
Member

tofumatt commented Apr 30, 2017 via email

@thgreasi
Copy link
Member

@denis1994 & @tofumatt How would you feel for a compatibility plugin with the following api:

var driverPreferenceOrder = [
  localforage.INDEXEDDB,
  localforage.WEBSQL,
  localforage.LOCALSTORAGE
];

localforageCompatibility1_4.config().then(function() {
  localforage.config({
    driver: driverPreferenceOrder
  });
  // or
  // return localforage.setDriver(driverPreferenceOrder);
}).then(function() {
  // your LF code here
});

@tofumatt
Copy link
Member

That works for me, should make it easy for folks to create a new instance and transfer their data over 👍

@thgreasi
Copy link
Member

Happy to hear that. I will need a review on #723 for this and we can probably release it as 1.5.1

@thgreasi
Copy link
Member

@denis1994 localForage-compatibility-1-4 was just released to resolve this issue. Please check it out, I hope that you will like it.
Closing this for now. Feel free to re-open in any case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants