首页 \ 问答 \ SVG在Firefox中无法正确呈现(SVG Not Rendering Correctly in Firefox)

SVG在Firefox中无法正确呈现(SVG Not Rendering Correctly in Firefox)

我正在为一个项目开发SVG徽标,并且在测试时,徽标在Google Chrome中呈现正常,但在Firefox中无法正常呈现。

Google Chrome中的徽标应该是: Google Chrome中的徽标

Firefox中的徽标是: Firefox中的徽标

我用于SVG的代码是:

<svg version="1.1" id="svg-logo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <rect id="svg-logo-rectangle" x="3.744" y="47.804" />
    <text id="svg-logo-text-crocker" transform="matrix(1 0 0 1 130 98.3037)">Crocker</text>
    <text id="svg-logo-text-estates" transform="matrix(1 0 0 1 130 163.3037)" font-size="64.9214">Estates</text>
    <text id="svg-logo-text-c" transform="matrix(1 0 0 1 0 118.3037)">C</text>
    <text id="svg-logo-text-e" transform="matrix(1 0 0 1 55 168.3037)">E</text>
    <text id="svg-logo-text-house-finder" transform="matrix(1 0 0 1 131 197.3037)">House Finder</text>
    <g id="svg-logo-house-1">
        <rect x="5.181" y="15.696" width="26.502" height="26.502"/>
        <polygon points="5.181,15.696 18.393,2.696 31.604,15.696    "/>
        <rect class="window" x="7.559" y="18.737" />
        <rect class="window" x="21.684" y="18.737" />
        <rect class="window" x="21.684" y="31.862" />
        <rect class="door" x="8.871" y="36.011" width="4.875" height="6.703"/>
    </g>
    <g id="svg-logo-house-2">
        <rect x="46.493" y="15.696" width="26.502" height="26.502"/>
        <polygon points="46.493,15.696 59.705,2.696 72.916,15.696   "/>
        <rect class="window" x="48.871" y="18.737" />
        <rect class="window" x="62.996" y="18.737" />
        <rect class="window" x="62.996" y="31.862" />
        <rect class="door" x="50.184" y="36.011" width="4.875" height="6.703"/>
    </g>
    <g id="svg-logo-house-3">
        <rect x="87.806" y="15.696" width="26.502" height="26.502"/>
        <polygon points="87.806,15.696 101.018,2.696 114.229,15.696     "/>
        <rect class="window" class="window" x="90.184" y="18.737" width="7.5" height="7.5"/>
        <rect class="window" class="window" x="104.309" y="18.737" width="7.5" height="7.5"/>
        <rect class="window" class="window" x="104.309" y="31.862" width="7.5" height="7.5"/>
        <rect class="door" x="91.496" y="36.011" />
    </g>
</svg>

你知道为什么这不起作用吗?


I am developing a SVG logo for a project, and, when testing it, the logo renders fine in Google Chrome, but doesn't render properly in Firefox.

The logo in Google Chrome, as it should look is: Logo in Google Chrome

And the logo in Firefox is: Logo in Firefox

The code I have used for the SVG is:

<svg version="1.1" id="svg-logo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <rect id="svg-logo-rectangle" x="3.744" y="47.804" />
    <text id="svg-logo-text-crocker" transform="matrix(1 0 0 1 130 98.3037)">Crocker</text>
    <text id="svg-logo-text-estates" transform="matrix(1 0 0 1 130 163.3037)" font-size="64.9214">Estates</text>
    <text id="svg-logo-text-c" transform="matrix(1 0 0 1 0 118.3037)">C</text>
    <text id="svg-logo-text-e" transform="matrix(1 0 0 1 55 168.3037)">E</text>
    <text id="svg-logo-text-house-finder" transform="matrix(1 0 0 1 131 197.3037)">House Finder</text>
    <g id="svg-logo-house-1">
        <rect x="5.181" y="15.696" width="26.502" height="26.502"/>
        <polygon points="5.181,15.696 18.393,2.696 31.604,15.696    "/>
        <rect class="window" x="7.559" y="18.737" />
        <rect class="window" x="21.684" y="18.737" />
        <rect class="window" x="21.684" y="31.862" />
        <rect class="door" x="8.871" y="36.011" width="4.875" height="6.703"/>
    </g>
    <g id="svg-logo-house-2">
        <rect x="46.493" y="15.696" width="26.502" height="26.502"/>
        <polygon points="46.493,15.696 59.705,2.696 72.916,15.696   "/>
        <rect class="window" x="48.871" y="18.737" />
        <rect class="window" x="62.996" y="18.737" />
        <rect class="window" x="62.996" y="31.862" />
        <rect class="door" x="50.184" y="36.011" width="4.875" height="6.703"/>
    </g>
    <g id="svg-logo-house-3">
        <rect x="87.806" y="15.696" width="26.502" height="26.502"/>
        <polygon points="87.806,15.696 101.018,2.696 114.229,15.696     "/>
        <rect class="window" class="window" x="90.184" y="18.737" width="7.5" height="7.5"/>
        <rect class="window" class="window" x="104.309" y="18.737" width="7.5" height="7.5"/>
        <rect class="window" class="window" x="104.309" y="31.862" width="7.5" height="7.5"/>
        <rect class="door" x="91.496" y="36.011" />
    </g>
</svg>

Do you have any idea why this doesn't work?


原文:https://stackoverflow.com/questions/41590038
更新时间:2021-12-27 16:12

最满意答案

根据您指出的文章,这就是原因:

易失性写入比非易失性写入要昂贵得多,因为保证可见性所需的内存防护但通常比锁定获取更便宜。

[...]易失性读取很便宜 - 几乎和非易失性读取一样便宜

当然,这是正确的:无论底层变量是否为易失性,内存围栏操作总是以写入和读取的方式执行。

但是,Java中的volatile不仅仅是易失性和非易失性内存读取。 事实上,它本质上与这种区别无关:区别在于并发语义

考虑这个臭名昭着的例子:

volatile boolean runningFlag = true;

void run() {
  while (runningFlag) { do work; }
}

如果runningFlag不是volatile ,那么JIT编译器基本上可以重写该代码

void run() {
   if (runningFlag) while (true) { do work; }
}

不用说,通过读取每次迭代的runningFlag而不是完全读取它所引入的开销比率是巨大的。


Here's why, according to the article you have indicated:

Volatile writes are considerably more expensive than nonvolatile writes because of the memory fencing required to guarantee visibility but still generally cheaper than lock acquisition.

[...] volatile reads are cheap -- nearly as cheap as nonvolatile reads

And that is, of course, true: memory fence operations are always bound to writing and reads execute the same way regardless of whether the underlying variable is volatile or not.

However, volatile in Java is about much more than just volatile vs. nonvolatile memory read. In fact, in its essence it has nothing to do with that distinction: the difference is in the concurrent semantics.

Consider this notorious example:

volatile boolean runningFlag = true;

void run() {
  while (runningFlag) { do work; }
}

If runningFlag wasn't volatile, the JIT compiler could essentially rewrite that code to

void run() {
   if (runningFlag) while (true) { do work; }
}

The ratio of overhead introduced by reading the runningFlag on each iteration against not reading it at all is, needless to say, enormous.

相关问答

更多
  • 是的,保证线程2将打印“完成”。 当然,如果在线程1中写入b实际上是在线程2中从b读取之前发生的,而不是在同一时间或更早的时间发生! 这里推理的核心是发生之前的关系 。 多线程程序执行被视为由事件组成。 事件可以通过发生之前的关系相关联,这表示一个事件发生在另一个事件之前。 即使两个事件不是直接相关的,如果你可以跟踪从一个事件到另一个事件之间的一连串发生关系,那么你可以说一个发生在另一个事件之前。 在您的情况下,您有以下事件: 线程1写入s 线程1写入b 线程2从b读取 线程2从s读取 以下规则发挥作用: ...
  • 根据您指出的文章,这就是原因: 易失性写入比非易失性写入要昂贵得多,因为保证可见性所需的内存防护但通常比锁定获取更便宜。 [...]易失性读取很便宜 - 几乎和非易失性读取一样便宜 当然,这是正确的:无论底层变量是否为易失性,内存围栏操作总是以写入和读取的方式执行。 但是,Java中的volatile不仅仅是易失性和非易失性内存读取。 事实上,它本质上与这种区别无关:区别在于并发语义 。 考虑这个臭名昭着的例子: volatile boolean runningFlag = true; void run( ...
  • int* volatile仅表示指针本身是volatile 。 指向的数据不是volatile限定的,这意味着以下场景可能会导致优化程序错误: int a=10; int* volatile ptr=&a; int main() { for(;;) { printf("%d\n", *ptr); } } void some_ISR (void) { a = something; } 编译器小心不要假设ptr在循环中的每一圈都没有指向同一个地址,但除此之外它可以自由地假设:“啊哈 ...
  • 写入引用类型(即Object )和字大小的值类型(即32位系统中的int )是原子的。 这意味着当你查看值(位置6)时,你可以确定你得到的是旧值或新值,但不是别的(如果你有一个像大型结构这样的类型,它可以被拼接,你可以在写作过程中读取价值)。 只要您愿意接受阅读陈旧价值的潜在风险,您就不需要 lock或volatile 。 请注意,由于在此处没有引入内存屏障(一个lock或使用volatile添加一个),所以可能该变量已在另一个线程中更新,但当前线程没有观察到该更改; 它可能会在另一个线程中更改(可能)一段 ...
  • 根据JMM,以下顺序严格按照先发生关系排序,因此保证了步骤1中读者在步骤4完成的更改的可见性: 写入x 从监视器M保护的同步块退出 进入由监视器M保护的同步块 从x读取 写入变量发生 - 在释放监视器之前,释放监视器 - 在获取相同的监视器并获取监视器发生之前 - 在从变量读取之前。 所以如果p和v是同步的,那么线程0会看到x的变化。 According to JMM the following sequence is strictly ordered by happens-before relations ...
  • 我的问题是,是否需要担心由于优化或其他线程缓存而导致静态_cachedResult仍然被其他线程视为null。 是的你是。 这是volatile存在的主要原因之一。 值得一提的是,无争议的锁定会增加一个完全可以忽略的性能成本,所以没有理由只是lock空检查和资源生成,因为它几乎肯定不会导致任何性能问题,并且使程序更容易关于的原因。 最好的解决方案是完全避免这个问题,并使用专门设计来解决您的确切问题的更高级别的抽象。 在这种情况下,这意味着Lazy 。 您可以创建一个Lazy对象,该对象定义了如何创建昂贵的资 ...
  • volatile确保访问对其他内核可见, Interlocked也是如此。 与互锁的区别在于它使用完整的内存屏障来保证并处理非原子操作。 易失性可能不会使用完整的内存屏障(取决于平台,例如x86 / x64不需要带有volatile的完整内存屏障......)但只能使原子操作“线程安全”。 通常建议避免使用volatile,因为它会使对该变量的每次原子访问都“易变”(这对x86 / x64来说可能不是那么大)并且有点隐藏了对变量的访问不同的事实。 通常更推荐使用Interlocked东西,因为它明确详细说明 ...
  • 从N个线程同时读取/写入(不销毁,不创建)“Q”元素是否安全? 不,不是。 看下一个情况。 Thread 1 Thread 2 qs.add(queue1); qs.delete(queue1); ... ... qs.add(queue100); qs.delete(queue100); 您同时添加并将对象删除到非同步 List 。 如果我们假设你们都尝试删除并添加到列表对象中,则会得到ConcurrentModific ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)