Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed reflection on java.lang.String. Was causing a crash on M #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

meghneelgore
Copy link

Removed reflection on java.lang.String. Was causing a crash on Android M

@andreidiaconu
Copy link

Can someone take a look at this? I also encountered this issue and unless this gets merged, the library does not work on android 6

@tinsukE
Copy link

tinsukE commented Jan 7, 2016

I'm using this fix in my fork https://github.com/tinsukE/svg-android. You can use it in gradle/maven with https://jitpack.io/:

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

...

compile 'com.github.tinsukE:svg-android:2.0.6-1'

@vitorprado
Copy link

@tinsukE your repo isn't listed in mavancentral.. how can I use your fork?

@tinsukE
Copy link

tinsukE commented Jan 18, 2016

@vitorprado I'm sorry I wasn't clear. I've updated my answer, and you can check out more about it:
https://jitpack.io/#tinsukE/svg-android

@vitorprado
Copy link

@tinsukE Thanks!

private final char[] s;
private final int n;
private char current;
public int pos;

public ParserHelper(String str, int pos) {
try {
this.s = (char[]) STRING_CHARS.get(str);
this.s = str.toCharArray();
Copy link

@refreshingdev refreshingdev Aug 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be costly, because toCharArray() copies the characters, as the javadoc says. This object might be constructed many times even during processing a single image. I have changed s to be a String, and use charAt() instead of getting from an array. Should charAt() be fast, it is a native method in newer SDKs, older use array access inside.
Should actually measure performance, it works as fast as previously (as perceived) for me anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants