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

生成的trace显示com.sample.systrace.MainActivity.onCreate.(Landroid.os.Bundle;)V(Did Not Finish) #2

Open
YuanYuan927 opened this issue Feb 8, 2020 · 3 comments

Comments

@YuanYuan927
Copy link

生成的trace显示com.sample.systrace.MainActivity.onCreate.(Landroid.os.Bundle;)V(Did Not Finish),实际上onCreate早运行完成了,我自己手动插桩就是正常的请问这是什么原因?

@softrice
Copy link

softrice commented May 14, 2020

@YuanSun927 Trace.beginSection(name)和 Trace.endSection()不对应导致的。
起初我怀疑是多线程导致的不对应问题,加了线程限制后还是有这个问题。
后来我建立一个变量,在Trace.beginSection(name)变量+1,Trace.endSection()的时候变量-1.
最后得到的结果是6。说明有部分函数没有正确的调用 Trace.endSection()。

@softrice
Copy link

package android.support.graphics.drawable
public class AnimatorInflaterCompat {
    public static Animator loadAnimator(Context context, Resources resources, Theme theme, @AnimatorRes int id, float pathErrorScale) throws NotFoundException {
        TraceTag.i("android.support.graphics.drawable.AnimatorInflaterCompat.loadAnimator.");
        XmlResourceParser parser = null;

        Animator var7;
        try {
            NotFoundException rnf;
            try {
                parser = resources.getAnimation(id);
                Animator animator = createAnimatorFromXml(context, resources, theme, parser, pathErrorScale);
                var7 = animator;
            } catch (XmlPullParserException var13) {
                rnf = new NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id));
                rnf.initCause(var13);
                TraceTag.o();
                throw rnf;
            } catch (IOException var14) {
                rnf = new NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id));
                rnf.initCause(var14);
                TraceTag.o();
                throw rnf;
            }
        } catch (Throwable var15) {
            if (parser != null) {
                parser.close();
            }

            TraceTag.o();
            throw var15;
        }

        if (parser != null) {
            parser.close();
        }

        TraceTag.o();
        return var7;
    }
}

如这个类 可能就会造成2次调用Trace.endSection()

@softrice
Copy link

softrice commented May 14, 2020

查看了matrix源码,解决方法是Trace.beginSection的时候传入唯一id。
像这样Trace.beginSection(name,34234224) Trace.endSection(34234224) 这样不会导致多次Trace.endSection,但是没找到没调用Trace.endSection的情况。

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

No branches or pull requests

2 participants