2

We are developing web app, that uses framework that uses indexedDB. All was going fine, but then we tested it on iPad and suddenly it didn't load the page at all. Thought it would be some minor issue, but after some tests we found out, that the app is crashing on:

TypeError: null is not an Object validating 'request'

It crashes on the line :

var request = indexedDB.open("FMVare",415);

This stores null in the request variable so then after that there is:

request.onerror(...)

Which will get us the error message, written above.

I spent one day looking for a fix, but only found that iOS implemetation of indexedDb is "buggy". But I cant even open a database, so there probably is problem somewhere else. My colleague also told me, that it was working fine like 1 month before, but the file with this implementation (according to git) didn't change... ever.

I tried using pollyfill to change it to the WebSQL, again it worked everywhere except iPad browsers (Safari, Chrome). This time it was throwing different error, which I only could google as far as some SQL syntax error, which obviously couldn't be the case, if it is working everywhere else.

I have tried some suggestions, which said to replace in that pollyfill indexedDB with _indexedDB etc. but again, it worked everywhere but iPad.

When I log the variable request, it returns null. If I log indexedDB or window.indexedDB, it returns IDBFactory object, so it's there, but the .open method is failing, without calling .onerror or .onsucess method.

Since I really found many people complaining about indexedDB bad implementation on iOS, it means they were able to use it. So what could be the problem in my iPad? I mean I can try update to iOS 9, but that's not exactly what are we trying to achieve.

I tried deleting cache, changing version number(greater and smaller), creating different database (different name), pollyfill... but still can't get it working, everytime i call indexedDB.open(databasename), it returns null and crashes.

Any ideas?

EDIT: The error I'm getting with shim is

Error in sysdb transaction - when creating dbVersions.

Then I get the SQLError object with

"code: 5"

and

"message: could not prepare statement (1 not authorized)"

The error happens in createSysDB(success, failure) function of the shim.

UPDATE: I tried an app on iPad called WebView Rendering so i could try if WKWebView would be capable of running my app. And it was! So the problem really was the UIWebView support of IndexedDB.

Seems very strange to me though, that you can't use IndexedDB on iOS Safari even after update on latest iOS version.

ezpzlmnsqz1337
  • 394
  • 1
  • 5
  • 16
  • Have you tried debugging the shim. My guess is that there goes something wrong with the creation of the IDBOpenDBRequest object of the shim. – Kristof Degrave Nov 19 '15 at 10:14
  • Can you be more specific how to do that? I use Telarik app to debug my iPad (since I'm using windows on my pc...) but I don't know how to go deeper than: var request = indexedDB.open(dbname,version); console.log(request); – ezpzlmnsqz1337 Nov 19 '15 at 10:52
  • 1
    maybe start with turning on debugging for the shim ´window.shimIndexedDB.__debug(true);´ Did you take a look at this (https://github.com/axemclion/IndexedDBShim#known-issues) and mybe try to log ´new window.shimIndexedDB.IDBOpenDBRequest()´ – Kristof Degrave Nov 19 '15 at 11:50
  • I have debuging enabled. The error I'm getting is "Error in sysdb transaction - when creating dbVersions". Then I get the SQLError object with "code: 5" and "message: could not prepare statement (1 not authorized)". The error happens in createSysDB(success, failure) function of the shim. But I'm not able to tell what's causing this error in the iPad, when it works everywhere else. I checked your link, but I tried those workarounds already. – ezpzlmnsqz1337 Nov 19 '15 at 12:23
  • I guess this will be an issue with the webSQL Implementation on safari. Maybe you should add the websql tag to your question. – Kristof Degrave Nov 19 '15 at 12:31
  • I will probably solve this, by making native iOS app with WKWebView for displaying the app. I'll report my findings once I'll have that done. – ezpzlmnsqz1337 Nov 24 '15 at 07:20
  • Having problem with the shim on IOS devices aswell. How did you solve the problem? – Abris Dec 30 '15 at 09:19
  • Look at my update part. WKWebView native app did solve it for me. – ezpzlmnsqz1337 Dec 31 '15 at 10:41

0 Answers0