使用Rails inline_svg gem时,Safari崩溃了

时间:2016-03-03 16:46:41

标签: ruby-on-rails safari inline-svg

当使用inline_svg gem在页面上有svgs时,我的Rails应用程序中的某些页面似乎会导致Safari完全崩溃。

导航到该页面会导致错误消息' Safari Web Content意外退出。'

这是堆栈跟踪的一部分,让我相信它是SVG渲染的一个问题:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff8e2c1286 __pthread_kill + 10
1   libsystem_c.dylib               0x00007fff9a58db53 abort + 129
2   libsystem_c.dylib               0x00007fff9a555c39 __assert_rtn + 321
3   com.apple.CoreGraphics          0x00007fff90ff9d0e CGPathCreateMutableCopyByTransformingPath + 242
4   com.apple.CoreGraphics          0x00007fff9101de10 CGContextAddPath + 93
5   com.apple.WebCore               0x00007fff920d70c0 WebCore::GraphicsContext::strokePath(WebCore::Path const&) + 80
6   com.apple.WebCore               0x00007fff929c4140 WebCore::RenderSVGShape::strokeShape(WebCore::GraphicsContext*) const + 160
7   com.apple.WebCore               0x00007fff929c8673 WebCore::RenderSVGPath::strokeShape(WebCore::GraphicsContext*) const + 99
8   com.apple.WebCore               0x00007fff929d0fce WebCore::RenderSVGShape::strokeShape(WebCore::RenderStyle const&, WebCore::GraphicsContext*) + 126
9   com.apple.WebCore               0x00007fff929d116f WebCore::RenderSVGShape::strokeShape(WebCore::GraphicsContext*) + 191
10  com.apple.WebCore               0x00007fff929d11ce WebCore::RenderSVGShape::fillStrokeMarkers(WebCore::PaintInfo&) + 78
11  com.apple.WebCore               0x00007fff91ff927b WebCore::RenderSVGShape::paint(WebCore::PaintInfo&, WebCore::LayoutPoint const&) + 379
12  com.apple.WebCore               0x00007fff92052b03 WebCore::RenderSVGContainer::paint(WebCore::PaintInfo&, WebCore::LayoutPoint const&) + 531
13  com.apple.WebCore               0x00007fff92052b03 WebCore::RenderSVGContainer::paint(WebCore::PaintInfo&, WebCore::LayoutPoint const&) + 531
14  com.apple.WebCore               0x00007fff92052b03 WebCore::RenderSVGContainer::paint(WebCore::PaintInfo&, WebCore::LayoutPoint const&) + 531
15  com.apple.WebCore               0x00007fff91ff8f12 WebCore::RenderSVGRoot::paintReplaced(WebCore::PaintInfo&, WebCore::LayoutPoint const&) + 1330
16  com.apple.WebCore               0x00007fff91f70d32 WebCore::RenderReplaced::paint(WebCore::PaintInfo&, WebCore::LayoutPoint const&) + 722

这是svg本身的样子:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns" width="91px" height="25px" viewBox="0 0 91 25" version="1.1" class="priority-urgent">
    <title>Urgent</title>
    <desc>Created with sketchtool.</desc>
    <defs></defs>
    <g id="1/18" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
        <g id="Detail" sketch:type="MSArtboardGroup" transform="translate(-459.000000, -264.000000)">
            <g id="Group" sketch:type="MSLayerGroup" transform="translate(429.000000, 103.000000)">
                <g id="Urgent_flag" transform="translate(30.000000, 161.000000)">
                    <rect id="Rectangle-28" fill="#E74C3C" sketch:type="MSShapeGroup" x="0" y="0" width="91" height="25" rx="2">    </rect>
                    <text id="URGENT" sketch:type="MSTextLayer" font-family="Gotham Book" font-size="16" font-weight="313" sketch:alignment="middle" line-spacing="19" fill="#FFFFFF">
                        <tspan x="10.508" y="18">URGENT</tspan>
                    </text>
                </g>
            </g>
        </g>
    </g>
</svg>

1 个答案:

答案 0 :(得分:0)

原来我padding已经应用于<svg>上的css类,这是一个问题。考虑到图像应该缩放到多大或多小,Safari可能会考虑填充?无论如何,在删除填充后,Safari停止了崩溃。