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

iOS 8.4 put only works the second time #76

Open
gabrielmaldi opened this issue Aug 19, 2015 · 4 comments
Open

iOS 8.4 put only works the second time #76

gabrielmaldi opened this issue Aug 19, 2015 · 4 comments

Comments

@gabrielmaldi
Copy link
Contributor

Hi, thanks for this awesome library. I was just playing around with it and found two very related issues:

With this simple code:

var db = new ydn.db.Storage("TestDatabase", {
    version: 1,
    stores: [{
        name: "TestTable",
        keyPath: "myId",
        autoIncrement: false
    }]
});
db.onReady(function (e) {
    if (e) {
        console.log(e);
        throw e;
    }

    db.get("TestTable", 12345).then(function (record) {
        if (record) {
            console.log("Record found:");
            console.log(record);
        } else {
            console.log("Record not found, adding it...");

            db.put("TestTable", {
                myId: 12345,
                myName: "Foo"
            }).then(function (r) {
                console.log("Record added:");
                console.log(r);
            });
        }
    });
});

The put call only works the second time I run the app on an iPhone with iOS 8.4 (the code runs inside a UIWebView). This is the output:

First run
"Record not found, adding it..."
"Record added:"
12345
Second run
"Record not found, adding it..."
"Record added:"
12345
Third run
"Record found:"
{"myId":12345,"myName":"Foo"}

The same code inside a UIWebView on iOS 7.1 works just fine:

First run
"Record not found, adding it..."
"Record added:"
12345
Second run
"Record found:"
{"myId":12345,"myName":"Foo"}

So that's the first issue I wanted to report.

I then went ahead and created a Plunker to be able to try the code in iOS Safari (instead of the UIWebView): http://embed.plnkr.co/ldYHBaXhkyrMw9ksSYqj/preview

Note that the code in that Plunker contains:

mechanisms: ["websql"]

These are the different scenarios:

  • iOS Safari 7.1 without mechanisms: works fine
  • iOS Safari 8.4 without mechanisms: ydn.db.TimeoutError when creating the database
    • This is the second issue I wanted to report. It seems that the library isn't picking WebSQL as the default for iOS Safari 8.4 when it really should (since IndexedDB has known issues).
  • iOS Safari 8.4 without mechanisms: creates the database but needs two calls to put to actually add the record (just like the first with UIWebView).

mechanisms doesn't make a difference in UIWebView: even with it we need two calls to put.

I'm using YDN-DB I got from this page, more specifically from here.

Thanks!

@yathit
Copy link
Owner

yathit commented Aug 19, 2015

Could you try using this raw file https://storage.cloud.google.com/ydn-db-d1/1.3.2/ydn.db-isw-core-e-cur-qry-dev-raw.js ?

Thanks for the report.

@gabrielmaldi
Copy link
Contributor Author

With that raw file the result is the same: on an iOS 8.4 UIWebView I have to run the app twice for the record to be added.

@yathit
Copy link
Owner

yathit commented Aug 19, 2015

iOS 8.4 UIWebView I have to run the app twice

Can you figure out why?

@chaserstrong
Copy link

chaserstrong commented Dec 14, 2016

I have faced the same issue when i ran my web app on ios10.0.2 . After second time ,it shows like that :

unable to open database (14 unable to open database file)
connect — ydn.db-is-core-qry.js:5773:90
Od — ydn.db-is-core-qry.js:2005:98
o — ydn.db-is-core-qry.js:1974
T — ydn.db-is-core-qry.js:1949
Je — ydn.db-is-core-qry.js:3532
X — ydn.db-is-core-qry.js:3591
Sf — ydn.db-is-core-qry.js:6008
openDB — service.js:198
queryLastUpdateAt — service.js:59
syncReport — service.js:539
(匿名函数) — login.js:38
n — angular.min.js:2828
$eval — angular.min.js:3864
$digest — angular.min.js:3798
$apply — angular.min.js:3892
(匿名函数) — angular.min.js:2836

And i use the same js plugin mentioned above. Have you ever solved this issue? @yathit

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