soehler / androidsvg

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

illegal start byte 0xf0 #29

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I decided to run all of my SVG files through AndroidSVG to see if any others 
would have rendering issues (similar to Issue 13) when strange error came up:

01-14 14:35:11.489    6353-6353/hell.go.whatevapp W/dalvikvm﹕ JNI WARNING: 
NewStringUTF input is not valid Modified UTF-8: illegal start byte 0xf0
01-14 14:35:11.489    6353-6353/hell.go.whatevapp W/dalvikvm﹕ string: '𠂊'
01-14 14:35:11.489    6353-6353/hell.go.whatevapp W/dalvikvm﹕ in 
Lorg/apache/harmony/xml/ExpatAttributes;.getValueByIndex:(JI)Ljava/lang/String; 
(NewStringUTF)
01-14 14:35:11.489    6353-6353/hell.go.whatevapp I/dalvikvm﹕ "main" prio=5 
tid=1 NATIVE
01-14 14:35:11.489    6353-6353/hell.go.whatevapp I/dalvikvm﹕ | group="main" 
sCount=0 dsCount=0 obj=0x41cf3e28 self=0x41ce24c0
01-14 14:35:11.489    6353-6353/hell.go.whatevapp I/dalvikvm﹕ | sysTid=6353 
nice=0 sched=0/0 cgrp=apps handle=1074098516
01-14 14:35:11.489    6353-6353/hell.go.whatevapp I/dalvikvm﹕ | state=R 
schedstat=( 0 0 0 ) utm=1186 stm=23 core=1
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ #00  pc 
0000132e  /system/lib/libcorkscrew.so (unwind_backtrace_thread+29)
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ #01  pc 
0006353e  /system/lib/libdvm.so (dvmDumpNativeStack(DebugOutputTarget const*, 
int)+33)
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ #02  pc 
00057514  /system/lib/libdvm.so (dvmDumpThreadEx(DebugOutputTarget const*, 
Thread*, bool)+395)
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ #03  pc 
00057582  /system/lib/libdvm.so (dvmDumpThread(Thread*, bool)+25)
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ #04  pc 
0003b4d4  /system/lib/libdvm.so
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ #05  pc 
0003c90c  /system/lib/libdvm.so
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ #06  pc 
0003ecde  /system/lib/libdvm.so
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ #07  pc 
00014396  /system/lib/libjavacore.so
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ #08  pc 
0002034c  /system/lib/libdvm.so (dvmPlatformInvoke+112)
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ #09  pc 
00050e6a  /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, 
Method const*, Thread*)+397)
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
org.apache.harmony.xml.ExpatAttributes.getValueByIndex(Native Method)
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
org.apache.harmony.xml.ExpatAttributes.getValue(ExpatAttributes.java:72)
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
com.caverock.androidsvg.SVGParser.parseAttributesStyle(SVGParser.java:2571)
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
com.caverock.androidsvg.SVGParser.g(SVGParser.java:913)
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
com.caverock.androidsvg.SVGParser.startElement(SVGParser.java:623)
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
org.apache.harmony.xml.ExpatParser.startElement(ExpatParser.java:143)
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
org.apache.harmony.xml.ExpatParser.appendBytes(Native Method)
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:513)
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:316)
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
com.caverock.androidsvg.SVGParser.parse(SVGParser.java:576)
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
com.caverock.androidsvg.SVG.getFromInputStream(SVG.java:143)
01-14 14:35:11.495    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
hell.go.whatevapp.MainActivity.onCreate(MainActivity.java:73)
01-14 14:35:11.496    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
android.app.Activity.performCreate(Activity.java:5260)
01-14 14:35:11.496    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
01-14 14:35:11.496    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2154)
01-14 14:35:11.496    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
01-14 14:35:11.496    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
android.app.ActivityThread.access$700(ActivityThread.java:139)
01-14 14:35:11.496    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1411)
01-14 14:35:11.496    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
android.os.Handler.dispatchMessage(Handler.java:102)
01-14 14:35:11.496    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
android.os.Looper.loop(Looper.java:137)
01-14 14:35:11.496    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
android.app.ActivityThread.main(ActivityThread.java:5083)
01-14 14:35:11.496    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
java.lang.reflect.Method.invokeNative(Native Method)
01-14 14:35:11.496    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
java.lang.reflect.Method.invoke(Method.java:515)
01-14 14:35:11.496    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
01-14 14:35:11.496    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
01-14 14:35:11.496    6353-6353/hell.go.whatevapp I/dalvikvm﹕ at 
dalvik.system.NativeStart.main(Native Method)

I still have about 6000 of 6700 images to run through, but so far this error is 
constant across all of the 10 files (the character in the second line is 
different for some of them, but the line preceding it and the lines following 
it are identical across all files).

I'm sure there will be others, but here are the two different unicode values 
that have caused this error so far:

U+20509
U+2008A

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

GoogleCodeExporter commented 9 years ago
This looks like the problem is in the XML parser and is probably out of my 
control.

Are you able to provide a test file that contains one of these problematic 
strings?

Original comment by paul.leb...@gmail.com on 15 Jan 2014 at 2:02

GoogleCodeExporter commented 9 years ago
Sorry about that, attached to this post is one of the files that threw the 
error.

Original comment by MasterK...@gmail.com on 15 Jan 2014 at 2:35

Attachments:

GoogleCodeExporter commented 9 years ago
I played around with the SVG file today and confirmed that the issue is, as you 
suggested, a problem with the XML parser itself and not AndroidSVG; I had the 
same problem when I tried to use SVG-Android2 to display the file.

I used some Python to strip out the [kvg:element] attribute from the <g> nodes 
in that 05e45.svg file and am pleased to report that the file loaded properly 
with AndroidSVG. I imagine I'll be able to prevent these errors by running the 
other SVG files through the script and strip out other such problematic 
characters.

I suppose you can close this issue since the cause is unrelated to AndroidSVG.

Original comment by MasterK...@gmail.com on 15 Jan 2014 at 10:14

GoogleCodeExporter commented 9 years ago
The problematic sequence of bytes in question is f0 a0 92 8a.

The initial f0 byte indicates that it is a four byte encoding sequence. See 
https://en.wikipedia.org/wiki/UTF-8 .

Unfortunately, it seems that the "Modified UTF8" encoding, that Java 
implements, only supports up to 3 byte sequences.  That's according to 
http://docs.oracle.com/javase/6/docs/api/java/io/DataInput.html#modified-utf-8 .

Unfortunately I can't really intercept these strings before the XML parser 
processes them, so it seems like the simplest solution is to do as you proposed 
and strip the problematic attributes before passing them to AndroidSVG.

Original comment by paul.leb...@gmail.com on 16 Jan 2014 at 12:08

GoogleCodeExporter commented 9 years ago
Marking "Won't Fix"

Original comment by paul.leb...@gmail.com on 16 Jan 2014 at 12:09

GoogleCodeExporter commented 9 years ago
Actually, the SAX parser in Java likes it fine.  I think it may be the one in 
Harmony/Android that doesn't like four byte UTF-8 sequences.  Doing some more 
tests to confirm.

Original comment by paul.leb...@gmail.com on 16 Jan 2014 at 4:57

GoogleCodeExporter commented 9 years ago
Android bug report filed for this issue.

https://code.google.com/p/android/issues/detail?id=64892

Original comment by paul.leb...@gmail.com on 16 Jan 2014 at 11:55