GNOME Bugzilla – Bug 786532
gdata_contacts_service_query_contacts_async: callback never called
Last modified: 2017-11-03 23:19:30 UTC
Note, this may be a bug in GJS, but I don't have an easy way to tell. I can confirm GDataContactsService.query_contacts() (synchronous) works, but when calling query_contacts_async(), either the *callback* function isn't called or the query never completes. The *progress_callback* doesn't seem to be called either. I've run query_contacts() and query_contacts_async() back to back with fairly standard args, but let me know if you'd like my full usage example.
If you could provide a minimal reproduction example in JS, that would be very helpful. Some other questions: • What version of libgdata is this with? • Do other *_query_async() methods misbehave similarly? gdata_contacts_service_query_contacts_async() is implemented the same way as almost all the other *_query_async() methods. So I would expect them to be broken too. • If you run your test with LIBGDATA_DEBUG=3 G_MESSAGES_DEBUG=all set in the environment, does the log output indicate anything unusual happening with the contacts query? Thanks.
This is Ubuntu Gnome 17.04 packages: libgdata22, gir1.2-gdata-0.0 version (both): 0.17.7-0ubuntu1 I believe this may be my mistake after all. This is one lib not covered by the current GJS docs[1] and after running with the debug vars set I'm getting: > libgdata-CRITICAL **: gdata_contacts_service_query_contacts_async: assertion 'callback != NULL' failed I've gathered that my translation of C=>GJS parameters for this function are at fault. You can safely close this and I'll comment again if I find any *real* errors. Thanks for your help as always. [1]:http://devdocs.baznga.org/)
(In reply to andrew.g.r.holmes from comment #2) > I believe this may be my mistake after all. This is one lib not covered by > the current GJS docs[1] and after running with the debug vars set I'm > getting: > > > libgdata-CRITICAL **: gdata_contacts_service_query_contacts_async: assertion 'callback != NULL' failed Interesting. It certainly looks like your code (or the GJS bindings for libgdata) is at fault. You should have received that critical regardless of whether you were running with the debug variables set. If not, you should check what’s causing it to be suppressed, because criticals being suppressed is really unhelpful for development. (Could be a bug in GJS?) > I've gathered that my translation of C=>GJS parameters for this function are > at fault. You can safely close this and I'll comment again if I find any > *real* errors. OK, thanks for looking into it. Let me know if you have any more problems! (Although I’m away for a couple of weeks; I’ll catch up with any bug reports when I get back.)
Okay, I've taken another crack at this and I am encountering some problems (although I haven't tried any other async functions). I've built the docs for GData using g-ir-doc-tool so I'm fairly confident I'm calling the functions with the correct args. Here's my GJS snippet: function get_google_contacts_async(account, query) { if (!query) { query = new GData.ContactsQuery({ q: "" }); } account.query_contacts_async( query, null, // cancellable (contact) => { log(contact.title); }, // progress_callback (account, res) => { let feed = account.query_finish(res); let count = feed.start_index * feed.items_per_page; //if (count < feed.total_results) { if (feed !== null) { //query.start_index = count; query.next_page(); get_google_contacts_async(account, query); } return; } ); } You can see there are two lines commented out. If I run the code as-is above only one page of contacts prints repeatedly until I get this error: (gjs:25988): libgdata-CRITICAL **: _gdata_query_set_next_uri: assertion 'self->priv->pagination_type == GDATA_QUERY_PAGINATION_URIS' failed Segmentation fault (core dumped) If I switch to manual pagination (which I know the docs say don't do), I get a correct list of all my contacts then this error: (gjs:25962): libgdata-CRITICAL **: _gdata_query_set_next_uri: assertion 'self->priv->pagination_type == GDATA_QUERY_PAGINATION_URIS' failed (gjs:25962): libgdata-CRITICAL **: _gdata_query_set_previous_uri: assertion 'self->priv->pagination_type == GDATA_QUERY_PAGINATION_URIS' failed Segmentation fault (core dumped) Let me know if there's anything I'm misunderstanding or more information I can provide.
This looks like a separate bug (but let’s track it in this bug report because we’re here already). Can you change GDATA_QUERY_PAGINATION_INDEXED to GDATA_QUERY_PAGINATION_URIS in gdata_contacts_query_init() in gdata-contacts-query.c and recompile libgdata? I think that should fix it. It doesn’t look like there are any problems in your code, as far as I can tell from that snippet.
That does seem to fix paging, is this something that should be changed upstream? On the other hand query_finish() never seems to return NULL, so the process stops printing at the end of the contact list, but keeps calling the query forever.
(In reply to andrew.g.r.holmes from comment #6) > That does seem to fix paging, is this something that should be changed > upstream? Yes, I’ll change it shortly. > On the other hand query_finish() never seems to return NULL, so the process > stops printing at the end of the contact list, but keeps calling the query > forever. You should never expect query_finish() to return NULL. At the end of the results, it should return a GDataFeed which is empty (i.e. get_entries() returns an empty list). That signifies the end of the results. The API’s a little clunky — it’s dated, sorry!
Thanks for testing the fix! The following fix has been pushed: 0309bb0 contacts: Fix pagination for contact queries
Created attachment 362926 [details] [review] contacts: Fix pagination for contact queries Use the right pagination type to avoid an assertion failure. Signed-off-by: Philip Withnall <withnall@endlessm.com>
Review of attachment 362926 [details] [review]: Hello, it's seems that there is a typo in the patch, should be: GDATA_QUERY_PAGINATION_URIS with an 'S' at the end. Best regards
(In reply to gschwind from comment #10) > Review of attachment 362926 [details] [review] [review]: > > Hello, it's seems that there is a typo in the patch, should be: > > GDATA_QUERY_PAGINATION_URIS > > with an 'S' at the end. > > Best regards Uff, fixed. Thanks for pointing it out.