2016-03-03 75 views
0

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

导航到页面会导致错误消息“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> 

回答

0

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