alexandre-g / androidsvg

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

AndroidSVG chokes with NPE while parsing one SVG file in particular #28

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm using AndroidSVG to display SVG kanji stroke diagrams. When I try to 
display one diagram in particular a Null Pointer Exception is caught. Here's 
the stack trace from a recent occurrence:

java.lang.NullPointerException
at com.caverock.androidsvg.SVGParser.parsePath(SVGParser.java:3674)
at com.caverock.androidsvg.SVGParser.parseAttributesPath(SVGParser.java:1091)
at com.caverock.androidsvg.SVGParser.path(SVGParser.java:1078)
at com.caverock.androidsvg.SVGParser.startElement(SVGParser.java:629)
at org.apache.harmony.xml.ExpatParser.startElement(ExpatParser.java:143)
at org.apache.harmony.xml.ExpatParser.appendBytes(Native Method)
at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:513)
at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:316)
at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
at com.caverock.androidsvg.SVGParser.parse(SVGParser.java:576)
at com.caverock.androidsvg.SVG.getFromInputStream(SVG.java:143)
at com.gshoapp.DialogStrokeOrder.onCreateDialog(DialogStrokeOrder.java:67)
at android.app.DialogFragment.getLayoutInflater(DialogFragment.java:398)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
at android.app.BackStackRecord.run(BackStackRecord.java:684)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)

And here's line 66 and 67 from my code:

InputStream is = new BufferedInputStream(new FileInputStream(svgPath));
SVG svg = SVG.getFromInputStream(is);

The code was able to handle the other dozen or so diagrams I threw at it, so I 
think the problem might be somewhere in AndroidSVG. After some testing I've 
determined that it's not an issue of the file not existing - I've verified that 
it's in the proper directory. In an effort to isolate it from potential issues 
from my code, I attempted to load the SVG in a separate, basic app that I 
drafted exclusively to test AndroidSVG functionality; that app threw the same 
error.

I've attached the image that causes the issue, I hope it helps. If it's an 
issue of a malformed SVG, let me know and I'll redirect the issue to the group 
responsible for making the original file.

Original issue reported on code.google.com by MasterK...@gmail.com on 13 Jan 2014 at 11:01

Attachments:

GoogleCodeExporter commented 9 years ago
Hi. Thanks for the report, and thanks for using AndroidSVG.

I am pretty sure this is also a duplicate of Issue 13.

To work around this bug until 1.3 is released, replace the comma between path 
command coordinate sequences with a space.

For example on line 43 of that file, the path definition is:

d="m13.5,67.39c1.62,0.99,2.5,0.99,4.12,-0.51,4.43,-4.09,7.63,-7,18.45,-17.66"/>

change it to:

d="m13.5,67.39c1.62,0.99,2.5,0.99,4.12,-0.51 4.43,-4.09,7.63,-7,18.45,-17.66"/>

Note the space after the "-0.51".  It looks like that is the only occurrence in 
that file.

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