Sometimes Icons don't render on firefox on ubuntu

On which Firefox version do tested?
Tested on a firefox 54.0 (64-bit) (firefox for ubuntu canonical - 1.0) on a ubuntu 16.04 LTS Edit: on version 55.0.3 (64-bit) it works fine, the problem seems to be with the one that comes pre installed with ubuntu
Having this issue on firefox 55, nixos and archlinux. Works fine on firefox 57.
@RocketChat/core Guys I see same issue on Firefox 55. Why new UI design have many issue on Firefox? :thinking:
We have this issue with Firefox 54... Is there an option to use the old design?
I don't think the new design is released in a stable version yet - just revert back to a stable version?
@karlprieb It's still happens sometimes. :cry:
Part of #8494
Face this issue using Firefox 52 esr on Windows. Rocket 0.59 release.
Rocket.Chat version 0.52.9 Firefox 52.3
Pretty anoying bug as Firefox 52 is an ESR. Any lead on how to help on this ?
Cheers
No luck here...
I tried something simple with svg to be sure (based on RocketChat 0.59.3 simplified sources, see below). It works like a charm with FF 52 et Chrome. I also tried the full code of RocketChat 0.59.3 but without css and I still don't see icons.
Ideas ?
<!DOCTYPE html>
<html>
<head/>
<body>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="display: none">
<symbol id="icon-pin" viewBox="0 0 20 20">
<g stroke="currentColor" stroke-width="1.5" fill="none" fill-rule="evenodd"><path d="M13.497 14.719l3.119 3.12" stroke-linecap="square"></path><path d="M2.48 9.725a1.588 1.588 0 0 1-.004-2.239l4.627-4.627a1.583 1.583 0 0 1 2.24.004l-.37-.37a1.59 1.59 0 0 1-.003 2.243l-.124.124 3.743 3.744s2.496-1.247 4.992 1.248l-8.112 8.111c-2.495-2.495-1.248-4.991-1.248-4.991L4.478 9.228l-.125.125c-.62.62-1.624.621-2.244.002l.371.37z"></path></g>
</symbol>
<div class="tab-button" title="Pin">
<button aria-label="Pin">
<svg class="rc-icon tab-button-icon tab-button-icon--pin" aria-hidden="true">
<use xlink:href="#icon-pin"></use>
</svg>
</button>
</div>
</body>
I've been testing some things too but to no avail. To me it looks like all elements that are not visible on the screen are base64 encoded SVG icons.
All of those missing icons have changed after 0.58 I think, and maybe they have some image property that bugs in CSS with Firefox ESR.
EDIT: Except that icons are not encoded in base64 it seems. They are in one file under:
programs/server/assets/packages/rocketchat_ui-master/public/icons.svg
in the format like this:
<symbol viewBox="0 0 20 20" id="icon-star"><path d="M10 15l-4.898 2.575.935-5.454-3.962-3.863 5.476-.796L10 2.5l2.45 4.962 5.475.796-3.962 3.863.935 5.454z" stroke-width="1.5" stroke="currentColor" /></symbol>
The format seems to be SVG or pretty close to it.
Nevertheless, how this gets decoded in Firefox ESR might be the problem.
It seems to work if we use absolute url for href in
Please, rocket.chat guys, fix it!
@agulov Could it be a HTTPS issue? Try href="/channel/general#icon-bell" and href="http://rebelraven.rocket.chat/channel/general#icon-bell" (http instead of https)
@Lemmmy
href="/channel/general#icon-bell" works, i can see icon
href="http://rebelraven.rocket.chat/channel/general#icon-bell" does not work
Sorry, I can't understand how I can resolve this issue on my installation ( 0.59.3 ), someone can help me ? thanks
Minimally tested hack for anyone that needs a temporary fix. JQuery/JavaScript is not my strong point, improvements appreciated. This goes in Administration -> Layout -> Custom Scripts.
This makes use of the absolute URL workaround pointed out by @agulov above. It appears to fix the icon problems in previous versions of Firefox without breaking Chromium or Firefox 59 - I haven't tested any other browsers. Use with caution and don't forget to take it out after a proper fix has been released.
// Hack to get SVG icons working on Firefox 52 ESR and other pre-59 versions
$(document).ready(function(){
$("svg > use").map(function(){
var svg_string = $(this)[0].href;
if (svg_string.baseVal.startsWith("#")){
svg_string.baseVal = window.location.href + svg_string.baseVal;
svg_string.animVal = window.location.href + svg_string.animVal;
}
});
})
EDIT/take 2: Some icons weren't getting caught with the above due to the lack of full page reloads while using Rocket.Chat - particularly, the vertical ribbon of channel option icons. So did a bit more research, and came up with a more robust seeming fix using MutationObservers; most of this is well above my JavaScript level and thanks to this StackOverflow hero:
// Hack to get SVG icons showing on Firefox 52 ESR and other pre-59 versions
$(document).ready(function(){
var observer = new MutationObserver(expandSVGPathsOnMutation);
observer.observe(document, {
childList: true, // report added/removed nodes
subtree: true, // observe any descendant elements
});
// automatically updated HTMLCollection
var svg_uses = document.getElementsByTagName("use");
function expandSVGPathsOnMutation(mutations){
if (mutations.length == 1){
var added = mutations[0].addedNodes[0];
if (!added || (added.localName !== 'use' && !added.children.length)){
return;
}
}
for (var i = 0, len = svg_uses.length; i < len; i++){
var svg_string = svg_uses[i].href;
if (svg_string.baseVal.startsWith("#")){
svg_string.baseVal = window.location.href + svg_string.baseVal;
svg_string.animVal = window.location.href + svg_string.animVal;
}
}
}
})
Thanks for the fix! Works like a charm!
Yes, this Workaround works at my instance too, thanks a lot!
This test if (!added || (added.localName !== 'use' && !added.children.length)) was giving me a ton of "undefined has no properties" JavaScript errors, and in this case I don't think the children length check is needed. You should be OK to replace it with if (!added || added.localName !== 'use') if the errors bother you or are causing actual trouble.