mchoe / SwiftSVG

A simple, performant, and lightweight SVG parser
Other
1.92k stars 229 forks source link

Mutiple crash due to swift optimization setting. #92

Closed buguibu closed 4 years ago

buguibu commented 6 years ago

Just download the recent master release, run on whatever device with release scheme or enable "Optimize for Speed" optimization level swift setting, and you will get different crashes based on which demo you try. captura de pantalla 2018-04-11 a las 16 05 56 captura de pantalla 2018-04-11 a las 16 05 21

mchoe commented 6 years ago

Hi @buguibu, I just tried this with XCode 9.3 on the latest release and am not able to reproduce. Can you attach a stack trace? Thanks.

buguibu commented 6 years ago

Hi @mchoe this is strange, so i've just reproduce it again even cleaning derived data and reseting simulator, so more details:

Hope it helps!

Robuske commented 6 years ago

I have the same problem, but @buguibu I believe that you meant

Build configuration Release or Debug but with SWIFT_OPTIMIZATION_LEVEL = "-O";

Also, I've found that compilation mode needs to be set to Whole Module And I'm using Swift 4.1, It probably has something to do with some of the changes https://swift.org/blog/osize/

Robuske commented 6 years ago

I found a way of creating a temporary fix that you can commit to the project

# Temporary fix for SwiftSVG Crash
post_install do |installer|
  swiftSVG = installer.pods_project.targets.find { |target| target.name == 'SwiftSVG' }
  swiftSVG.build_configurations.each do |config|
    config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = "-Onone"
  end
end
DamienBell commented 6 years ago

Just wanted to say I'm running into the exact same issue. It's an important one because it's a bug that only shows up in release builds. @Robuske solution worked for me.

afedor commented 6 years ago

FYI, here's a very simple macOS project which illustrates the crash. Oddly it doesn't crash all the time and not always in the same place, but it does crash most of the time

SwiftSVGOptCrash.zip

alexbartisro commented 6 years ago

+1, just found this issue today when distributing a build to stakeholders

tobins commented 6 years ago

+1. Found that turning off swift optimizations with @Robuske addition to the project's Podfile worked.

pavelgubarev commented 6 years ago

Hi! We have the same problem with our project. Maybe this crashlog can help you:

The app with SwiftSVG works fine when we launch it on our devices with xCode. But when we make a build and distribute it with TestFlight we have this error (from Crahslytics).

0Crashed: com.straussmade.swiftsvgEXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000018 Raw Text

-- 0 | SwiftSVG | Identifiable.swift line 74_T08SwiftSVG12IdentifiablePA2A19SVGContainerElementRzrlE8identifyySS10identifier_tFAA8SVGGroupC_Tg5 1 | SwiftSVG | SVGParserSupportedElements.swift line 0_T08SwiftSVG12IdentifiablePA2A19SVGContainerElementRzrlE8identifyySS10identifier_tFAA8SVGGroupC_Tg5TA 2 | SwiftSVG | SVGParserSupportedElements.swift line 0_T0SSIegx_SSytIegirTRTA 3 | SwiftSVG | NSXMLSVGParser.swift line 142specialized NSXMLSVGParser.parser(:didStartElement:namespaceURI:qualifiedName:attributes:) 4 | SwiftSVG | NSXMLSVGParser.swift line 0@objc NSXMLSVGParser.parser(_:didStartElement:namespaceURI:qualifiedName:attributes:)

Line number 74 in Identifiable.swift is self.containerLayer.name = identifier

buguibu commented 4 years ago

This doesn't use to happen me again.