Firefox moz-icon://.ext not working

Bug #466567 reported by Tadej Novak on 2009-10-31
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Mozilla Firefox
Fix Released
Medium
firefox (Ubuntu)
Medium
Unassigned
firefox-3.5 (Ubuntu)
Medium
Unassigned
humanity-icon-theme (Ubuntu)
Undecided
Unassigned

Bug Description

In Kubuntu 9.10 using Firefox the command moz-icon://.ext, where .ext represents file extension does not work. This command should return an icon representing this file type.
In Kubuntu 9.04 this feature works.
After some investigation I found mimetype icons in /usr/share/icons/hicolor/16x16/ on my jaunty installation that are missing in same directory in karmic. I think Firefox loads icons from that location.
This bug is present in Firefox provided by Ubuntu and in Firefox downloaded from mozilla.com, so I think it's not Firefox specific bug.

Tadej Novak (ntadej) wrote :

In Kubuntu 9.10 using Firefox the command moz-icon://.ext, where .ext represents file extension does not work. This command should return an icon representing this file type.
In Kubuntu 9.04 this feature works.
After some investigation I found mimetype icons in /usr/share/icons/hicolor/16x16/ on my jaunty installation that are missing in same directory in karmic. I think Firefox loads icons from that location.
This bug is present in Firefox provided by Ubuntu and in Firefox downloaded from mozilla.com, so I think it's not Firefox specific bug.

my python-script is ready. i reimplemented some moz-icon-parsing and i think that detecting the desktop-enviroment is also already implemented.

just port it, someone, and you are done (oh, and fix one minor TODO)

#! /usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function
import sys, os
from subprocess import Popen, PIPE

def detectDE():
 if os.environ.get("KDE_FULL_SESSION") == "true":
  return "kde"
 elif os.environ.get("GNOME_DESKTOP_SESSION_ID"):
  return "gnome"
 elif os.environ.get("DISPLAY"):
  return "x"
 return None

url = sys.argv[1] + "?" #the "?" is a bugfix, since string.find() gives back a "-1" when nothing is found.

ext = url[url.find(".") : url.find("?")]

sizeindex = url.find("size=")
if sizeindex == -1: #"size=" not found => no size specified
 size = 16
else:
 sizeend = url.find("?",sizeindex)
 size = int(url[sizeindex+5 : sizeend])

for s in [256,128,64,48,32,22,16]:
 if size <= s:
  sizestr = str(s) + "x" + str(s)

if detectDE() == "kde":
 mime = Popen(["kmimetypefinder", "-f", ext], stdout=PIPE).communicate()[0] #finds mimetype for the extension on kde
 if "\n" in mime: #a two-line-string is only the output if the mimetype is found
  mime = mime[:mime.find("\n")] #remove the accuracy-line
  mime = mime.replace("/","-") # using "-"-mimetypes is more bug-proof
  iconpath = Popen(["kiconfinder", mime], stdout=PIPE).communicate()[0] #finds icon for mimetype
  iconpath = iconpath.replace("\n","") #the line-end is removed
  iconpath = iconpath.replace("48x48", sizestr) #replaces icon size 48×48 with the size specified
 else:
  iconpath = "generic icon path" #to be replaced
 print(iconpath) #the output: you will want to change this to "return iconpath" after making all of this a c++-method ;)

#TODO: Check if requested image size exists and if not, try other sizes

i see this too. Confirming

Ilja Sekler (ilja-sekler-) wrote :

This issue is specific to Humanity* icon sets (package humanity-icon-theme), possibly due to limitations of the moz-icon:// protocol in Firefox and in Thunderbird 3.

flying sheep (flying-sheep) wrote :

Why should it be specific to a special iconset?

If anything, it is specific to a special feature the oxygen and humanity (and probably loads of other) themes either have or lack.

With which icon theme does this work for you? Note that this is a Karmic Bug, everything worked for me up to Jaunty!

@Everyone:
Please note that this Bug only covers moz-icon://.ext uris.
moz-icon://stock/* works still fine!

Changed in ubuntu:
status: New → Confirmed
Ilja Sekler (ilja-sekler-) wrote :

> With which icon theme does this work for you?

Works at least with gnome and Human icon themes. The most visible difference is that gnome and Human themes contain icons in PNG format in the relevant /usr/share/$ICON_THEME/16x16/mimetypes/ subdirectory, but Humanity has only SVG.

flying sheep (flying-sheep) wrote :

that is either not the cause, or on kde there is another one.
for example
/usr/share/icons/oxygen/16x16/mimetypes/image-x-generic.png
exists (and all other mimetype-.pngs) on my pc.

Ilja Sekler (ilja-sekler-) wrote :

WFM with oxygen icons on GNOME and current trunk builds of Firefox as well with Thunderbird 3.0.1pre.

Ilja Sekler (ilja-sekler-) wrote :

Saving the required icons from the Humanity icon theme as PNG files definitely works around the issue. With the default "Human" theme an Karmic (which includes the Humanity icons), I can see the right icon for application/pdf in the large attachment view in Thunderbird 3 if I save /usr/share/icons/Humanity/mimes/32/x-office-document.svg as ~/.icons/Humanity/mimes/32/x-office-document.png and make a symlink ~/.icons/Humanity/mimes/32/application-pdf.png to this file.

As far as it is unlikely that moz-icon:// would accept SVG soon enough, it could be preferable to be nice to Firefox and Thunderbird and give them what they want. Setting "package" to "humanity-icon-theme".

affects: ubuntu → humanity-icon-theme (Ubuntu)
Vish (vish) wrote :

We are not going to convert all our MIME icons to png , just because a single app is not able to handle the svg.

It is a problem in the app and not the icon theme.

Changed in humanity-icon-theme (Ubuntu):
status: Confirmed → Invalid
Vish (vish) wrote :

Firefox is able to use the svg icons in the toolbars and other locations.
So, it needs to be fixed in firefox and not workaround the problem by asking the icon theme to change its icon formats.

Tadej Novak (ntadej) wrote :

What about using other icon themes. Firefox successfully uses Oxygen icons as back/forward/refresh if this theme is selected. And Oxygen already has .png mime icons.

*** Bug 528382 has been marked as a duplicate of this bug. ***

Comment #0 is very hard to follow. Check the launchpad bug or my bug 528382.

If this only happens after an upgrade to Ubuntu 9.10, I guess it's not really a regression on Firefox's end.

The initial Firefox 3.0 release behaves exactly the same, so likely the default SVG-only icon theme on Ubuntu 9.10 just exposed for the first time some issues or of moz-icon:// protocol.

Actually, it is enough to change the filename extension of SVG icons from .svg to .png (e.g. put symlinks into ~/.icons/Humanity/mimes/$ICON_SIZE/ with .png as extension) to make them "work".

remember: this is not only about svg.
i have a kde desktop and use the oxygen icons. every mime icon is a png-picture and the mime icons do not work in firefox.

furthermore i did not uprade, my kubuntu 9.10 is freshly installed!

tu sum it up: the last two comments are misleading, since they only refer to gnome desktops, not kde.

So this is or isn't a Firefox regression?

re comment 8; flying sheep, I think what Reed is saying is that something in Ubuntu 9.10 may have caused this.

Micah Gersten (micahg) wrote :

Thank you for reporting this. I'm marking this triaged as we have an upstream bug. Please report any other bugs you may find.

affects: firefox (Ubuntu) → firefox-3.5 (Ubuntu)
Changed in firefox-3.5 (Ubuntu):
importance: Undecided → Medium
status: New → Triaged

(In reply to comment #9)
> So this is or isn't a Firefox regression?

No. But the problem on GNOME seems to live on the Firefox end, so this should be fixed in Firefox. Unsure about the problem on KDE, it is IMHO different and probably a KDE (or even KDE and Ubuntu-specific) bug.

So said, I apologize for the mess I caused asking Reed to dupe his bug 528382 to this one. Don't know whether it would be better to undupe bug 528382 and to give this one a better summary and description or to continue in this bug despite the original intention of the reporter.

flying sheep (flying-sheep) wrote :

i use a kde desktop, the oxygen icon theme (png!) and the mime icons don’t work for me.

so this bug happens in two cases: using .svg-icon themes on gnome or using anything on kde!

Ilja Sekler (ilja-sekler-) wrote :

> so this bug happens in two cases: using .svg-icon themes on gnome
> or using anything on kde!

I apologize for the mess. The issues on GNOME and on KDE are unrelated IMHO.

To finish with the issue on GNOME in this bug, I suggest the following per-user
workaround for the Humanity icon theme:

#!/bin/bash

ISOURCE=/usr/share/icons/
ITHEME=Humanity

for size in 16 22 24 32 48;
do
  mkdir -p $HOME/.icons/$ITHEME/mimes/$size;
  for file in $ISOURCE/$ITHEME/mimes/$size/*.svg;
    do ln -s $file $HOME/.icons/$ITHEME/mimes/$size/`basename $file`.png;
  done;
done;

It turns out to be, that it is not required to convert SVG icons to PNG format:
changing the filename extension to .png is sufficient.

Ilja Sekler (ilja-sekler-) wrote :

Oops... This:

ln -s $file $HOME/.icons/$ITHEME/mimes/$size/`basename $file`.png;

must be on a single line or the line break must be escaped.

Ilja Sekler (ilja-sekler-) wrote :

> ln -s $file $HOME/.icons/$ITHEME/mimes/$size/`basename $file`.png;

*Arrgghh* once again the fixed script:

#!/bin/bash

ISOURCE=/usr/share/icons/
ITHEME=Humanity

for size in 16 22 24 32 48;
do
  mkdir -p $HOME/.icons/$ITHEME/mimes/$size;
  for file in $ISOURCE/$ITHEME/mimes/$size/*.svg;
  do
    ln -s $file $HOME/.icons/$ITHEME/mimes/$size/`basename \
    $file .svg`.png;
  done;
done;

of course... My deepest apologies for the bugspam!

Changed in firefox:
status: Unknown → Confirmed

Don't see how minor UI polish can possibly be a blocker for security updates.

OK, let's call this a bug with SVG icons. flying sheep: could you please file a separate bug for your issue, and we will track it down there?

There is absolutely no way this should block.

Joe, this is my bug. The Gnome Users just found out that they have a similar issue, too and discussed it here.

I made a new Bug report. Could somebody with kde please confirm Bug 532362, since for me, this discussion was a waste of time.

don’t get me wrong, i’m glad you tracked down your .svg-bug here, but initially i reported this and wanted my problem tracked down ;)

*** Bug 535549 has been marked as a duplicate of this bug. ***

Created an attachment (id=418531)
v1 central, Fix moz-icon under gnome by using gtk functions

Current patch uses gtk_icon_theme_* which replaces the libgnomeui stuff since some time.
See: http://live.gnome.org/LibgnomeMustDie

A lot of stuff already depends on gtk 2.4+, so depending on it shouldn't be a problem here.

Tested to work under Ubuntu karmic 9.10 x86.

(From update of attachment 418531)
Is it possible to add a test on this? Are there any icons that ship with most default gtk themes in SVG format?

Created an attachment (id=422104)
v0, xpshell-tests

Some xpcshell tests.

The test will try to open channels for various pre-defined file icons at different sizes.
All tests are expected to succeed.

Some troubles, however:
* On *nix (at least on Ubuntu karmic x86) xpcshell seg faults in exit_handlers after running these tests, no matter if my icon channel patch was applied before or not.
Stack is like this:
#0 0x432dfa40 in ?? ()
#1 0x41758afc in IA__g_hash_table_foreach (hash_table=0x920d720, func=0x42e13460, user_data=0xbfe22984) at /build/buildd/glib2.0-2.22.3/glib/ghash.c:1211
#2 0x42e17333 in ORBit_POA_deactivate () from /usr/lib/libORBit-2.so.0
#3 0x42e17594 in ?? () from /usr/lib/libORBit-2.so.0
#4 0x42e1782d in PortableServer_POA_destroy () from /usr/lib/libORBit-2.so.0
#5 0x42e01c06 in CORBA_ORB_shutdown () from /usr/lib/libORBit-2.so.0
#6 0x42e01d7f in CORBA_ORB_destroy () from /usr/lib/libORBit-2.so.0
#7 0x42e0355f in ?? () from /usr/lib/libORBit-2.so.0
#8 0x4124c05f in __run_exit_handlers (status=153158016, listp=0x4135e304, run_list_atexit=true) at exit.c:78
#9 0x4124c0cf in *__GI_exit (status=0) at exit.c:100
#10 0x41233b5e in __libc_start_main (main=0x804baf6 <main>, argc=18, ubp_av=0xbfe22bc4, init=0x8051c10 <__libc_csu_init>, fini=0x8051c00 <__libc_csu_fini>, rtld_fini=0x4000dd20 <_dl_fini>,
    stack_end=0xbfe22bbc) at libc-start.c:252
#11 0x0804a541 in _start () at ../sysdeps/i386/elf/start.S:119

Any ideas about that?

* Cannot test on Mac, as I do not own a Mac.

Test work fine under Win32. Win32 already returns an icon, always.

(In reply to comment #17)
> (From update of attachment 418531 [details])
> Is it possible to add a test on this? Are there any icons that ship with most
> default gtk themes in SVG format?

I don't think you can really make any assumptions about the system/distro in place.
Hence the more general tests.

(From update of attachment 418531)
>+#if GTK_CHECK_VERSION(2,4,0)

Why do we need such a check here at all? configure.in has GTK2_VERSION=2.10.0 as the minimum version.

(In reply to comment #19)
> (From update of attachment 418531 [details])
> >+#if GTK_CHECK_VERSION(2,4,0)
>
> Why do we need such a check here at all? configure.in has GTK2_VERSION=2.10.0
> as the minimum version.

There are a couple of such checks in already. I didn't know if the configure check is considered enough, so I did stick with the code style already there and added one such check myself.

If these checks are considered "obsolete" I can easily remove the one I added and the others as well.

(In reply to comment #20)
> (In reply to comment #19)
> > (From update of attachment 418531 [details] [details])
> > >+#if GTK_CHECK_VERSION(2,4,0)
> >
> > Why do we need such a check here at all? configure.in has GTK2_VERSION=2.10.0
> > as the minimum version.
>
> There are a couple of such checks in already. I didn't know if the configure
> check is considered enough, so I did stick with the code style already there
> and added one such check myself.

IMO the check could make sense still. The reasons for requiring 2.10 are for example the new print dialog. In case someone wants to ship anything based on mozilla and don't need that it's still better to have checks for the other (older) stuff. But that's only my opinion.

Any idea about the crashing test exit (comment #18)?
If not, maybe implement this as mochitests instead of xpcshell ones? Or what else?

Does this require super-review, and if yes could you point me at the best sreviewer for this type of bug?

Changed in firefox:
status: Confirmed → Fix Released
Micah Gersten (micahg) wrote :

Adding unversioned firefox package to track the fix in Lucid+

Changed in firefox:
milestone: none → 4.0
Changed in firefox (Ubuntu):
importance: Undecided → Medium
status: New → Triaged
Changed in firefox:
importance: Unknown → Medium
In , Kim (kim-h) wrote :

With this fixed, is the "height < 256 && width < 256" checks still really necessary in?:
http://hg.mozilla.org/mozilla-central/file/d0d3ac2ce08c/modules/libpr0n/decoders/icon/gtk/nsIconChannel.cpp#l102

I think the comparator might be wrong too, should I file a new bug for that if the checks should stay in?

Micah Gersten (micahg) wrote :

This is fixed in Natty now with Firefox 4.0b7. Please report any other issues you may find.

Changed in firefox (Ubuntu):
status: Triaged → Fix Released
Ilja Sekler (ilja-sekler-) wrote :

> This is fixed in Natty now with Firefox 4.0b7. Please report any
> other issues you may find.

While true for Firefox 4 on top of Gecko 2.0, this bug is still valid for Thunderbird 3.1 on top of Gecko 1.9.2. It is even much more prominent there as there are no attachment icons in Thunderbird with the default Ubuntu icon theme.

How would you like to proceed for Natty? Do nothing and hope that Thunderbird releases a next major version based on Gecko 2.0 till then? Apply the patch <https://bugzilla.mozilla.org/attachment.cgi?id=418531> (this is what I do locally for my private Thunderbird builds)?

Do you wish to track the issue for the thunderbird (Ubuntu) in a separate bug?

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

Other bug subscribers

Remote bug watches

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