After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 155420 - file chooser dialogs can block mainloop in the non-local_only case
file chooser dialogs can block mainloop in the non-local_only case
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkFileChooser
unspecified
Other Linux
: High normal
: Medium fix
Assigned To: Federico Mena Quintero
Federico Mena Quintero
: 168574 319847 328217 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2004-10-14 20:00 UTC by Matthias Clasen
Modified: 2007-01-25 22:10 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Matthias Clasen 2004-10-14 20:00:00 UTC
this happens if the .gtk-bookmarks file contains a uri whose server is doesn't
respond.
Comment 1 Matthias Clasen 2005-02-26 15:21:06 UTC
*** Bug 168574 has been marked as a duplicate of this bug. ***
Comment 2 Federico Mena Quintero 2005-06-10 16:56:51 UTC
This also happens if you have a bookmark for a stale NFS mount.  I think we
should not check the validity/presence of the bookmarks until you actually try
to activate one.
Comment 3 Michael Meeks 2005-06-10 17:40:18 UTC
or - check it asynchronously; clearly it'd be pretty sucky to delay the check
until someone presses the combo box / expands the 'browse to' thing & then still
do it synchronously :-)
Comment 4 Tuomas Kuosmanen 2005-08-19 18:23:54 UTC
Well. It has nothing to do about whether the server responds or not - when you
have enough of bookmarks, it'll be slow no matter how fast your net is, to poke
at each of them.

http://gallery.tigert.com/scratch/bmarks.png 

Most of those are sftp mounts.

All it takes for someone to start _using_ the bookmarks. You will love them, and
you'll add several because they rock. And that is enough to make it too slow to
be useful. Great feature crippled by bad implementation.

Like Michael said, it's silly to poke each mount before showing the dialog.

Comment 5 Mikael Hallendal 2005-08-20 14:07:11 UTC
This is not a problem with only bookmarks, it's in the very design of the
GtkFileChooser/GtkFileSystem. I spent some time looking at this and I seriously
can't see how this can be solved without a serious overhaul of the design.

The problem is that the GtkFileSystem APIs are synchronous by nature, even more
the file chooser uses it in a way that makes it even more synchronous than it
would have to be (by using get_folder to check if a certain URI is a folder).

Fixing this would require new API to the GtkFileSystem interface and a redesign
of how GtkFileChooser uses this API. 

What is surprising me is that no one has thought about this since it's quite
obvious that a synchronous API for remote file systems (existing or not
existing) will never work.
Comment 6 Mikael Hallendal 2005-08-20 14:09:02 UTC
By the way, for reference. The mainloop will also block as soon as you browse a
slow remote file system or try to create a directory on it.

If it's non-existing, the time it will take is left to the GnomeVFS module to
decide when it figures the remote system doesn't exist and gives control back to
the GTK GnomeVFS FileSystem backend that can report the error back to the UI.
Comment 7 Tuomas Kuosmanen 2005-08-22 11:49:12 UTC
Suck. DND from nautilus works on many cases, but it's the saving that sucks
BADLY in this one.

Would it be possible to only check a bookmark when the user tries to open one?
So one would just show the bookmarks in the list, but the fileselector wouldnt
check if they are valid until the user clicked them?

This clearly shows that more developer people should actually start using the
vfs stuff.. Unfortunately many of those mostly use Gnome for the terminal...
Comment 8 Michael Meeks 2005-08-22 14:21:49 UTC
This should all be fixable though - right ?

/* This is a "semi-private" header; it is meant only for
 * alternate GtkFileChooser backend modules; no stability guarantees 
 * are made at this point
 */
#ifndef GTK_FILE_SYSTEM_ENABLE_UNSUPPORTED
#error "GtkFileSystem is not supported API for general use"
#endif
Comment 9 Mikael Hallendal 2005-08-22 19:05:51 UTC
Yes, I think it shouldn't be a huge problem getting the needed changes in but
it's a pretty large task to do since you have to fix all the backends and the
filechooser code.
Comment 10 Fernando Herrera 2005-09-08 19:02:42 UTC
Well, I think we can accept having some kind of blocking on remote dirs coming
from gnomevfs backend.
But the big problem I think is when an user has a remote bookmark. Every
filechooser dialog he get would query the remote host just for adding the
bookmark. Opening a filechooser for reading o saving a local file with a remote
bookmar can be the 90% cases of a 50% scenario of GNOME users, and we should try
to avoid this pain.

Looking at the code in gtkfilechooserdefault, the remote query for a bookmark is
done three times:
1) Check if it is a folder
2) Get the label
3) Get the proper icon

I think we can just skip 1), because only folders can be bookmarked right now,
and the checking then should be done only at creation time
For 2), the code is now using a gtk_file_info_get_display_name over a
GtkFileInfo (that does a remote query). We can try first to do a
gtk_file_system_get_bookmark_label, that in the gnomevfs backend doesn't do a
remote query.
The problem is for 3, that uses gtk_file_system_render_icon, and every
implementation of this uses a fileInfo to get the mime type (with remote query).
Maybe we should add a gtk_file_system_render_bookmark_icon funtion to the
interface, and allow backends to get the icon based only on the path and without
remote query (as gtk_file_system_get_bookmark_label does).

So with this addition I think we will speed up 90% of 50% of normal scenarios :)
 
Comment 11 Mikael Hallendal 2005-09-23 09:17:18 UTC
Fernando, how can blocking the UI be acceptable, no matter if it's a remote
filesystem or not. This problem isn't about bookmarks, it's just happen to
trigger it often.

The biggest issue here is not performance but the fact that if you try to access
a slow or offline remote filesystem it's going to take ages before the UI redraws.
Comment 12 Sebastien Bacher 2005-09-26 17:06:50 UTC
Ubuntu has a similar bug: https://bugzilla.ubuntu.com/show_bug.cgi?id=16286

"if I press "sysrq" to take a screenshot, or if I run "gnome-screenshot" from a
command line, I don't see anything for 30 or 35 seconds.  then the screenshot
window appears.
...
I just "fixed" the problem by going into nautilus and deleting my 2 bookmarks. 
They were both bookmarks to SMB mountpoints within my home directory which
aren't currently mounted.

I have had those bookmarks for a long time now, and they've never caused this
slowdown before, even when the shared drives haven't been mounted.
...
I found a way to reproduce this delay:

In nautilus, make a new bookmark to:

  smb://abc123/abc123/abc123

(where host abc123 doesn't exist).

Then there's a 15 second delay when trying to start gnome-screenshot.

When I first noticed this delay, I had 2 nautilus bookmarks to un-mounted smb
shares, and had a firewall up which prevented them being mounted.  Removing just
one of them halved the delay to 15 seconds.  Taking the firewall down removed
the delay.  But replacing the hostname with a host which doesn't exist brings
the delay back.  If the bookmark is to "smb://abc123/abc123" I see no delay - it
seems I need to add an extra "/abc123" for it to happen."
Comment 13 Fernando Herrera 2005-09-26 18:43:23 UTC
Mikael, I'm not saying that blocking the UI is acceptable. Only that this
blocking is happening most of time for most of the users under the bookmarks
scenario, and then I should priorize a
"fix/workaround/horrible-hack/not-the-real-fix" for this pain for tons of users
targeted for a 2.12.x release or whatever. Of course we need a full and real fix
for the sync-remote-ops-blocking-the-ui-problem :)
 
Comment 14 Matthias Clasen 2005-10-27 03:23:44 UTC
*** Bug 319847 has been marked as a duplicate of this bug. ***
Comment 15 Luke Hutchison 2005-10-27 12:01:39 UTC
In the dup in Comment 14, note that also if the URI requires authentication and
your password is not saved in the keyring, you will be asked to authenticate
every time the save dialog is brought up, even if you're not saving to the URI
that requires authentication.  This is just strange, it took me a while to
figure out what was going on, because I forgot I had created a bookmark that
required authentication.  Sometimes you are asked for the password 2-4 times
before it brings up the dialog, if you just hit Cancel (which is strange in
itself, perhaps the file chooser is actually trying more than once to hit the URI).

Also note that some URIs are sometimes available and sometimes unavailable, e.g.
only when a VPN is up.
Comment 16 Federico Mena Quintero 2006-01-23 18:02:33 UTC
*** Bug 328217 has been marked as a duplicate of this bug. ***
Comment 17 Luke Hutchison 2006-01-23 21:05:31 UTC
I noticed that the async logic was added to the file chooser recently... but is the file chooser still checking locations before they are accessed?  It used to try connecting to all locations in the shortcuts pane, whether or not they were used in a given save/open operation.
Comment 18 Matthias Clasen 2006-09-20 16:59:57 UTC
There is a patch in bug 354887 which gets rid of some more touching of remote
filesystems for bookmarks. We still call is_local() for them, though, which
is problematic as well.
Comment 19 Federico Mena Quintero 2007-01-24 19:11:17 UTC
Does this still happen in 2.10 with the async code?
Comment 20 Bastien Nocera 2007-01-25 11:23:32 UTC
(In reply to comment #19)
> Does this still happen in 2.10 with the async code?

I can't reproduce it with GTK+ 2.10.4. I discovered that it would list an empty directory pane, instead of an error (filed as bug 400558).

This was my test case:
1. Setup /etc/exports:
$ cat /etc/exports 
/tmp/   (ro,all_squash,insecure)
2. Start the server:
# service nfs start
3. Mount the share:
# mount localhost:/tmp /mnt/iso/
4. Add the directory to the ~/.gtk-bookmarks
$ echo file:///mnt/iso/ >> ~/.gtk-bookmarks
5. Stop the server to get a stale mount:
# service nfs stop
6. Launch an application and its "Open" dialogue

Works fine. With older versions of GTK+, you'd get a hang by that time...
Comment 21 Federico Mena Quintero 2007-01-25 22:10:49 UTC
Thanks for the confirmation :)  Marking as fixed.