treojs/treo

Websql works with Safari OSX but not iOS, and indexeddb seems buggy on both OSX and iOS

Closed this issue · 3 comments

I'm having trouble to get treo working on both OSX and iOS (from the same codebase). If I enable the websql fallback on Safari on OSX, then it works fine on OSX, but does not run at all on OSX. If I disable websql, then the opposite is true; the app seems to load and start up on iOS, but then the OSX version seems to halt during startup (no error messages). Despite starting on iOS without websql, there are numerous errors indicating that indexeddb still does not work properly in iOS. FWIW, I'm testing on an upgraded iPad (iOS 8.1.3) and bleeding edge OSX (10.10.2).

I've narrowed it down somewhat. I've confirmed that by default, both OSX and iOS will use websql if that options is enabled. The following simple test seems to confirm there are differences on OSX and iOS:

var stores = db.store('stores');
stores.get('app', (err, rows) => {
  console.log('rows', rows);
});

This code works differently on iOS and OSX. On OSX it works as expected. On iOS the callback never fires.

Enabling DEBUG in the shim gives me the following:

Error in sysdb transaction - when creating dbVersions [
SQLError
code: 5
message: "could not prepare statement (1 not authorized)"
__proto__: SQLErrorPrototype
CONSTRAINT_ERR: 6
DATABASE_ERR: 1
QUOTA_ERR: 4
SYNTAX_ERR: 5
TIMEOUT_ERR: 7
TOO_LARGE_ERR: 3
UNKNOWN_ERR: 0
VERSION_ERR: 2
__proto__: Object

Aaand with that error message, the reason is obvious; private browsing mode was enabled, which disables websql it seems.