vim-gtk/-gnome use of gtk-filechooser causes recently used files list to be constantly written

Bug #251122 reported by Guido Berhoerster
22
This bug affects 1 person
Affects Status Importance Assigned to Milestone
vim
Fix Released
Unknown
vim (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

After the first invocation of the GTK2-filechooser dialog, GTK's list of recently used files (~/.recently-used.xbel) gets written on events such as every single keypress, mouseclick etc. This causes considerable I/O activity and, when .recently-used.xbel is reasonably large, also a considerable slowdown of vim.

This affects the GTK2 flavors of vim as this bug is obviously specific to GTK2. This occurs at least under Ubuntu 7.10 (vim-gnome_7.1-056+2ubuntu2), 8.04 (vim-gnome_7.1-138+1ubuntu3), Debian unstable (see linked Debian Bug), and Fedora 9 (vim-X11-7.1.291-1.fc9.i386), but not under Ubuntu 7.04 (vim-gnome_7.0-164+1ubuntu7.2) and RHEL/CentOS 5.2 (vim-x11-7.0.109-3.el5.3.i386).

Further testing revealed that the bug seems to occur with GTK > 2.10, this is supported by the fact that vim does not use GTK's recently used files list directly and that the recently used files functionality was added to the GtkFileChooser in GTK 2.11.

Steps to reproduce:
strace -erename,open vim -g -f -i NONE -n -u NONE -U NONE
then use the Open/Save file dialog in vim
after that every keypress, mouseclick, mouse entering the vim window should result in ~/.recently-used.xbel getting rewritten

Revision history for this message
Guido Berhoerster (gber) wrote :

I have forwarded this to <email address hidden>.

description: updated
Changed in vim:
status: Unknown → New
Guido Berhoerster (gber)
description: updated
Revision history for this message
Guido Berhoerster (gber) wrote :

After some further digging into into the issue and with helpful hints from some friendly GTK developers I figured out the problem. It's basically that various GTK event handlers of the vim GTK2 GUI quit the gtk main loop (see the event handlers in src/gui_gtk_x11.c) which implicitly causes GTK to save the recently used files list.
I have notified the author of vim.

Changed in vim:
status: New → Fix Committed
Revision history for this message
Guido Berhoerster (gber) wrote :

As I already mentioned above the recently used files list is rewritten when quitting the last level of the GTK main loop, that is gtk_main_loop_level reaches 0. However the write happens only if the recent manager singleton exists which appears to be created lazily on the first invocation of GtkFileChooser. This allows for a simple but ugly workaround, namely using the depreceated GtkFileSelection instead. The code is still in vim, it is activated by commenting out the USE_FILE_CHOOSER define in src/gui_gtk.c. I have tested this with vim 7.1-056 in Ubuntu and this has gone into vim 7.2 upstream, see patch 7.2b.026.

Changed in vim:
status: Fix Committed → Fix Released
Revision history for this message
Colin Watson (cjwatson) wrote :

In that case, this is fixed in Jaunty's vim package. Thanks for chasing this down!

Changed in vim:
status: New → Fix Released
Revision history for this message
Gediminas Paulauskas (menesis) wrote :

This is clearly not a proper fix, introduces a regression, but is not even mentioned in the changelog.

These file selection dialogs are unusable... But of course there are other ways to open a file.

Revision history for this message
Sean Cazzell (seancazzell) wrote :

This seems to be fixed in vim 7.2 - packages for Intrepid are available in Matthew Smith's PPA: https://launchpad.net/~indigojo/+archive/ppa

Revision history for this message
Marius Gedminas (mgedmin) wrote :

I'm also very unhappy that the "fix" is switching to the old-style ugly and inconvenient gtk file selection dialog.

Revision history for this message
Guido Berhoerster (gber) wrote : Re: [Bug 251122] Re: vim-gtk/-gnome use of gtk-filechooser causes recently used files list to be constantly written

This problem cannot be easily fixed in vim, it uses GTK in a "slightly
unusual" way and relied on the documented behavior of gtk_main_quit()
which the GTK devs silently changed in 2.10.0 (by making RecentManager
save the recently used files list). A real fix depends on the GTK devs
reverting this undocumented behavior for which I have filed a RFE at
http://bugzilla.gnome.org/show_bug.cgi?id=546691 . So if you care about
this feel free to bug the GTK folks about it, complaining here will gain
you nothing.

Revision history for this message
Marius Gedminas (mgedmin) wrote :

Guido, thank you for that reference!

Do you have a link to the other side of the discussion (i.e. with Bram and other Vim developers, assuming there are other Vim developers)? From the thread referenced in the bugzilla entry it does seem as if it's Vim that's using a library incorrectly.

Revision history for this message
Guido Berhoerster (gber) wrote :

Marius Gedminas wrote:
> Guido, thank you for that reference!
>
> Do you have a link to the other side of the discussion (i.e. with Bram
> and other Vim developers, assuming there are other Vim developers)?
>>From the thread referenced in the bugzilla entry it does seem as if it's
> Vim that's using a library incorrectly.

Sorry, that was private correspondence with Bram. Basically vim has its
own main loop and enters and leaves the GTK main loop at pretty much any
event. Bram is fine with this but the GTK devs disapprove this usage.
Point is, that GTK changed its behavior in an undocumented way and that
the GTK folks acknowledge this as a problem. So it's either the GTK devs
revert the behavior of RecentManager or somebody makes substantial
changes to vim.
If you want even more details on the vim side you can take a look at the
GTK specific code here:

http://vim.svn.sourceforge.net/viewvc/vim/vim7/src/gui_gtk_x11.c?view=markup
http://vim.svn.sourceforge.net/viewvc/vim/vim7/src/gui_gtk.c?view=markup

If you want to discuss this further I think it would be more appropriate
if you mail me privately or take this to <email address hidden> .

Revision history for this message
Jiahua Huang (huangjiahua) wrote :

I'm unhappy that switching to the ugly and gtk file selection dialog.
I prefer to err on the recently-used func.

This patch overwrited the g_bookmark_file_to_file() func to fixed the considerable I/O problem,
and switching to the new-style gtk_file_chooser_dialog.

It works on my Ubuntu 9.04.

--- vim-7.2.079/src/gui_gtk.c 2009-04-26 13:06:52 +0000
+++ vim-7.2.079/src/gui_gtk.c 2009-04-26 18:57:06 +0000
@@ -1199,8 +1199,17 @@
  * ~/.recently-used.xbel every time the main loop is quit. For Vim that means
  * on just about any event. */
 /* # define USE_FILE_CHOOSER */
+#define USE_FILE_CHOOSER 1
 #endif

+extern gboolean
+g_bookmark_file_to_file (GBookmarkFile *bookmark,
+ const gchar *filename,
+ GError **error)
+{
+ return TRUE;
+}
+
 #ifndef USE_FILE_CHOOSER
 /*ARGSUSED*/
     static void

Revision history for this message
Andrew (andrew-rw-robinson) wrote :

2 years later and still not fixed?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.