zakariachowdhury / androidsvg

Automatically exported from code.google.com/p/androidsvg
0 stars 0 forks source link

Parser crash (file attached) #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

The attached SVG file crashes the SVGParser.

Here's the stacktrace:

08-21 19:12:59.707: E/ResourceImageItem(16638): Could not load image from 
resource
08-21 19:12:59.707: E/ResourceImageItem(16638): java.lang.NullPointerException
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
com.caverock.androidsvg.SVGParser.parsePath(SVGParser.java:3648)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
com.caverock.androidsvg.SVGParser.parseAttributesPath(SVGParser.java:1091)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
com.caverock.androidsvg.SVGParser.path(SVGParser.java:1078)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
com.caverock.androidsvg.SVGParser.startElement(SVGParser.java:629)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
org.apache.harmony.xml.ExpatParser.startElement(ExpatParser.java:143)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
org.apache.harmony.xml.ExpatParser.appendBytes(Native Method)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:513)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:321)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
com.caverock.androidsvg.SVGParser.parse(SVGParser.java:576)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
com.caverock.androidsvg.SVG.getFromResource(SVG.java:172)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
uk.ac.ucl.excites.collector.ui.picker.items.ResourceImageItem.setImage(ResourceI
mageItem.java:66)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
uk.ac.ucl.excites.collector.ui.picker.items.ImageItem.createView(ImageItem.java:
38)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
uk.ac.ucl.excites.collector.ui.picker.items.Item.getView(Item.java:36)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
uk.ac.ucl.excites.collector.ui.picker.PickerAdapter.getView(PickerAdapter.java:7
1)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.widget.AbsListView.obtainView(AbsListView.java:2465)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.widget.GridView.onMeasure(GridView.java:1030)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.view.View.measure(View.java:15326)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4876)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.view.View.measure(View.java:15326)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4876)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.view.View.measure(View.java:15326)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4876)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.view.View.measure(View.java:15326)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4876)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.jav
a:2423)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.view.View.measure(View.java:15326)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1974)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1217)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1390)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1113)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4481)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.view.Choreographer.doCallbacks(Choreographer.java:555)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.view.Choreographer.doFrame(Choreographer.java:525)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.os.Handler.handleCallback(Handler.java:615)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.os.Handler.dispatchMessage(Handler.java:92)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.os.Looper.loop(Looper.java:137)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
android.app.ActivityThread.main(ActivityThread.java:4867)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
java.lang.reflect.Method.invokeNative(Native Method)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
java.lang.reflect.Method.invoke(Method.java:511)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
08-21 19:12:59.707: E/ResourceImageItem(16638):     at 
dalvik.system.NativeStart.main(Native Method)
08-21 19:12:59.737: E/ResourceImageItem(16638): Could not load image from 
resource
08-21 19:12:59.737: E/ResourceImageItem(16638): java.lang.NullPointerException
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
com.caverock.androidsvg.SVGParser.parsePath(SVGParser.java:3648)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
com.caverock.androidsvg.SVGParser.parseAttributesPath(SVGParser.java:1091)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
com.caverock.androidsvg.SVGParser.path(SVGParser.java:1078)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
com.caverock.androidsvg.SVGParser.startElement(SVGParser.java:629)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
org.apache.harmony.xml.ExpatParser.startElement(ExpatParser.java:143)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
org.apache.harmony.xml.ExpatParser.appendBytes(Native Method)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:513)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:321)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
com.caverock.androidsvg.SVGParser.parse(SVGParser.java:576)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
com.caverock.androidsvg.SVG.getFromResource(SVG.java:172)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
uk.ac.ucl.excites.collector.ui.picker.items.ResourceImageItem.setImage(ResourceI
mageItem.java:66)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
uk.ac.ucl.excites.collector.ui.picker.items.ImageItem.createView(ImageItem.java:
38)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
uk.ac.ucl.excites.collector.ui.picker.items.Item.getView(Item.java:36)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
uk.ac.ucl.excites.collector.ui.picker.PickerAdapter.getView(PickerAdapter.java:7
1)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.widget.AbsListView.obtainView(AbsListView.java:2465)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.widget.GridView.makeAndAddView(GridView.java:1331)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.widget.GridView.makeRow(GridView.java:331)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.widget.GridView.fillDown(GridView.java:283)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.widget.GridView.fillFromTop(GridView.java:407)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.widget.GridView.layoutChildren(GridView.java:1219)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.widget.AbsListView.onLayout(AbsListView.java:2300)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.view.View.layout(View.java:13891)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.view.ViewGroup.layout(ViewGroup.java:4424)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.view.View.layout(View.java:13891)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.view.ViewGroup.layout(ViewGroup.java:4424)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.widget.FrameLayout.onLayout(FrameLayout.java:448)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.view.View.layout(View.java:13891)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.view.ViewGroup.layout(ViewGroup.java:4424)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.view.View.layout(View.java:13891)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.view.ViewGroup.layout(ViewGroup.java:4424)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.widget.FrameLayout.onLayout(FrameLayout.java:448)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.view.View.layout(View.java:13891)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.view.ViewGroup.layout(ViewGroup.java:4424)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1992)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1813)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1113)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4481)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.view.Choreographer.doCallbacks(Choreographer.java:555)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.view.Choreographer.doFrame(Choreographer.java:525)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.os.Handler.handleCallback(Handler.java:615)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.os.Handler.dispatchMessage(Handler.java:92)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.os.Looper.loop(Looper.java:137)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
android.app.ActivityThread.main(ActivityThread.java:4867)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
java.lang.reflect.Method.invokeNative(Native Method)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
java.lang.reflect.Method.invoke(Method.java:511)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
08-21 19:12:59.737: E/ResourceImageItem(16638):     at 
dalvik.system.NativeStart.main(Native Method)

Original issue reported on code.google.com by matthias...@gmail.com on 21 Aug 2013 at 6:15

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by paul.leb...@gmail.com on 21 Aug 2013 at 6:21

GoogleCodeExporter commented 9 years ago
Fixed in revision 242.

Made path parser more permissive.  Was balking at paths with commas between 
extra coords. Ed. "L1,2,3,4" (vs "L1,2 3,4").   

This fix will be in the upcoming release 1.3.0.

Workaround for now: remove commas from between pairs of coords.  So for example 
in this file, change the path def to:

  "M18.773,952.36 0,971.14 31.047,1002.5 0,1033.6l18.773,18.773 31.047-31.048 ...
                 ^        ^             ^                      ^             ^

Thanks for the bug report!

Original comment by paul.leb...@gmail.com on 21 Aug 2013 at 7:07

GoogleCodeExporter commented 9 years ago
Your welcome! Thanks for the lighting fast fix!

Original comment by matthias...@gmail.com on 21 Aug 2013 at 7:11

GoogleCodeExporter commented 9 years ago
Issue 27 has been merged into this issue.

Original comment by paul.leb...@gmail.com on 7 Jan 2014 at 3:59

GoogleCodeExporter commented 9 years ago
Issue 28 has been merged into this issue.

Original comment by paul.leb...@gmail.com on 14 Jan 2014 at 2:21

GoogleCodeExporter commented 9 years ago
This fix is available in the 1.2.1 release.

Original comment by paul.leb...@gmail.com on 31 Jan 2014 at 1:33