Unable to get/save contacts via the API immediately after pushing a reference database

NEW
Unassigned

Status

()

Core
DOM: Contacts
5 years ago
5 years ago

People

(Reporter: davehunt, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

5 years ago
You will need a device running an engineering build so you can use Marionette to execute asynchronous JavaScript. Also, please note that data will be wiped from the device.

Steps to reproduce:
1. Download https://github.com/mozilla-b2g/gaia/raw/master/test_media/reference-workload/contactsDb-200.sqlite
2. Connect B2G device with master engineering build via USB
3. Run the following from the command line:

$ adb forward tcp:2828 tcp:2828
$ adb shell stop b2g
$ adb shell rm -r /data/local/indexedDB/chrome/idb/*csotncta*
$ adb push contactsDb-200.sqlite /data/local/indexedDB/chrome/idb/3406066227csotncta.sqlite
$ adb shell start b2g

4. Wait for B2G to start
5. Run the following to install the Marionette client:

$ pip install marionette_client

4. Start a Python interactive shell and run the following:

>>> from marionette import Marionette
>>> m = Marionette()
>>> m.start_session()
u'6-b2g'
>>> print m.execute_async_script("SpecialPowers.addPermission('contacts-read', true, document); var req = window.navigator.mozContacts.find({}); req.onsuccess = function () { marionetteScriptFinished(req.result) };", special_powers=True, script_timeout=60000)

Expected:
Details of the 200 contacts should be output to the console

Actual:
The script times out

If you run the last Marionette command a second time, it is successful. It seems there's an issue performing contacts API calls on a fresh reference database.

Comment 1

5 years ago
Looks like this is using contacts API directly, so updating component.
Component: Gaia::Contacts → DOM: Device Interfaces
Product: Boot2Gecko → Core
The reference database probably uses an old DB schema and we have to iterate over all contacts and modify them when we do a schema upgrade. This might take some time. Can you try to increase the timeout to see if it works?
(Reporter)

Comment 3

5 years ago
(In reply to Gregor Wagner [:gwagner] from comment #2)
> The reference database probably uses an old DB schema and we have to iterate
> over all contacts and modify them when we do a schema upgrade. This might
> take some time. Can you try to increase the timeout to see if it works?

The strange thing is that this can time out after 10 seconds and trying again immediately with a 10 second timeout works. Trying with a 60 second timeout fails, and I have also tried a 3 minute timeout without success.
From what I saw of the conversation yesterday, it appears that the first call to the API fails (regardless of the timeout), and the second one succeeds.
(In reply to Gregor Wagner [:gwagner] from comment #2)
> The reference database probably uses an old DB schema and we have to iterate
> over all contacts and modify them when we do a schema upgrade. This might
> take some time. Can you try to increase the timeout to see if it works?

More than 60 seconds for a 200 contacts DB? I think it's more likely that the upgrade code is exploding, leaving things half-broken and causing the error on the first transaction.
(In reply to Reuben Morais [:reuben] from comment #5)
> (In reply to Gregor Wagner [:gwagner] from comment #2)
> > The reference database probably uses an old DB schema and we have to iterate
> > over all contacts and modify them when we do a schema upgrade. This might
> > take some time. Can you try to increase the timeout to see if it works?
> 
> More than 60 seconds for a 200 contacts DB? I think it's more likely that
> the upgrade code is exploding, leaving things half-broken and causing the
> error on the first transaction.

If it's an emulator running a debug build... But yeah something is strange here. Can we get a regular logcat output?
(Reporter)

Comment 7

5 years ago
Created attachment 788535 [details]
logcat
(Reporter)

Comment 8

5 years ago
(In reply to Gregor Wagner [:gwagner] from comment #6)
> If it's an emulator running a debug build... But yeah something is strange
> here. Can we get a regular logcat output?

This is a device running an engineering build.

I've attached a logcat, however there's a difference between my steps to reproduce and the way I ran this. I used b2gpopulate, which is how this issue was initially discovered. Essentially it does exactly the same as the steps to reproduce by pushing the reference database and then attempting to insert additional contacts via the API.
(Reporter)

Comment 9

5 years ago
Is the attached logcat useful? Anything else I can do to assist with this?
Flags: needinfo?(anygregor)
(In reply to Dave Hunt (:davehunt) from comment #9)
> Is the attached logcat useful? Anything else I can do to assist with this?

Nothing obvious in the logcat. Maybe we need a reboot instead of b2g stop.
Jan, Ben do you know if stopping the parent process is enough after replacing a DB?
Flags: needinfo?(anygregor)
Stop/Start should be fine I think.

Updated

5 years ago
Component: DOM: Device Interfaces → DOM: Contacts
You need to log in before you can comment on or make changes to this bug.