Snippet loading freezes the application

Bug #555389 reported by Wolter Hellmund on 2010-04-04
This bug affects 7 people
Affects Status Importance Assigned to Milestone

Bug Description

Acire uses what I believe is called a synchronous function to load the snippet into the text view/source view. Because of this, the whole application freezes while the snippet is being loaded into the window. When it finally loads, then the application becomes usable again.

The solution to this problem would be to implement snippet loading in an asynchronous function, so that the rest of the application will not need to wait for the function to return, thus eliminating the freezing.

Tags: bug Edit Tag help
Vimal Joseph (vimal) wrote :

I also got the same problem. It happens only when the computer is connected to the internet. The problem happens when the Acire tries to get the title of documentation page (the snippet_docs url) from the internet.

Changed in acire:
status: New → Confirmed
Ed S (edgar-b-dsouza) wrote :

Agreed with vimal. The snippet loading itself is from local files, and does not incur significant delay. The retrieval of page titles for documentation URLs in the snippet is what is causing Acire to apparently "freeze" for a significant time while information is retrieved from the Net.

I had made a small correction to my local copy to work around this annoyance, but I have not yet proposed this specific change for merging, since I'm waiting on the project lead for response to a query on a larger feature - adding snippet module dependency detection and resolution (if the snippet imports a module which is not installed on the system).

The project lead, Jono Bacon, being Ubuntu Community Manager, I expect he is busy with the upcoming final release of Lucid, so I am waiting for some sign that he is paying attention to Acire again :) and hope I will get some response about my pending feature addition.

ANYWAY... In the meanwhile, if you wish to work around this until Jono accepts a fix... check
OR, you can create a local Acire branch, if you have bazaar installed:
bzr branch lp:~edgar-b-dsouza/acire/delay_web_doc_title_fetch

(Patched against rev 56, may be "outdated" by LP automatic translation service updates pretty soon)

Basically, the idea is to just split off the documentation box updation (which uses the webbrowser module) to about 800 milliseconds after the other code in the snippet_selected() function - by then, (on my laptop at least) GTKSourceView has been updated.

Here is the logic:
1. import the gobject library
2. Split out inline code (to update the docs box) in the snippet_selected() function, into a separate function, update_docs_box()
3. Replace the earlier inline code to update the docs box with:
    gobject.timeout_add(800, self.update_docs_box)

The 800 millisecond timeout is pretty arbitrary, yes - it may cause problems with slower processors, I don't know... (I'm running a C2D T9400 with max step 2.53 GHz). Probably the optimal solution is to somewhere do a CPU calibration to determine a sensible interval for which to delay the callback. I didn't go to that level (I'm a newbie at FOSS collaborative dev too :) ) but in the short term, this fix should probably hold off the irritation till project lead accepts a proper fix from whoever offers one.


Vimal Joseph (vimal) wrote :

I tried ed's fix but for me it is not working. I think the proper solution is to run the fetch title from url feature in a separate thread so that fetching the url will not freezes the GUI.

Wolter Hellmund (wolterh) wrote :

Thats correct, I think Glib can help with that

Ed S (edgar-b-dsouza) wrote :

@vimal - just out of curiosity: did you try adjusting the timeout? Did it have no effect at all?

Yes, probably the update_docs_box function should be run in a separate thread... I'll try to do that when I get free from work I'm currently handling.

Vimal Joseph (vimal) wrote :

@Ed the effect of time out was

Case 1 : Not connected to the internet
In this case, the snippets loads without any delay, and the documentation button shows none if the snippets contain a doc url and it displayed the message "click here to add the documentation" after the delay we set in the program.

Case 2 : Connected to internet
The snippet will load when i click on the first snippet. Then I click on the next snippet after waiting some time (ie after loading the doc url title) and click on another snippet, it works. But if i immediately browse through the list without waiting to load the doc title, it freezes the GUI.

Again the problem lies in the time delay to load a page from the Internet and get its title. (my internet connection is slow :(.

Timo Vanwynsberghe (timovwb) wrote :

Maybe putting it in a glib.idle_add() callback would help. But I think fast browsing through the list will still freeze the UI.

Threads don't seem such a good idea to me, because it can still fetch titles even when the snippet isn't selected anymore.

mcNisse (johan-erlands) wrote :

I have a modified version with a offline mode. In offline I've renamed links as Doc 1, Doc 2 instead of fetching the title from internet, but I don't know how to push my bazaar branch back to launchpad.

tags: added: bug
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers