Large SVG crash on ipod


#1

Hi

I’m using some large SVG files, some >300k, which Juce renders ok in an Mac OS X app, but in an iPod/iPhone port of the app, crash on the device. I’m using an 8GB iPod running iOS 4.0.
The crash happens in the XML parsing in the CreateFromSVG function.

Smaller SVG files, <100k, produced in the same way (with Illustrator) work fine on the device.
Because of this, could this be a problem with memory allocation within the XML data structures?

Here’s the trace back:

0   libSystem.B.dylib             	0x000ae500 wcslen + 8
1   MyApp                         	0x00068004 juce::CharacterFunctions::length(wchar_t const*) (juce_CharacterFunctions.cpp:53)
2   MyApp                         	0x000681d0 juce::String::length() const (juce_String.cpp:470)
3   MyApp                         	0x00079264 juce::String::operator[](int) const (juce_String.h:434)
4   MyApp                         	0x00174d94 juce::SVGState::parsePath(juce::XmlElement const&) const (juce_SVGParser.cpp:476)
5   MyApp                         	0x00176938 juce::SVGState::parseSubElements(juce::XmlElement const&, juce::DrawableComposite*) (juce_SVGParser.cpp:155)
6   MyApp                         	0x001779c4 juce::SVGState::parseGroupElement(juce::XmlElement const&) (juce_SVGParser.cpp:204)
7   MyApp                         	0x00176880 juce::SVGState::parseSubElements(juce::XmlElement const&, juce::DrawableComposite*) (juce_SVGParser.cpp:151)
8   MyApp                         	0x001779c4 juce::SVGState::parseGroupElement(juce::XmlElement const&) (juce_SVGParser.cpp:204)
9   MyApp                         	0x00176880 juce::SVGState::parseSubElements(juce::XmlElement const&, juce::DrawableComposite*) (juce_SVGParser.cpp:151)
10  MyApp                         	0x001779c4 juce::SVGState::parseGroupElement(juce::XmlElement const&) (juce_SVGParser.cpp:204)
11  MyApp                         	0x00177a6c juce::SVGState::parseSwitch(juce::XmlElement const&) (juce_SVGParser.cpp:184)
12  MyApp                         	0x00176c20 juce::SVGState::parseSubElements(juce::XmlElement const&, juce::DrawableComposite*) (juce_SVGParser.cpp:171)
13  MyApp                         	0x00177754 juce::SVGState::parseSVGElement(juce::XmlElement const&) (juce_SVGParser.cpp:131)
14  MyApp                         	0x000d0990 juce::Drawable::createFromSVG(juce::XmlElement const&) (juce_SVGParser.cpp:1302)
15  MyApp                         	0x000d0ca8 juce::Drawable::createFromImageData(void const*, unsigned long) (juce_Drawable.cpp:113)

Thanks!


#2

The XML structures are about as efficient as they could be, but the parser does need to load the whole thing into memory before it can start using it. The strings are held as 4-byte unicode and there’ll be space wasted for data alignment, etc, so a 300k file could easily eat up 2Mb of heap space. Still, 2MB isn’t an awful lot… I’m sure the ipod has at 96MB…?


#3

Fixed.

I was working in debug, so I tried cleaning the release build, built release and it worked fine.
So I cleaned and rebuilt debug and strangely it now works fine… perhaps Xcode got out of sync somehow after rebuilding the resources with binarybuilder?